diff --git a/cmd/containerd-shim-runhcs-v1/events_test.go b/cmd/containerd-shim-runhcs-v1/events_test.go index 0b227efdc2..04f3d4897c 100644 --- a/cmd/containerd-shim-runhcs-v1/events_test.go +++ b/cmd/containerd-shim-runhcs-v1/events_test.go @@ -19,7 +19,3 @@ func (p *fakePublisher) publishEvent(ctx context.Context, topic string, event in p.events = append(p.events, event) return nil } - -func (p *fakePublisher) getEvents() []interface{} { - return p.events -} diff --git a/cmd/containerd-shim-runhcs-v1/exec_hcs.go b/cmd/containerd-shim-runhcs-v1/exec_hcs.go index 7c2115c2cc..0886ff19a5 100644 --- a/cmd/containerd-shim-runhcs-v1/exec_hcs.go +++ b/cmd/containerd-shim-runhcs-v1/exec_hcs.go @@ -2,7 +2,6 @@ package main import ( "context" - "strings" "sync" "time" @@ -22,18 +21,6 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" "go.opencensus.io/trace" - "golang.org/x/sys/windows" -) - -const ( - // processStopTimeout is the amount of time after signaling the process with - // a signal expected to kill the process that the exec must wait before - // forcibly terminating the process. - // - // For example, sending a SIGKILL is expected to kill a process. If the - // process does not stop within `processStopTimeout` we will forcibly - // terminate the process without a signal. - processStopTimeout = time.Second * 5 ) // newHcsExec creates an exec to track the lifetime of `spec` in `c` which is @@ -199,7 +186,7 @@ func (he *hcsExec) startInternal(ctx context.Context, initializeContainer bool) } defer func() { if err != nil { - he.c.Terminate(ctx) + _ = he.c.Terminate(ctx) he.c.Close() } }() @@ -233,22 +220,26 @@ func (he *hcsExec) startInternal(ctx context.Context, initializeContainer bool) // Publish the task/exec start event. This MUST happen before waitForExit to // avoid publishing the exit previous to the start. if he.id != he.tid { - he.events.publishEvent( + if err := he.events.publishEvent( ctx, runtime.TaskExecStartedEventTopic, &eventstypes.TaskExecStarted{ ContainerID: he.tid, ExecID: he.id, Pid: uint32(he.pid), - }) + }); err != nil { + return err + } } else { - he.events.publishEvent( + if err := he.events.publishEvent( ctx, runtime.TaskStartEventTopic, &eventstypes.TaskStart{ ContainerID: he.tid, Pid: uint32(he.pid), - }) + }); err != nil { + return err + } } // wait in the background for the exit. @@ -350,7 +341,7 @@ func (he *hcsExec) ForceExit(ctx context.Context, status int) { he.exitFromCreatedL(ctx, status) case shimExecStateRunning: // Kill the process to unblock `he.waitForExit` - he.p.Process.Kill(ctx) + _, _ = he.p.Process.Kill(ctx) } } } @@ -451,14 +442,14 @@ func (he *hcsExec) waitForExit() { he.sl.Unlock() // Wait for all IO copies to complete and free the resources. - he.p.Wait() + _ = he.p.Wait() he.io.Close(ctx) // Only send the `runtime.TaskExitEventTopic` notification if this is a true // exec. For the `init` exec this is handled in task teardown. if he.tid != he.id { // We had a valid process so send the exited notification. - he.events.publishEvent( + if err := he.events.publishEvent( ctx, runtime.TaskExitEventTopic, &eventstypes.TaskExit{ @@ -467,7 +458,9 @@ func (he *hcsExec) waitForExit() { Pid: uint32(he.pid), ExitStatus: he.exitStatus, ExitedAt: he.exitedAt, - }) + }); err != nil { + log.G(ctx).WithError(err).Error("failed to publish TaskExitEvent") + } } // Free any waiters. @@ -490,7 +483,7 @@ func (he *hcsExec) waitForContainerExit() { cexit := make(chan struct{}) go func() { - he.c.Wait() + _ = he.c.Wait() close(cexit) }() select { @@ -503,7 +496,7 @@ func (he *hcsExec) waitForContainerExit() { he.exitFromCreatedL(ctx, 1) case shimExecStateRunning: // Kill the process to unblock `he.waitForExit`. - he.p.Process.Kill(ctx) + _, _ = he.p.Process.Kill(ctx) } he.sl.Unlock() case <-he.processDone: @@ -511,12 +504,3 @@ func (he *hcsExec) waitForContainerExit() { // `he.waitForExit` will release any waiters. } } - -// escapeArgs makes a Windows-style escaped command line from a set of arguments -func escapeArgs(args []string) string { - escapedArgs := make([]string, len(args)) - for i, a := range args { - escapedArgs[i] = windows.EscapeArg(a) - } - return strings.Join(escapedArgs, " ") -} diff --git a/cmd/containerd-shim-runhcs-v1/exec_wcow_podsandbox.go b/cmd/containerd-shim-runhcs-v1/exec_wcow_podsandbox.go index b4cae61206..0a4b4e7eb7 100644 --- a/cmd/containerd-shim-runhcs-v1/exec_wcow_podsandbox.go +++ b/cmd/containerd-shim-runhcs-v1/exec_wcow_podsandbox.go @@ -130,17 +130,15 @@ func (wpse *wcowPodSandboxExec) Start(ctx context.Context) error { wpse.state = shimExecStateRunning wpse.pid = 1 // Fake but init pid is always 1 - // Publish the task start event. We mever have an exec for the WCOW + // Publish the task start event. We never have an exec for the WCOW // PodSandbox. - wpse.events.publishEvent( + return wpse.events.publishEvent( ctx, runtime.TaskStartEventTopic, &eventstypes.TaskStart{ ContainerID: wpse.tid, Pid: uint32(wpse.pid), }) - - return nil } func (wpse *wcowPodSandboxExec) Kill(ctx context.Context, signal uint32) error { diff --git a/cmd/containerd-shim-runhcs-v1/main.go b/cmd/containerd-shim-runhcs-v1/main.go index 1c983cd80b..e0ee3a4ac0 100644 --- a/cmd/containerd-shim-runhcs-v1/main.go +++ b/cmd/containerd-shim-runhcs-v1/main.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "os" - "runtime" "strings" "github.com/Microsoft/go-winio/pkg/etw" @@ -44,17 +43,6 @@ var ( idFlag string ) -func stack() []byte { - buf := make([]byte, 1024) - for { - n := runtime.Stack(buf, true) // true means all goroutines - if n < len(buf) { - return buf[:n] - } - buf = make([]byte, 2*len(buf)) - } -} - func etwCallback(sourceID guid.GUID, state etw.ProviderState, level etw.Level, matchAnyKeyword uint64, matchAllKeyword uint64, filterData uintptr) { if state == etw.ProviderStateCaptureState { resp, err := svc.DiagStacks(context.Background(), &shimdiag.StacksRequest{}) @@ -83,7 +71,7 @@ func main() { } } - provider.WriteEvent( + _ = provider.WriteEvent( "ShimLaunched", nil, etw.WithFields( diff --git a/cmd/containerd-shim-runhcs-v1/pod.go b/cmd/containerd-shim-runhcs-v1/pod.go index 9606769463..bdec1d4c75 100644 --- a/cmd/containerd-shim-runhcs-v1/pod.go +++ b/cmd/containerd-shim-runhcs-v1/pod.go @@ -176,7 +176,7 @@ func createPod(ctx context.Context, events publisher, req *task.CreateTaskReques p.sandboxTask = newWcowPodSandboxTask(ctx, events, req.ID, req.Bundle, parent, nsid) // Publish the created event. We only do this for a fake WCOW task. A // HCS Task will event itself based on actual process lifetime. - events.publishEvent( + if err := events.publishEvent( ctx, runtime.TaskCreateEventTopic, &eventstypes.TaskCreate{ @@ -191,7 +191,9 @@ func createPod(ctx context.Context, events publisher, req *task.CreateTaskReques }, Checkpoint: "", Pid: 0, - }) + }); err != nil { + return nil, err + } } else { if isWCOW { // The pause container activation will immediately exit on Windows diff --git a/cmd/containerd-shim-runhcs-v1/serve.go b/cmd/containerd-shim-runhcs-v1/serve.go index 224904fc62..c4f64ec66a 100644 --- a/cmd/containerd-shim-runhcs-v1/serve.go +++ b/cmd/containerd-shim-runhcs-v1/serve.go @@ -282,6 +282,5 @@ func setupDebuggerEvent() { return } logrus.WithField("event", event).Info("Halting until signalled") - windows.WaitForSingleObject(handle, windows.INFINITE) - return + _, _ = windows.WaitForSingleObject(handle, windows.INFINITE) } diff --git a/cmd/containerd-shim-runhcs-v1/service.go b/cmd/containerd-shim-runhcs-v1/service.go index d7bd114fb8..cc25d87ae1 100644 --- a/cmd/containerd-shim-runhcs-v1/service.go +++ b/cmd/containerd-shim-runhcs-v1/service.go @@ -17,11 +17,6 @@ import ( "go.opencensus.io/trace" ) -type cdevent struct { - topic string - event interface{} -} - var _ = (task.TaskService)(&service{}) type service struct { @@ -460,7 +455,7 @@ func (s *service) DiagPid(ctx context.Context, req *shimdiag.PidRequest) (*shimd if s == nil { return nil, nil } - ctx, span := trace.StartSpan(ctx, "DiagPid") + ctx, span := trace.StartSpan(ctx, "DiagPid") //nolint:ineffassign,staticcheck defer span.End() span.AddAttributes(trace.StringAttribute("tid", s.tid)) diff --git a/cmd/containerd-shim-runhcs-v1/start.go b/cmd/containerd-shim-runhcs-v1/start.go index f49462280b..e5fa54929a 100644 --- a/cmd/containerd-shim-runhcs-v1/start.go +++ b/cmd/containerd-shim-runhcs-v1/start.go @@ -154,7 +154,7 @@ The start command can either start a new shim or return an address to an existin w.Close() defer func() { if err != nil { - cmd.Process.Kill() + _ = cmd.Process.Kill() } }() diff --git a/cmd/containerd-shim-runhcs-v1/task.go b/cmd/containerd-shim-runhcs-v1/task.go index 337661da77..2b3b835adc 100644 --- a/cmd/containerd-shim-runhcs-v1/task.go +++ b/cmd/containerd-shim-runhcs-v1/task.go @@ -17,15 +17,6 @@ import ( var errTaskNotIsolated = errors.New("task is not isolated") -// shimTaskPidPair groups a process pid to its execID if it was user generated. -type shimTaskPidPair struct { - // Pid is the pid of the container process. - Pid int - // ExecID is the id of the exec if this container process was user - // generated. - ExecID string -} - type shimTask interface { // ID returns the original id used at `Create`. ID() string diff --git a/cmd/containerd-shim-runhcs-v1/task_hcs.go b/cmd/containerd-shim-runhcs-v1/task_hcs.go index ddd493eac3..438cb73985 100644 --- a/cmd/containerd-shim-runhcs-v1/task_hcs.go +++ b/cmd/containerd-shim-runhcs-v1/task_hcs.go @@ -147,12 +147,11 @@ func newHcsTask( } opts := hcsoci.CreateOptions{ - ID: req.ID, - Owner: owner, - Spec: s, - HostingSystem: parent, - NetworkNamespace: netNS, - ScaleCPULimitsToSandbox: shimOpts.ScaleCpuLimitsToSandbox, + ID: req.ID, + Owner: owner, + Spec: s, + HostingSystem: parent, + NetworkNamespace: netNS, } if shimOpts != nil { @@ -204,7 +203,7 @@ func newHcsTask( go ht.waitInitExit(!isTemplate) // Publish the created event - ht.events.publishEvent( + if err := ht.events.publishEvent( ctx, runtime.TaskCreateEventTopic, &eventstypes.TaskCreate{ @@ -219,7 +218,9 @@ func newHcsTask( }, Checkpoint: "", Pid: uint32(ht.init.Pid()), - }) + }); err != nil { + return nil, err + } return ht, nil } @@ -312,7 +313,7 @@ func newClonedHcsTask( go ht.waitInitExit(true) // Publish the created event - ht.events.publishEvent( + if err := ht.events.publishEvent( ctx, runtime.TaskCreateEventTopic, &eventstypes.TaskCreate{ @@ -327,7 +328,9 @@ func newClonedHcsTask( }, Checkpoint: "", Pid: uint32(ht.init.Pid()), - }) + }); err != nil { + return nil, err + } return ht, nil } @@ -443,15 +446,13 @@ func (ht *hcsTask) CreateExec(ctx context.Context, req *task.ExecProcessRequest, ht.execs.Store(req.ExecID, he) // Publish the created event - ht.events.publishEvent( + return ht.events.publishEvent( ctx, runtime.TaskExecAddedEventTopic, &eventstypes.TaskExecAdded{ ContainerID: ht.id, ExecID: req.ExecID, }) - - return nil } func (ht *hcsTask) GetExec(eid string) (shimExec, error) { @@ -542,7 +543,7 @@ func (ht *hcsTask) DeleteExec(ctx context.Context, eid string) (int, uint32, tim } // Publish the deleted event - ht.events.publishEvent( + if err := ht.events.publishEvent( ctx, runtime.TaskDeleteEventTopic, &eventstypes.TaskDelete{ @@ -551,7 +552,9 @@ func (ht *hcsTask) DeleteExec(ctx context.Context, eid string) (int, uint32, tim Pid: status.Pid, ExitStatus: status.ExitStatus, ExitedAt: status.ExitedAt, - }) + }); err != nil { + return 0, 0, time.Time{}, err + } return int(status.Pid), status.ExitStatus, status.ExitedAt, nil } @@ -741,7 +744,8 @@ func (ht *hcsTask) closeHost(ctx context.Context) { } // Send the `init` exec exit notification always. exit := ht.init.Status() - ht.events.publishEvent( + + if err := ht.events.publishEvent( ctx, runtime.TaskExitEventTopic, &eventstypes.TaskExit{ @@ -750,7 +754,9 @@ func (ht *hcsTask) closeHost(ctx context.Context) { Pid: uint32(exit.Pid), ExitStatus: exit.ExitStatus, ExitedAt: exit.ExitedAt, - }) + }); err != nil { + log.G(ctx).WithError(err).Error("failed to publish TaskExitEventTopic") + } close(ht.closed) }) } diff --git a/cmd/containerd-shim-runhcs-v1/task_hcs_test.go b/cmd/containerd-shim-runhcs-v1/task_hcs_test.go index 13e0acbf86..798af38556 100644 --- a/cmd/containerd-shim-runhcs-v1/task_hcs_test.go +++ b/cmd/containerd-shim-runhcs-v1/task_hcs_test.go @@ -176,7 +176,7 @@ func Test_hcsTask_DeleteExec_InitExecID_RunningState_Error(t *testing.T) { lt.execs.Delete(second.id) // Start the init exec - init.Start(context.TODO()) + _ = init.Start(context.TODO()) // try to delete the init exec pid, status, at, err := lt.DeleteExec(context.TODO(), "") @@ -190,7 +190,7 @@ func Test_hcsTask_DeleteExec_InitExecID_ExitedState_Success(t *testing.T) { // remove the 2nd exec so we just check without it. lt.execs.Delete(second.id) - init.Kill(context.TODO(), 0xf) + _ = init.Kill(context.TODO(), 0xf) // try to delete the init exec pid, status, at, err := lt.DeleteExec(context.TODO(), "") @@ -205,7 +205,7 @@ func Test_hcsTask_DeleteExec_InitExecID_2ndExec_CreatedState_Error(t *testing.T) lt, init, second := setupTestHcsTask(t) // start the init exec (required to have 2nd exec) - init.Start(context.TODO()) + _ = init.Start(context.TODO()) // try to delete the init exec pid, status, at, err := lt.DeleteExec(context.TODO(), "") @@ -221,10 +221,10 @@ func Test_hcsTask_DeleteExec_InitExecID_2ndExec_RunningState_Error(t *testing.T) lt, init, second := setupTestHcsTask(t) // start the init exec (required to have 2nd exec) - init.Start(context.TODO()) + _ = init.Start(context.TODO()) // put the 2nd exec into the running state - second.Start(context.TODO()) + _ = second.Start(context.TODO()) // try to delete the init exec pid, status, at, err := lt.DeleteExec(context.TODO(), "") @@ -240,9 +240,9 @@ func Test_hcsTask_DeleteExec_InitExecID_2ndExec_ExitedState_Success(t *testing.T lt, init, second := setupTestHcsTask(t) // put the init exec into the exited state - init.Kill(context.TODO(), 0xf) + _ = init.Kill(context.TODO(), 0xf) // put the 2nd exec into the exited state - second.Kill(context.TODO(), 0xf) + _ = second.Kill(context.TODO(), 0xf) // try to delete the init exec pid, status, at, err := lt.DeleteExec(context.TODO(), "") @@ -257,7 +257,7 @@ func Test_hcsTask_DeleteExec_2ndExecID_CreatedState_Success(t *testing.T) { lt, init, second := setupTestHcsTask(t) // start the init exec (required to have 2nd exec) - init.Start(context.TODO()) + _ = init.Start(context.TODO()) // try to delete the 2nd exec pid, status, at, err := lt.DeleteExec(context.TODO(), second.id) @@ -272,10 +272,10 @@ func Test_hcsTask_DeleteExec_2ndExecID_RunningState_Error(t *testing.T) { lt, init, second := setupTestHcsTask(t) // start the init exec (required to have 2nd exec) - init.Start(context.TODO()) + _ = init.Start(context.TODO()) // put the 2nd exec into the running state - second.Start(context.TODO()) + _ = second.Start(context.TODO()) // try to delete the 2nd exec pid, status, at, err := lt.DeleteExec(context.TODO(), second.id) @@ -288,10 +288,10 @@ func Test_hcsTask_DeleteExec_2ndExecID_ExitedState_Success(t *testing.T) { lt, init, second := setupTestHcsTask(t) // start the init exec (required to have 2nd exec) - init.Kill(context.TODO(), 0xf) + _ = init.Kill(context.TODO(), 0xf) // put the 2nd exec into the exited state - second.Kill(context.TODO(), 0xf) + _ = second.Kill(context.TODO(), 0xf) // try to delete the 2nd exec pid, status, at, err := lt.DeleteExec(context.TODO(), second.id) diff --git a/cmd/containerd-shim-runhcs-v1/task_wcow_podsandbox.go b/cmd/containerd-shim-runhcs-v1/task_wcow_podsandbox.go index 0fd700fae6..93422c75af 100644 --- a/cmd/containerd-shim-runhcs-v1/task_wcow_podsandbox.go +++ b/cmd/containerd-shim-runhcs-v1/task_wcow_podsandbox.go @@ -136,7 +136,7 @@ func (wpst *wcowPodSandboxTask) DeleteExec(ctx context.Context, eid string) (int status := e.Status() // Publish the deleted event - wpst.events.publishEvent( + if err := wpst.events.publishEvent( ctx, runtime.TaskDeleteEventTopic, &eventstypes.TaskDelete{ @@ -145,7 +145,9 @@ func (wpst *wcowPodSandboxTask) DeleteExec(ctx context.Context, eid string) (int Pid: status.Pid, ExitStatus: status.ExitStatus, ExitedAt: status.ExitedAt, - }) + }); err != nil { + return 0, 0, time.Time{}, err + } return int(status.Pid), status.ExitStatus, status.ExitedAt, nil } @@ -189,7 +191,8 @@ func (wpst *wcowPodSandboxTask) close(ctx context.Context) { } // Send the `init` exec exit notification always. exit := wpst.init.Status() - wpst.events.publishEvent( + + if err := wpst.events.publishEvent( ctx, runtime.TaskExitEventTopic, &eventstypes.TaskExit{ @@ -198,7 +201,9 @@ func (wpst *wcowPodSandboxTask) close(ctx context.Context) { Pid: uint32(exit.Pid), ExitStatus: exit.ExitStatus, ExitedAt: exit.ExitedAt, - }) + }); err != nil { + log.G(ctx).WithError(err).Error("failed to publish TaskExitEventTopic") + } close(wpst.closed) }) } diff --git a/cmd/ncproxy/main.go b/cmd/ncproxy/main.go index 8fbc1c923e..46874b448b 100644 --- a/cmd/ncproxy/main.go +++ b/cmd/ncproxy/main.go @@ -68,9 +68,12 @@ func main() { opts := []grpc.DialOption{grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{})} if conf.Timeout > 0 { - opts = append(opts, grpc.WithBlock(), grpc.WithTimeout(time.Duration(conf.Timeout)*time.Second)) + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, time.Duration(conf.Timeout)*time.Second) + defer cancel() + opts = append(opts, grpc.WithBlock()) } - client, err := grpc.Dial(conf.NodeNetSvcAddr, opts...) + client, err := grpc.DialContext(ctx, conf.NodeNetSvcAddr, opts...) if err != nil { log.G(ctx).Fatalf("failed to connect to NodeNetworkService at address %s", conf.NodeNetSvcAddr) } diff --git a/cmd/ncproxy/ncproxy.go b/cmd/ncproxy/ncproxy.go index 3610be8a12..8f37b7d182 100644 --- a/cmd/ncproxy/ncproxy.go +++ b/cmd/ncproxy/ncproxy.go @@ -90,7 +90,7 @@ func (s *grpcService) DeleteNIC(ctx context.Context, req *ncproxygrpc.DeleteNICR // HNS Methods // func (s *grpcService) CreateNetwork(ctx context.Context, req *ncproxygrpc.CreateNetworkRequest) (_ *ncproxygrpc.CreateNetworkResponse, err error) { - ctx, span := trace.StartSpan(ctx, "CreateNetwork") + ctx, span := trace.StartSpan(ctx, "CreateNetwork") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() @@ -177,7 +177,7 @@ func (s *grpcService) CreateNetwork(ctx context.Context, req *ncproxygrpc.Create } func (s *grpcService) CreateEndpoint(ctx context.Context, req *ncproxygrpc.CreateEndpointRequest) (_ *ncproxygrpc.CreateEndpointResponse, err error) { - ctx, span := trace.StartSpan(ctx, "CreateEndpoint") + ctx, span := trace.StartSpan(ctx, "CreateEndpoint") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() @@ -251,7 +251,7 @@ func (s *grpcService) CreateEndpoint(ctx context.Context, req *ncproxygrpc.Creat } func (s *grpcService) AddEndpoint(ctx context.Context, req *ncproxygrpc.AddEndpointRequest) (_ *ncproxygrpc.AddEndpointResponse, err error) { - ctx, span := trace.StartSpan(ctx, "AddEndpoint") + ctx, span := trace.StartSpan(ctx, "AddEndpoint") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() @@ -278,7 +278,7 @@ func (s *grpcService) AddEndpoint(ctx context.Context, req *ncproxygrpc.AddEndpo } func (s *grpcService) DeleteEndpoint(ctx context.Context, req *ncproxygrpc.DeleteEndpointRequest) (_ *ncproxygrpc.DeleteEndpointResponse, err error) { - ctx, span := trace.StartSpan(ctx, "DeleteEndpoint") + ctx, span := trace.StartSpan(ctx, "DeleteEndpoint") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() @@ -304,7 +304,7 @@ func (s *grpcService) DeleteEndpoint(ctx context.Context, req *ncproxygrpc.Delet } func (s *grpcService) DeleteNetwork(ctx context.Context, req *ncproxygrpc.DeleteNetworkRequest) (_ *ncproxygrpc.DeleteNetworkResponse, err error) { - ctx, span := trace.StartSpan(ctx, "DeleteNetwork") + ctx, span := trace.StartSpan(ctx, "DeleteNetwork") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() @@ -330,7 +330,7 @@ func (s *grpcService) DeleteNetwork(ctx context.Context, req *ncproxygrpc.Delete } func (s *grpcService) GetEndpoint(ctx context.Context, req *ncproxygrpc.GetEndpointRequest) (_ *ncproxygrpc.GetEndpointResponse, err error) { - ctx, span := trace.StartSpan(ctx, "GetEndpoint") + ctx, span := trace.StartSpan(ctx, "GetEndpoint") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() @@ -358,7 +358,7 @@ func (s *grpcService) GetEndpoint(ctx context.Context, req *ncproxygrpc.GetEndpo } func (s *grpcService) GetEndpoints(ctx context.Context, req *ncproxygrpc.GetEndpointsRequest) (_ *ncproxygrpc.GetEndpointsResponse, err error) { - ctx, span := trace.StartSpan(ctx, "GetEndpoints") + ctx, span := trace.StartSpan(ctx, "GetEndpoints") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() @@ -383,7 +383,7 @@ func (s *grpcService) GetEndpoints(ctx context.Context, req *ncproxygrpc.GetEndp } func (s *grpcService) GetNetwork(ctx context.Context, req *ncproxygrpc.GetNetworkRequest) (_ *ncproxygrpc.GetNetworkResponse, err error) { - ctx, span := trace.StartSpan(ctx, "GetNetwork") + ctx, span := trace.StartSpan(ctx, "GetNetwork") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() @@ -409,7 +409,7 @@ func (s *grpcService) GetNetwork(ctx context.Context, req *ncproxygrpc.GetNetwor } func (s *grpcService) GetNetworks(ctx context.Context, req *ncproxygrpc.GetNetworksRequest) (_ *ncproxygrpc.GetNetworksResponse, err error) { - ctx, span := trace.StartSpan(ctx, "GetNetworks") + ctx, span := trace.StartSpan(ctx, "GetNetworks") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() @@ -439,7 +439,7 @@ type ttrpcService struct { } func (s *ttrpcService) RegisterComputeAgent(ctx context.Context, req *ncproxyttrpc.RegisterComputeAgentRequest) (_ *ncproxyttrpc.RegisterComputeAgentResponse, err error) { - ctx, span := trace.StartSpan(ctx, "RegisterComputeAgent") + ctx, span := trace.StartSpan(ctx, "RegisterComputeAgent") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() @@ -465,7 +465,7 @@ func (s *ttrpcService) RegisterComputeAgent(ctx context.Context, req *ncproxyttr } func (s *ttrpcService) ConfigureNetworking(ctx context.Context, req *ncproxyttrpc.ConfigureNetworkingInternalRequest) (_ *ncproxyttrpc.ConfigureNetworkingInternalResponse, err error) { - ctx, span := trace.StartSpan(ctx, "ConfigureNetworking") + ctx, span := trace.StartSpan(ctx, "ConfigureNetworking") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() diff --git a/cmd/runhcs/container.go b/cmd/runhcs/container.go index 5fcfbdc707..ac5eb49bed 100644 --- a/cmd/runhcs/container.go +++ b/cmd/runhcs/container.go @@ -80,9 +80,8 @@ const ( type container struct { persistedState - ShimPid int - hc *hcs.System - resources *resources.Resources + ShimPid int + hc *hcs.System } func startProcessShim(id, pidFile, logFile string, spec *specs.Process) (_ *os.Process, err error) { @@ -165,7 +164,7 @@ func launchShim(cmd, pidFile, logFile string, args []string, data interface{}) ( } defer func() { if err != nil { - p.Kill() + _ = p.Kill() } }() @@ -374,7 +373,7 @@ func createContainer(cfg *containerConfig) (_ *container, err error) { } defer func() { if err != nil { - c.Remove() + _ = c.Remove() } }() if isSandbox && vmisolated { @@ -385,7 +384,7 @@ func createContainer(cfg *containerConfig) (_ *container, err error) { } defer func() { if err != nil { - cnicfg.Remove() + _ = cnicfg.Remove() } }() } @@ -396,13 +395,10 @@ func createContainer(cfg *containerConfig) (_ *container, err error) { if err != nil { return nil, err } - switch opts.(type) { + switch opts := opts.(type) { case *uvm.OptionsLCOW: - lopts := opts.(*uvm.OptionsLCOW) - lopts.ConsolePipe = cfg.VMConsolePipe + opts.ConsolePipe = cfg.VMConsolePipe case *uvm.OptionsWCOW: - wopts := opts.(*uvm.OptionsWCOW) - // In order for the UVM sandbox.vhdx not to collide with the actual // nested Argon sandbox.vhdx we append the \vm folder to the last entry // in the list. @@ -417,14 +413,14 @@ func createContainer(cfg *containerConfig) (_ *container, err error) { } layers[layersLen-1] = vmPath - wopts.LayerFolders = layers + opts.LayerFolders = layers } shim, err := c.startVMShim(cfg.VMLogFile, opts) if err != nil { return nil, err } - shim.Release() + _ = shim.Release() } if c.HostID != "" { @@ -451,7 +447,7 @@ func createContainer(cfg *containerConfig) (_ *container, err error) { err = startContainerShim(c, cfg.PidFile, cfg.ShimLogFile) if err != nil { if e := c.Kill(); e == nil { - c.Remove() + _ = c.Remove() } return nil, err } @@ -482,7 +478,7 @@ func (c *container) unmountInHost(vm *uvm.UtilityVM, all bool) error { } err = resources.ReleaseResources(context.Background(), r, vm, all) if err != nil { - stateKey.Set(c.ID, keyResources, r) + _ = stateKey.Set(c.ID, keyResources, r) return err } @@ -500,19 +496,17 @@ func (c *container) Unmount(all bool) error { op = runhcs.OpUnmountContainer } err := c.issueVMRequest(op) - if err != nil { - if _, ok := err.(*noVMError); ok { - logrus.WithFields(logrus.Fields{ - logfields.ContainerID: c.ID, - logfields.UVMID: c.HostID, - logrus.ErrorKey: errors.New("failed to unmount container resources"), - }).Warning("VM shim could not be contacted") - } else { - return err - } + if _, ok := err.(*noVMError); ok { + logrus.WithFields(logrus.Fields{ + logfields.ContainerID: c.ID, + logfields.UVMID: c.HostID, + logrus.ErrorKey: errors.New("failed to unmount container resources"), + }).Warning("VM shim could not be contacted") + } else { + return err } } else { - c.unmountInHost(nil, false) + _ = c.unmountInHost(nil, false) } return nil } @@ -544,9 +538,9 @@ func createContainerInHost(c *container, vm *uvm.UtilityVM) (err error) { } defer func() { if err != nil { - hc.Terminate(context.Background()) - hc.Wait() - resources.ReleaseResources(context.Background(), r, vm, true) + _ = hc.Terminate(context.Background()) + _ = hc.Wait() + _ = resources.ReleaseResources(context.Background(), r, vm, true) } }() @@ -572,10 +566,12 @@ func startContainerShim(c *container, pidFile, logFile string) error { if err != nil { return err } - defer shim.Release() + defer func() { + _ = shim.Release() + }() defer func() { if err != nil { - shim.Kill() + _ = shim.Kill() } }() @@ -622,7 +618,9 @@ func (c *container) Exec() error { if err != nil { return err } - defer shim.Release() + defer func() { + _ = shim.Release() + }() err = runhcs.GetErrorFromPipe(pipe, shim) if err != nil { @@ -673,8 +671,8 @@ func (c *container) Remove() error { if c.IsHost { vm, err := hcs.OpenComputeSystem(context.Background(), vmID(c.ID)) if err == nil { - vm.Terminate(context.Background()) - vm.Wait() + _ = vm.Terminate(context.Background()) + _ = vm.Wait() } } return stateKey.Remove(c.ID) @@ -684,7 +682,7 @@ func (c *container) Kill() error { if c.hc == nil { return nil } - c.hc.Terminate(context.Background()) + _ = c.hc.Terminate(context.Background()) return c.hc.Wait() } diff --git a/cmd/runhcs/create.go b/cmd/runhcs/create.go index 5eb5b9e61a..7443729a53 100644 --- a/cmd/runhcs/create.go +++ b/cmd/runhcs/create.go @@ -54,7 +54,7 @@ The specification file includes an args parameter. The args parameter is used to specify command(s) that get run when the container is started. To change the command(s) that get executed on start, edit the args parameter of the spec. See "runc spec --help" for more explanation.`, - Flags: append(createRunFlags), + Flags: createRunFlags, Before: appargs.Validate(argID), Action: func(context *cli.Context) error { cfg, err := containerConfigFromContext(context) diff --git a/cmd/runhcs/run.go b/cmd/runhcs/run.go index 04cf868c45..a88bf8b4df 100644 --- a/cmd/runhcs/run.go +++ b/cmd/runhcs/run.go @@ -56,7 +56,7 @@ command(s) that get executed on start, edit the args parameter of the spec.`, if err != nil { return err } - c.Remove() + _ = c.Remove() os.Exit(int(state.Sys().(syscall.WaitStatus).ExitCode)) } return nil diff --git a/cmd/runhcs/shim.go b/cmd/runhcs/shim.go index eaf84f0c97..cc37503eb7 100644 --- a/cmd/runhcs/shim.go +++ b/cmd/runhcs/shim.go @@ -8,7 +8,6 @@ import ( "io/ioutil" "net" "os" - "strings" "time" winio "github.com/Microsoft/go-winio" @@ -19,13 +18,8 @@ import ( specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" "github.com/urfave/cli" - "golang.org/x/sys/windows" ) -func containerPipePath(id string) string { - return runhcs.SafePipePath("runhcs-shim-" + id) -} - func newFile(context *cli.Context, param string) *os.File { fd := uintptr(context.Int(param)) if fd == 0 { @@ -113,18 +107,18 @@ var shimCommand = cli.Command{ // Alert the parent process that initialization has completed // successfully. - errorOut.Write(runhcs.ShimSuccess) + _, _ = errorOut.Write(runhcs.ShimSuccess) errorOut.Close() fatalWriter.Writer = ioutil.Discard // When this process exits, clear this process's pid in the registry. defer func() { - stateKey.Set(id, keyShimPid, 0) + _ = stateKey.Set(id, keyShimPid, 0) }() defer func() { if terminateOnFailure { - c.hc.Terminate(gcontext.Background()) + _ = c.hc.Terminate(gcontext.Background()) <-containerExitCh } }() @@ -181,34 +175,35 @@ var shimCommand = cli.Command{ err = stateKey.Set(c.ID, keyInitPid, pid) if err != nil { stdin.Close() - cmd.Process.Kill(gcontext.Background()) - cmd.Wait() + _, _ = cmd.Process.Kill(gcontext.Background()) + _ = cmd.Wait() return err } } // Store the Guest pid map err = stateKey.Set(c.ID, fmt.Sprintf(keyPidMapFmt, os.Getpid()), pid) + if err != nil { stdin.Close() - cmd.Process.Kill(gcontext.Background()) - cmd.Wait() + _, _ = cmd.Process.Kill(gcontext.Background()) + _ = cmd.Wait() return err } defer func() { // Remove the Guest pid map when this process is cleaned up - stateKey.Clear(c.ID, fmt.Sprintf(keyPidMapFmt, os.Getpid())) + _ = stateKey.Clear(c.ID, fmt.Sprintf(keyPidMapFmt, os.Getpid())) }() terminateOnFailure = false // Alert the connected process that the process was launched // successfully. - errorOut.Write(runhcs.ShimSuccess) + _, _ = errorOut.Write(runhcs.ShimSuccess) errorOut.Close() fatalWriter.Writer = ioutil.Discard - cmd.Wait() + _ = cmd.Wait() code := cmd.ExitState.ExitCode() if !exec { // Shutdown the container, waiting 5 minutes before terminating is @@ -225,21 +220,11 @@ var shimCommand = cli.Command{ } if err != nil { - c.hc.Terminate(gcontext.Background()) + _ = c.hc.Terminate(gcontext.Background()) } <-containerExitCh - err = containerExitErr } return cli.NewExitError("", code) }, } - -// escapeArgs makes a Windows-style escaped command line from a set of arguments -func escapeArgs(args []string) string { - escapedArgs := make([]string, len(args)) - for i, a := range args { - escapedArgs[i] = windows.EscapeArg(a) - } - return strings.Join(escapedArgs, " ") -} diff --git a/cmd/runhcs/vm.go b/cmd/runhcs/vm.go index c766900597..9e684e486b 100644 --- a/cmd/runhcs/vm.go +++ b/cmd/runhcs/vm.go @@ -128,7 +128,7 @@ var vmshimCommand = cli.Command{ err = closeWritePipe(pipe) } if err == nil { - ioutil.ReadAll(pipe) + _, _ = ioutil.ReadAll(pipe) } } else { logrus.WithError(err). @@ -169,7 +169,7 @@ func processRequest(vm *uvm.UtilityVM, pipe net.Conn) error { c2 := c c = nil go func() { - c2.hc.Wait() + _ = c2.hc.Wait() c2.Close() }() diff --git a/cmd/shimdiag/exec.go b/cmd/shimdiag/exec.go index 8b5ff90934..9510814ece 100644 --- a/cmd/shimdiag/exec.go +++ b/cmd/shimdiag/exec.go @@ -60,7 +60,9 @@ var execCommand = cli.Command{ if err != nil { return err } - defer con.Reset() + defer func() { + _ = con.Reset() + }() // Console reads return EOF whenever the user presses Ctrl-Z. // Wrap the reads to translate these EOFs back. osStdin = rawConReader{os.Stdin} @@ -120,11 +122,12 @@ func makePipe(f interface{}, in bool) (string, error) { logrus.WithError(err).Error("failed to accept pipe") return } + if in { - io.Copy(c, f.(io.Reader)) + _, _ = io.Copy(c, f.(io.Reader)) c.Close() } else { - io.Copy(f.(io.Writer), c) + _, _ = io.Copy(f.(io.Writer), c) } }() return p, nil diff --git a/cmd/tar2ext4/tar2ext4.go b/cmd/tar2ext4/tar2ext4.go index 9f298d2ae8..ce1ba89a0b 100644 --- a/cmd/tar2ext4/tar2ext4.go +++ b/cmd/tar2ext4/tar2ext4.go @@ -54,7 +54,7 @@ func main() { } // Exhaust the tar stream. - io.Copy(ioutil.Discard, in) + _, _ = io.Copy(ioutil.Discard, in) return nil }() if err != nil { diff --git a/cmd/wclayer/mount.go b/cmd/wclayer/mount.go index 2d04ac208a..096aba60cf 100644 --- a/cmd/wclayer/mount.go +++ b/cmd/wclayer/mount.go @@ -43,7 +43,7 @@ var mountCommand = cli.Command{ } defer func() { if err != nil { - hcsshim.DeactivateLayer(driverInfo, path) + _ = hcsshim.DeactivateLayer(driverInfo, path) } }() @@ -53,7 +53,7 @@ var mountCommand = cli.Command{ } defer func() { if err != nil { - hcsshim.UnprepareLayer(driverInfo, path) + _ = hcsshim.UnprepareLayer(driverInfo, path) } }() diff --git a/computestorage/attach.go b/computestorage/attach.go index dcc61347c5..7f1f2823dd 100644 --- a/computestorage/attach.go +++ b/computestorage/attach.go @@ -18,7 +18,7 @@ import ( // `layerData` is the parent read-only layer data. func AttachLayerStorageFilter(ctx context.Context, layerPath string, layerData LayerData) (err error) { title := "hcsshim.AttachLayerStorageFilter" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/computestorage/destroy.go b/computestorage/destroy.go index 39a9ba3812..8e28e6c504 100644 --- a/computestorage/destroy.go +++ b/computestorage/destroy.go @@ -13,7 +13,7 @@ import ( // `layerPath` is a path to a directory containing the layer to export. func DestroyLayer(ctx context.Context, layerPath string) (err error) { title := "hcsshim.DestroyLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("layerPath", layerPath)) diff --git a/computestorage/detach.go b/computestorage/detach.go index 9c144c066b..435473257e 100644 --- a/computestorage/detach.go +++ b/computestorage/detach.go @@ -13,7 +13,7 @@ import ( // `layerPath` is a path to a directory containing the layer to export. func DetachLayerStorageFilter(ctx context.Context, layerPath string) (err error) { title := "hcsshim.DetachLayerStorageFilter" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("layerPath", layerPath)) diff --git a/computestorage/export.go b/computestorage/export.go index 649b2602ae..a1b12dd129 100644 --- a/computestorage/export.go +++ b/computestorage/export.go @@ -20,7 +20,7 @@ import ( // `options` are the export options applied to the exported layer. func ExportLayer(ctx context.Context, layerPath, exportFolderPath string, layerData LayerData, options ExportLayerOptions) (err error) { title := "hcsshim.ExportLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/computestorage/format.go b/computestorage/format.go index fe0861d2a0..83c0fa33f0 100644 --- a/computestorage/format.go +++ b/computestorage/format.go @@ -14,7 +14,7 @@ import ( // If the VHD is not mounted it will be temporarily mounted. func FormatWritableLayerVhd(ctx context.Context, vhdHandle windows.Handle) (err error) { title := "hcsshim.FormatWritableLayerVhd" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() diff --git a/computestorage/helpers.go b/computestorage/helpers.go index 93546f34d7..87fee452cd 100644 --- a/computestorage/helpers.go +++ b/computestorage/helpers.go @@ -70,7 +70,7 @@ func SetupContainerBaseLayer(ctx context.Context, layerPath, baseVhdPath, diffVh defer func() { if err != nil { - syscall.CloseHandle(handle) + _ = syscall.CloseHandle(handle) os.RemoveAll(baseVhdPath) os.RemoveAll(diffVhdPath) } @@ -146,7 +146,7 @@ func SetupUtilityVMBaseLayer(ctx context.Context, uvmPath, baseVhdPath, diffVhdP defer func() { if err != nil { - syscall.CloseHandle(handle) + _ = syscall.CloseHandle(handle) os.RemoveAll(baseVhdPath) os.RemoveAll(diffVhdPath) } diff --git a/computestorage/import.go b/computestorage/import.go index 8ad2b085cb..0c61dab329 100644 --- a/computestorage/import.go +++ b/computestorage/import.go @@ -20,7 +20,7 @@ import ( // `layerData` is the parent layer data. func ImportLayer(ctx context.Context, layerPath, sourceFolderPath string, layerData LayerData) (err error) { title := "hcsshim.ImportLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/computestorage/initialize.go b/computestorage/initialize.go index a50afd821e..53ed8ea6ed 100644 --- a/computestorage/initialize.go +++ b/computestorage/initialize.go @@ -17,7 +17,7 @@ import ( // `layerData` is the parent read-only layer data. func InitializeWritableLayer(ctx context.Context, layerPath string, layerData LayerData) (err error) { title := "hcsshim.InitializeWritableLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/computestorage/mount.go b/computestorage/mount.go index 1c16ff4094..fcdbbef814 100644 --- a/computestorage/mount.go +++ b/computestorage/mount.go @@ -13,7 +13,7 @@ import ( // GetLayerVhdMountPath returns the volume path for a virtual disk of a writable container layer. func GetLayerVhdMountPath(ctx context.Context, vhdHandle windows.Handle) (path string, err error) { title := "hcsshim.GetLayerVhdMountPath" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() diff --git a/computestorage/setup.go b/computestorage/setup.go index 7506709ca6..ca7b40ef66 100644 --- a/computestorage/setup.go +++ b/computestorage/setup.go @@ -22,7 +22,7 @@ import ( // `options` are the options applied while processing the layer. func SetupBaseOSLayer(ctx context.Context, layerPath string, vhdHandle windows.Handle, options OsLayerOptions) (err error) { title := "hcsshim.SetupBaseOSLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( @@ -53,7 +53,7 @@ func SetupBaseOSVolume(ctx context.Context, layerPath, volumePath string, option return errors.New("SetupBaseOSVolume is not present on builds older than 19645") } title := "hcsshim.SetupBaseOSVolume" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/errors.go b/errors.go index 061727c679..5bdc23e45d 100644 --- a/errors.go +++ b/errors.go @@ -132,15 +132,6 @@ func (e *ContainerError) Error() string { return s } -func makeContainerError(container *container, operation string, extraInfo string, err error) error { - // Don't double wrap errors - if _, ok := err.(*ContainerError); ok { - return err - } - containerError := &ContainerError{Container: container, Operation: operation, ExtraInfo: extraInfo, Err: err} - return containerError -} - func (e *ProcessError) Error() string { if e == nil { return "" @@ -171,15 +162,6 @@ func (e *ProcessError) Error() string { return s } -func makeProcessError(process *process, operation string, extraInfo string, err error) error { - // Don't double wrap errors - if _, ok := err.(*ProcessError); ok { - return err - } - processError := &ProcessError{Process: process, Operation: operation, ExtraInfo: extraInfo, Err: err} - return processError -} - // IsNotExist checks if an error is caused by the Container or Process not existing. // Note: Currently, ErrElementNotFound can mean that a Process has either // already exited, or does not exist. Both IsAlreadyStopped and IsNotExist diff --git a/ext4/internal/compactext4/compact.go b/ext4/internal/compactext4/compact.go index 823a5c5d97..d9a959ffeb 100644 --- a/ext4/internal/compactext4/compact.go +++ b/ext4/internal/compactext4/compact.go @@ -732,7 +732,7 @@ func (w *Writer) seekBlock(block uint32) { func (w *Writer) nextBlock() { if w.pos%blockSize != 0 { // Simplify callers; w.err is updated on failure. - w.zero(blockSize - w.pos%blockSize) + _, _ = w.zero(blockSize - w.pos%blockSize) } } @@ -782,7 +782,7 @@ func (w *Writer) writeExtents(inode *inode) error { extents [4]format.ExtentLeafNode } fillExtents(&root.hdr, root.extents[:extents], startBlock, 0, blocks) - binary.Write(&b, binary.LittleEndian, root) + _ = binary.Write(&b, binary.LittleEndian, root) } else if extents <= 4*extentsPerBlock { const extentsPerBlock = blockSize/extentNodeSize - 1 extentBlocks := extents/extentsPerBlock + 1 @@ -817,12 +817,12 @@ func (w *Writer) writeExtents(inode *inode) error { offset := i * extentsPerBlock * maxBlocksPerExtent fillExtents(&node.hdr, node.extents[:extentsInBlock], startBlock+offset, offset, blocks) - binary.Write(&b2, binary.LittleEndian, node) + _ = binary.Write(&b2, binary.LittleEndian, node) if _, err := w.write(b2.Next(blockSize)); err != nil { return err } } - binary.Write(&b, binary.LittleEndian, root) + _ = binary.Write(&b, binary.LittleEndian, root) } else { panic("file too big") } @@ -1060,12 +1060,12 @@ func (w *Writer) writeInodeTable(tableSize uint32) error { binary.LittleEndian.PutUint32(binode.Block[4:], dev) } - binary.Write(&b, binary.LittleEndian, binode) + _ = binary.Write(&b, binary.LittleEndian, binode) b.Truncate(inodeUsedSize) n, _ := b.Write(inode.XattrInline) - io.CopyN(&b, zero, int64(inodeExtraSize-n)) + _, _ = io.CopyN(&b, zero, int64(inodeExtraSize-n)) } else { - io.CopyN(&b, zero, inodeSize) + _, _ = io.CopyN(&b, zero, inodeSize) } if _, err := w.write(b.Next(inodeSize)); err != nil { return err @@ -1315,7 +1315,7 @@ func (w *Writer) Close() error { if w.supportInlineData { sb.FeatureIncompat |= format.IncompatInlineData } - binary.Write(b, binary.LittleEndian, sb) + _ = binary.Write(b, binary.LittleEndian, sb) w.seekBlock(0) if _, err := w.write(blk[:]); err != nil { return err diff --git a/ext4/internal/compactext4/compact_test.go b/ext4/internal/compactext4/compact_test.go index b7b2a30b8e..cc3dd675de 100644 --- a/ext4/internal/compactext4/compact_test.go +++ b/ext4/internal/compactext4/compact_test.go @@ -51,7 +51,7 @@ func (d *largeData) Read(b []byte) (int, error) { binary.LittleEndian.PutUint64(pb[:], uint64(p+int64(i))) b[i] = pb[i%8] } - p += int64(len(b)) + d.pos += int64(len(b)) return len(b), nil } diff --git a/ext4/tar2ext4/vhdfooter.go b/ext4/tar2ext4/vhdfooter.go index c98740302f..99f6e3a304 100644 --- a/ext4/tar2ext4/vhdfooter.go +++ b/ext4/tar2ext4/vhdfooter.go @@ -56,7 +56,7 @@ func calculateCheckSum(footer *vhdFooter) uint32 { footer.Checksum = 0 buf := &bytes.Buffer{} - binary.Write(buf, binary.BigEndian, footer) + _ = binary.Write(buf, binary.BigEndian, footer) var chk uint32 bufBytes := buf.Bytes() diff --git a/hcn/hcn.go b/hcn/hcn.go index c75125e523..ed311fed9d 100644 --- a/hcn/hcn.go +++ b/hcn/hcn.go @@ -3,7 +3,6 @@ package hcn import ( - "encoding/json" "fmt" "syscall" @@ -64,12 +63,6 @@ import ( //sys hcnDeleteRoute(id *_guid, result **uint16) (hr error) = computenetwork.HcnDeleteSdnRoute? //sys hcnCloseRoute(route hcnRoute) (hr error) = computenetwork.HcnCloseSdnRoute? -// Service -//sys hcnOpenService(service *hcnService, result **uint16) (hr error) = computenetwork.HcnOpenService? -//sys hcnRegisterServiceCallback(service hcnService, callback int32, context int32, callbackHandle *hcnCallbackHandle) (hr error) = computenetwork.HcnRegisterServiceCallback? -//sys hcnUnregisterServiceCallback(callbackHandle hcnCallbackHandle) (hr error) = computenetwork.HcnUnregisterServiceCallback? -//sys hcnCloseService(service hcnService) (hr error) = computenetwork.HcnCloseService? - type _guid = guid.GUID type hcnNetwork syscall.Handle @@ -77,8 +70,6 @@ type hcnEndpoint syscall.Handle type hcnNamespace syscall.Handle type hcnLoadBalancer syscall.Handle type hcnRoute syscall.Handle -type hcnService syscall.Handle -type hcnCallbackHandle syscall.Handle // SchemaVersion for HCN Objects/Queries. type SchemaVersion = Version // hcnglobals.go @@ -128,15 +119,6 @@ func defaultQuery() HostComputeQuery { return query } -func defaultQueryJson() string { - query := defaultQuery() - queryJson, err := json.Marshal(query) - if err != nil { - return "" - } - return string(queryJson) -} - // PlatformDoesNotSupportError happens when users are attempting to use a newer shim on an older OS func platformDoesNotSupportError(featureName string) error { return fmt.Errorf("Platform does not support feature %s", featureName) diff --git a/hcn/hcnloadbalancer.go b/hcn/hcnloadbalancer.go index 9ed59a669a..e74c77654b 100644 --- a/hcn/hcnloadbalancer.go +++ b/hcn/hcnloadbalancer.go @@ -160,50 +160,6 @@ func createLoadBalancer(settings string) (*HostComputeLoadBalancer, error) { return &outputLoadBalancer, nil } -func modifyLoadBalancer(loadBalancerId string, settings string) (*HostComputeLoadBalancer, error) { - loadBalancerGuid, err := guid.FromString(loadBalancerId) - if err != nil { - return nil, errInvalidLoadBalancerID - } - // Open loadBalancer. - var ( - loadBalancerHandle hcnLoadBalancer - resultBuffer *uint16 - propertiesBuffer *uint16 - ) - hr := hcnOpenLoadBalancer(&loadBalancerGuid, &loadBalancerHandle, &resultBuffer) - if err := checkForErrors("hcnOpenLoadBalancer", hr, resultBuffer); err != nil { - return nil, err - } - // Modify loadBalancer. - hr = hcnModifyLoadBalancer(loadBalancerHandle, settings, &resultBuffer) - if err := checkForErrors("hcnModifyLoadBalancer", hr, resultBuffer); err != nil { - return nil, err - } - // Query loadBalancer. - hcnQuery := defaultQuery() - query, err := json.Marshal(hcnQuery) - if err != nil { - return nil, err - } - hr = hcnQueryLoadBalancerProperties(loadBalancerHandle, string(query), &propertiesBuffer, &resultBuffer) - if err := checkForErrors("hcnQueryLoadBalancerProperties", hr, resultBuffer); err != nil { - return nil, err - } - properties := interop.ConvertAndFreeCoTaskMemString(propertiesBuffer) - // Close loadBalancer. - hr = hcnCloseLoadBalancer(loadBalancerHandle) - if err := checkForErrors("hcnCloseLoadBalancer", hr, nil); err != nil { - return nil, err - } - // Convert output to LoadBalancer - var outputLoadBalancer HostComputeLoadBalancer - if err := json.Unmarshal([]byte(properties), &outputLoadBalancer); err != nil { - return nil, err - } - return &outputLoadBalancer, nil -} - func deleteLoadBalancer(loadBalancerId string) error { loadBalancerGuid, err := guid.FromString(loadBalancerId) if err != nil { diff --git a/hcn/hcnnamespace.go b/hcn/hcnnamespace.go index 22c7cf95f6..d2ef229609 100644 --- a/hcn/hcnnamespace.go +++ b/hcn/hcnnamespace.go @@ -378,7 +378,7 @@ func (namespace *HostComputeNamespace) Sync() error { // The shim is likey gone. Simply ignore the sync as if it didn't exist. if perr, ok := err.(*os.PathError); ok && perr.Err == syscall.ERROR_FILE_NOT_FOUND { // Remove the reg key there is no point to try again - cfg.Remove() + _ = cfg.Remove() return nil } f := map[string]interface{}{ diff --git a/hcn/zsyscall_windows.go b/hcn/zsyscall_windows.go index 466d304572..7ec5b58b66 100644 --- a/hcn/zsyscall_windows.go +++ b/hcn/zsyscall_windows.go @@ -78,10 +78,6 @@ var ( procHcnQuerySdnRouteProperties = modcomputenetwork.NewProc("HcnQuerySdnRouteProperties") procHcnDeleteSdnRoute = modcomputenetwork.NewProc("HcnDeleteSdnRoute") procHcnCloseSdnRoute = modcomputenetwork.NewProc("HcnCloseSdnRoute") - procHcnOpenService = modcomputenetwork.NewProc("HcnOpenService") - procHcnRegisterServiceCallback = modcomputenetwork.NewProc("HcnRegisterServiceCallback") - procHcnUnregisterServiceCallback = modcomputenetwork.NewProc("HcnUnregisterServiceCallback") - procHcnCloseService = modcomputenetwork.NewProc("HcnCloseService") ) func SetCurrentThreadCompartmentId(compartmentId uint32) (hr error) { @@ -797,59 +793,3 @@ func hcnCloseRoute(route hcnRoute) (hr error) { } return } - -func hcnOpenService(service *hcnService, result **uint16) (hr error) { - if hr = procHcnOpenService.Find(); hr != nil { - return - } - r0, _, _ := syscall.Syscall(procHcnOpenService.Addr(), 2, uintptr(unsafe.Pointer(service)), uintptr(unsafe.Pointer(result)), 0) - if int32(r0) < 0 { - if r0&0x1fff0000 == 0x00070000 { - r0 &= 0xffff - } - hr = syscall.Errno(r0) - } - return -} - -func hcnRegisterServiceCallback(service hcnService, callback int32, context int32, callbackHandle *hcnCallbackHandle) (hr error) { - if hr = procHcnRegisterServiceCallback.Find(); hr != nil { - return - } - r0, _, _ := syscall.Syscall6(procHcnRegisterServiceCallback.Addr(), 4, uintptr(service), uintptr(callback), uintptr(context), uintptr(unsafe.Pointer(callbackHandle)), 0, 0) - if int32(r0) < 0 { - if r0&0x1fff0000 == 0x00070000 { - r0 &= 0xffff - } - hr = syscall.Errno(r0) - } - return -} - -func hcnUnregisterServiceCallback(callbackHandle hcnCallbackHandle) (hr error) { - if hr = procHcnUnregisterServiceCallback.Find(); hr != nil { - return - } - r0, _, _ := syscall.Syscall(procHcnUnregisterServiceCallback.Addr(), 1, uintptr(callbackHandle), 0, 0) - if int32(r0) < 0 { - if r0&0x1fff0000 == 0x00070000 { - r0 &= 0xffff - } - hr = syscall.Errno(r0) - } - return -} - -func hcnCloseService(service hcnService) (hr error) { - if hr = procHcnCloseService.Find(); hr != nil { - return - } - r0, _, _ := syscall.Syscall(procHcnCloseService.Addr(), 1, uintptr(service), 0, 0) - if int32(r0) < 0 { - if r0&0x1fff0000 == 0x00070000 { - r0 &= 0xffff - } - hr = syscall.Errno(r0) - } - return -} diff --git a/hnsendpoint.go b/hnsendpoint.go index 09b3860a7b..408312672e 100644 --- a/hnsendpoint.go +++ b/hnsendpoint.go @@ -40,6 +40,9 @@ func HNSListEndpointRequest() ([]HNSEndpoint, error) { // HotAttachEndpoint makes a HCS Call to attach the endpoint to the container func HotAttachEndpoint(containerID string, endpointID string) error { endpoint, err := GetHNSEndpointByID(endpointID) + if err != nil { + return err + } isAttached, err := endpoint.IsAttached(containerID) if isAttached { return err @@ -50,6 +53,9 @@ func HotAttachEndpoint(containerID string, endpointID string) error { // HotDetachEndpoint makes a HCS Call to detach the endpoint from the container func HotDetachEndpoint(containerID string, endpointID string) error { endpoint, err := GetHNSEndpointByID(endpointID) + if err != nil { + return err + } isAttached, err := endpoint.IsAttached(containerID) if !isAttached { return err diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 478455429f..d0b3868892 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -215,7 +215,10 @@ func (c *Cmd) Start() error { c.stdinErr.Store(err) } // Notify the process that there is no more input. - p.CloseStdin(context.TODO()) + err = p.CloseStdin(context.TODO()) + if err != nil && c.Log != nil { + c.Log.WithError(err).Warn("failed to close pod stdin") + } }() } @@ -237,7 +240,7 @@ func (c *Cmd) Start() error { go func() { select { case <-c.Context.Done(): - c.Process.Kill(context.TODO()) + _, _ = c.Process.Kill(context.TODO()) case <-c.allDoneCh: } }() diff --git a/internal/cmd/cmd_test.go b/internal/cmd/cmd_test.go index 143aa99ce1..2dd40201ac 100644 --- a/internal/cmd/cmd_test.go +++ b/internal/cmd/cmd_test.go @@ -88,7 +88,7 @@ func (h *localProcessHost) CreateProcess(ctx context.Context, cfg interface{}) ( func (p *localProcess) Close() error { if p.p != nil { - p.p.Release() + _ = p.p.Release() } if p.stdin != nil { p.stdin.Close() @@ -169,7 +169,7 @@ func TestCmdContext(t *testing.T) { if err != nil { t.Fatal(err) } - cmd.Process.Wait() + _ = cmd.Process.Wait() w.Close() err = cmd.Wait() if e, ok := err.(*ExitError); !ok || e.ExitCode() != 1 || ctx.Err() == nil { @@ -195,7 +195,7 @@ func TestCmdStdinBlocked(t *testing.T) { defer r.Close() go func() { b := []byte{'\n'} - w.Write(b) + _, _ = w.Write(b) }() cmd.Stdin = r _, err := cmd.Output() diff --git a/internal/cmd/io_binary.go b/internal/cmd/io_binary.go index 1fde77e482..ac53d3c22f 100644 --- a/internal/cmd/io_binary.go +++ b/internal/cmd/io_binary.go @@ -155,7 +155,7 @@ type binaryIO struct { binaryCloser sync.Once - stdin, stdout, stderr string + stdout, stderr string sout, serr io.ReadWriteCloser soutCloser sync.Once diff --git a/internal/cni/registry_test.go b/internal/cni/registry_test.go index ea50202388..9533129734 100644 --- a/internal/cni/registry_test.go +++ b/internal/cni/registry_test.go @@ -32,10 +32,12 @@ func Test_LoadPersistedNamespaceConfig_NoConfig(t *testing.T) { func Test_LoadPersistedNamespaceConfig_WithConfig(t *testing.T) { pnc := NewPersistedNamespaceConfig(t.Name(), "test-container", newGUID(t)) if err := pnc.Store(); err != nil { - pnc.Remove() + _ = pnc.Remove() t.Fatalf("store failed with: %v", err) } - defer pnc.Remove() + defer func() { + _ = pnc.Remove() + }() pnc2, err := LoadPersistedNamespaceConfig(t.Name()) if err != nil { @@ -62,24 +64,28 @@ func Test_LoadPersistedNamespaceConfig_WithConfig(t *testing.T) { func Test_PersistedNamespaceConfig_StoreNew(t *testing.T) { pnc := NewPersistedNamespaceConfig(t.Name(), "test-container", newGUID(t)) if err := pnc.Store(); err != nil { - pnc.Remove() + _ = pnc.Remove() t.Fatalf("store failed with: %v", err) } - defer pnc.Remove() + defer func() { + _ = pnc.Remove() + }() } func Test_PersistedNamespaceConfig_StoreUpdate(t *testing.T) { pnc := NewPersistedNamespaceConfig(t.Name(), "test-container", newGUID(t)) if err := pnc.Store(); err != nil { - pnc.Remove() + _ = pnc.Remove() t.Fatalf("store failed with: %v", err) } - defer pnc.Remove() + defer func() { + _ = pnc.Remove() + }() pnc.ContainerID = "test-container2" pnc.HostUniqueID = newGUID(t) if err := pnc.Store(); err != nil { - pnc.Remove() + _ = pnc.Remove() t.Fatalf("store update failed with: %v", err) } diff --git a/internal/copyfile/copyfile.go b/internal/copyfile/copyfile.go index 3f7bd23885..fe7a2faa11 100644 --- a/internal/copyfile/copyfile.go +++ b/internal/copyfile/copyfile.go @@ -18,7 +18,7 @@ var ( // CopyFile is a utility for copying a file using CopyFileW win32 API for // performance. func CopyFile(ctx context.Context, srcFile, destFile string, overwrite bool) (err error) { - ctx, span := trace.StartSpan(ctx, "copyfile::CopyFile") + ctx, span := trace.StartSpan(ctx, "copyfile::CopyFile") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/internal/cpugroup/cpugroup.go b/internal/cpugroup/cpugroup.go index e2d7e2b361..41caf24106 100644 --- a/internal/cpugroup/cpugroup.go +++ b/internal/cpugroup/cpugroup.go @@ -54,6 +54,7 @@ func Create(ctx context.Context, id string, logicalProcessors []uint32) error { } // getCPUGroupConfig finds the cpugroup config information for group with `id` +//nolint:unused func getCPUGroupConfig(ctx context.Context, id string) (*hcsschema.CpuGroupConfig, error) { query := hcsschema.PropertyQuery{ PropertyTypes: []hcsschema.PropertyType{hcsschema.PTCPUGroup}, @@ -68,7 +69,7 @@ func getCPUGroupConfig(ctx context.Context, id string) (*hcsschema.CpuGroupConfi } for _, c := range groupConfigs.CpuGroups { - if strings.ToLower(c.GroupId) == strings.ToLower(id) { + if strings.EqualFold(c.GroupId, id) { return &c, nil } } diff --git a/internal/devices/assigned_devices.go b/internal/devices/assigned_devices.go index de1ca247d7..f712009571 100644 --- a/internal/devices/assigned_devices.go +++ b/internal/devices/assigned_devices.go @@ -145,10 +145,7 @@ func readCsPipeOutput(l net.Listener, errChan chan<- error, result *[]string) { elementsAsString := strings.TrimSuffix(string(bytes), "\n") elements := strings.Split(elementsAsString, ",") - - for _, elem := range elements { - *result = append(*result, elem) - } + *result = append(*result, elements...) if len(*result) == 0 { errChan <- errors.Wrapf(err, "failed to get any pipe output") diff --git a/internal/gcs/guestconnection.go b/internal/gcs/guestconnection.go index 43f99fd62e..765e6d69c4 100644 --- a/internal/gcs/guestconnection.go +++ b/internal/gcs/guestconnection.go @@ -70,7 +70,7 @@ func (gcc *GuestConnectionConfig) Connect(ctx context.Context, isColdStart bool) gc.brdg = newBridge(gcc.Conn, gc.notify, gcc.Log) gc.brdg.Start() go func() { - gc.brdg.Wait() + _ = gc.brdg.Wait() gc.clearNotifies() }() err = gc.connect(ctx, isColdStart) diff --git a/internal/gcs/guestconnection_test.go b/internal/gcs/guestconnection_test.go index a878bae2ff..1202ffa4e7 100644 --- a/internal/gcs/guestconnection_test.go +++ b/internal/gcs/guestconnection_test.go @@ -51,7 +51,7 @@ func simpleGcsLoop(t *testing.T, rw io.ReadWriter) error { } switch proc := rpcProc(typ &^ msgTypeRequest); proc { case rpcNegotiateProtocol: - err := sendJSON(t, rw, msgType(msgTypeResponse|proc), id, &negotiateProtocolResponse{ + err := sendJSON(t, rw, msgTypeResponse|msgType(proc), id, &negotiateProtocolResponse{ Version: protocolVersion, Capabilities: gcsCapabilities{ RuntimeOsType: "linux", @@ -61,7 +61,7 @@ func simpleGcsLoop(t *testing.T, rw io.ReadWriter) error { return err } case rpcCreate: - err := sendJSON(t, rw, msgType(msgTypeResponse|proc), id, &containerCreateResponse{}) + err := sendJSON(t, rw, msgTypeResponse|msgType(proc), id, &containerCreateResponse{}) if err != nil { return err } @@ -105,7 +105,7 @@ func simpleGcsLoop(t *testing.T, rw io.ReadWriter) error { stdout.Close() }() } - err = sendJSON(t, rw, msgType(msgTypeResponse|proc), id, &containerExecuteProcessResponse{ + err = sendJSON(t, rw, msgTypeResponse|msgType(proc), id, &containerExecuteProcessResponse{ ProcessID: 42, }) if err != nil { @@ -119,7 +119,7 @@ func simpleGcsLoop(t *testing.T, rw io.ReadWriter) error { if err != nil { return err } - err = sendJSON(t, rw, msgType(msgTypeResponse|proc), id, &responseBase{}) + err = sendJSON(t, rw, msgTypeResponse|msgType(proc), id, &responseBase{}) if err != nil { return err } diff --git a/internal/gcs/process.go b/internal/gcs/process.go index e82471ce3a..f496522c87 100644 --- a/internal/gcs/process.go +++ b/internal/gcs/process.go @@ -145,7 +145,7 @@ func (p *Process) Close() error { // CloseStdin causes the process to read EOF on its stdin stream. func (p *Process) CloseStdin(ctx context.Context) (err error) { - ctx, span := trace.StartSpan(ctx, "gcs::Process::CloseStdin") + ctx, span := trace.StartSpan(ctx, "gcs::Process::CloseStdin") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/internal/gcs/protocol.go b/internal/gcs/protocol.go index 23acd3cabd..f1a8346195 100644 --- a/internal/gcs/protocol.go +++ b/internal/gcs/protocol.go @@ -66,9 +66,9 @@ type msgType uint32 const ( msgTypeRequest msgType = 0x10100000 - msgTypeResponse = 0x20100000 - msgTypeNotify = 0x30100000 - msgTypeMask = 0xfff00000 + msgTypeResponse msgType = 0x20100000 + msgTypeNotify msgType = 0x30100000 + msgTypeMask msgType = 0xfff00000 notifyContainer = 1<<8 | 1 ) diff --git a/internal/gcs/resourcepaths.go b/internal/gcs/resourcepaths.go index 8540af96c7..20b57b710a 100644 --- a/internal/gcs/resourcepaths.go +++ b/internal/gcs/resourcepaths.go @@ -2,9 +2,9 @@ package gcs const ( // silo container resources paths - siloDeviceResourcePath string = "Container/Devices/Generic" - siloMappedDirectoryResourcePath string = "Container/MappedDirectories" - siloMappedPipeResourcePath string = "Container/MappedPipes" - siloMemoryResourcePath string = "Container/Memory/SizeInMB" - siloRegistryFlushStatePath string = "Container/RegistryFlushState" + siloDeviceResourcePath string = "Container/Devices/Generic" //nolint + siloMappedDirectoryResourcePath string = "Container/MappedDirectories" //nolint + siloMappedPipeResourcePath string = "Container/MappedPipes" //nolint + siloMemoryResourcePath string = "Container/Memory/SizeInMB" //nolint + siloRegistryFlushStatePath string = "Container/RegistryFlushState" //nolint ) diff --git a/internal/hcs/errors.go b/internal/hcs/errors.go index bca824b8e1..ce6616ac0b 100644 --- a/internal/hcs/errors.go +++ b/internal/hcs/errors.go @@ -332,12 +332,3 @@ func getInnerError(err error) error { } return err } - -func getOperationLogResult(err error) (string, error) { - switch err { - case nil: - return "Success", nil - default: - return "Error", err - } -} diff --git a/internal/hcs/process.go b/internal/hcs/process.go index 2ad978f290..b74389eca2 100644 --- a/internal/hcs/process.go +++ b/internal/hcs/process.go @@ -64,11 +64,7 @@ type processStatus struct { LastWaitResult int32 } -const ( - stdIn string = "StdIn" - stdOut string = "StdOut" - stdErr string = "StdErr" -) +const stdIn string = "StdIn" const ( modifyConsoleSize string = "ConsoleSize" @@ -176,8 +172,10 @@ func (process *Process) waitBackground() { trace.Int64Attribute("pid", int64(process.processID))) var ( - err error - exitCode = -1 + err error + exitCode = -1 + propertiesJSON string + resultJSON string ) err = waitForNotification(ctx, process.callbackNumber, hcsNotificationProcessExited, nil) @@ -190,15 +188,15 @@ func (process *Process) waitBackground() { // Make sure we didnt race with Close() here if process.handle != 0 { - propertiesJSON, resultJSON, err := vmcompute.HcsGetProcessProperties(ctx, process.handle) + propertiesJSON, resultJSON, err = vmcompute.HcsGetProcessProperties(ctx, process.handle) events := processHcsResult(ctx, resultJSON) if err != nil { - err = makeProcessError(process, operation, err, events) + err = makeProcessError(process, operation, err, events) //nolint:ineffassign } else { properties := &processStatus{} err = json.Unmarshal([]byte(propertiesJSON), properties) if err != nil { - err = makeProcessError(process, operation, err, nil) + err = makeProcessError(process, operation, err, nil) //nolint:ineffassign } else { if properties.LastWaitResult != 0 { log.G(ctx).WithField("wait-result", properties.LastWaitResult).Warning("non-zero last wait result") @@ -468,7 +466,7 @@ func (process *Process) unregisterCallback(ctx context.Context) error { delete(callbackMap, callbackNumber) callbackMapLock.Unlock() - handle = 0 + handle = 0 //nolint:ineffassign return nil } diff --git a/internal/hcs/system.go b/internal/hcs/system.go index bda393a6d1..1caf3d2e9b 100644 --- a/internal/hcs/system.go +++ b/internal/hcs/system.go @@ -73,7 +73,7 @@ func CreateComputeSystem(ctx context.Context, id string, hcsDocumentInterface in if err = computeSystem.registerCallback(ctx); err != nil { // Terminate the compute system if it still exists. We're okay to // ignore a failure here. - computeSystem.Terminate(ctx) + _ = computeSystem.Terminate(ctx) return nil, makeSystemError(computeSystem, operation, "", err, nil) } } @@ -83,7 +83,7 @@ func CreateComputeSystem(ctx context.Context, id string, hcsDocumentInterface in if err == ErrTimeout { // Terminate the compute system if it still exists. We're okay to // ignore a failure here. - computeSystem.Terminate(ctx) + _ = computeSystem.Terminate(ctx) } return nil, makeSystemError(computeSystem, operation, hcsDocument, err, events) } @@ -605,7 +605,7 @@ func (computeSystem *System) unregisterCallback(ctx context.Context) error { delete(callbackMap, callbackNumber) callbackMapLock.Unlock() - handle = 0 + handle = 0 //nolint:ineffassign return nil } diff --git a/internal/hcs/waithelper.go b/internal/hcs/waithelper.go index f07f532c13..db4e14fdfb 100644 --- a/internal/hcs/waithelper.go +++ b/internal/hcs/waithelper.go @@ -65,5 +65,4 @@ func waitForNotification(ctx context.Context, callbackNumber uintptr, expectedNo case <-c: return ErrTimeout } - return nil } diff --git a/internal/hcsoci/create.go b/internal/hcsoci/create.go index 19689e9e01..546e3516c2 100644 --- a/internal/hcsoci/create.go +++ b/internal/hcsoci/create.go @@ -83,11 +83,6 @@ func cmpSlices(s1, s2 []string) bool { return equal } -// Compares to mount structs and returns true if they are equal, returns false otherwise. -func compareMounts(m1, m2 specs.Mount) bool { - return cmpSlices(m1.Options, m2.Options) && (m1.Source == m2.Source) && (m1.Destination == m2.Destination) && (m1.Type == m2.Type) -} - // verifyCloneContainerSpecs compares the container creation spec provided during the template container // creation and the spec provided during cloned container creation and checks that all the fields match // (except for the certain fields that are allowed to be different). @@ -276,7 +271,7 @@ func CreateContainer(ctx context.Context, createOptions *CreateOptions) (_ cow.C defer func() { if err != nil { if !coi.DoNotReleaseResourcesOnFailure { - resources.ReleaseResources(ctx, r, coi.HostingSystem, true) + _ = resources.ReleaseResources(ctx, r, coi.HostingSystem, true) } } }() @@ -393,7 +388,7 @@ func CloneContainer(ctx context.Context, createOptions *CreateOptions) (_ cow.Co defer func() { if err != nil { if !coi.DoNotReleaseResourcesOnFailure { - resources.ReleaseResources(ctx, r, coi.HostingSystem, true) + _ = resources.ReleaseResources(ctx, r, coi.HostingSystem, true) } } }() diff --git a/internal/hcsoci/resources_lcow.go b/internal/hcsoci/resources_lcow.go index b6b7b40e32..66752d18a1 100644 --- a/internal/hcsoci/resources_lcow.go +++ b/internal/hcsoci/resources_lcow.go @@ -99,7 +99,6 @@ func allocateLinuxResources(ctx context.Context, coi *createOptionsInternal, r * } uvmPathForFile = scsiMount.UVMPath - uvmPathForShare = scsiMount.UVMPath r.Add(scsiMount) coi.Spec.Mounts[i].Type = "none" } else if mount.Type == "virtual-disk" { @@ -114,7 +113,6 @@ func allocateLinuxResources(ctx context.Context, coi *createOptionsInternal, r * } uvmPathForFile = scsiMount.UVMPath - uvmPathForShare = scsiMount.UVMPath r.Add(scsiMount) coi.Spec.Mounts[i].Type = "none" } else if strings.HasPrefix(mount.Source, "sandbox://") { diff --git a/internal/hns/hnsnetwork.go b/internal/hns/hnsnetwork.go index b7ae96fddd..f12d3ab041 100644 --- a/internal/hns/hnsnetwork.go +++ b/internal/hns/hnsnetwork.go @@ -39,12 +39,6 @@ type HNSNetwork struct { AutomaticDNS bool `json:",omitempty"` } -type hnsNetworkResponse struct { - Success bool - Error string - Output HNSNetwork -} - type hnsResponse struct { Success bool Error string diff --git a/internal/jobcontainers/env.go b/internal/jobcontainers/env.go index ed1017fbf2..b64a365471 100644 --- a/internal/jobcontainers/env.go +++ b/internal/jobcontainers/env.go @@ -23,7 +23,9 @@ func defaultEnvBlock(token windows.Token) (env []string, err error) { if err := windows.CreateEnvironmentBlock(&block, token, false); err != nil { return nil, err } - defer windows.DestroyEnvironmentBlock(block) + defer func() { + _ = windows.DestroyEnvironmentBlock(block) + }() blockp := uintptr(unsafe.Pointer(block)) for { diff --git a/internal/jobcontainers/jobcontainer.go b/internal/jobcontainers/jobcontainer.go index c4f589357b..9c7146eccd 100644 --- a/internal/jobcontainers/jobcontainer.go +++ b/internal/jobcontainers/jobcontainer.go @@ -138,7 +138,7 @@ func Create(ctx context.Context, id string, s *specs.Spec) (_ cow.Container, err if err != nil { container.Close() if path != "" { - removeSandboxMountPoint(ctx, path) + _ = removeSandboxMountPoint(ctx, path) } } }() @@ -404,7 +404,7 @@ func (c *JobContainer) waitBackground(ctx context.Context) { ctx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() if err := c.Shutdown(ctx); err != nil { - c.Terminate(ctx) + _ = c.Terminate(ctx) } c.closedWaitOnce.Do(func() { diff --git a/internal/jobobject/jobobject_test.go b/internal/jobobject/jobobject_test.go index d251dab9a8..b9cb8dbd76 100644 --- a/internal/jobobject/jobobject_test.go +++ b/internal/jobobject/jobobject_test.go @@ -43,7 +43,7 @@ func createProcsAndAssign(num int, job *JobObject) (_ []*exec.Cmd, err error) { defer func() { if err != nil { for _, proc := range procs { - proc.Process.Kill() + _ = proc.Process.Kill() } } }() @@ -108,7 +108,7 @@ func TestSetTerminateOnLastHandleClose(t *testing.T) { t.Fatal(err) } case <-time.After(time.Second * 10): - procs[0].Process.Kill() + _ = procs[0].Process.Kill() t.Fatal("process didn't complete wait within timeout") } } diff --git a/internal/jobobject/limits.go b/internal/jobobject/limits.go index 4657f9322d..1690f603fd 100644 --- a/internal/jobobject/limits.go +++ b/internal/jobobject/limits.go @@ -10,8 +10,7 @@ import ( ) const ( - processorWeightMax float64 = 10000 - memoryLimitMax uint64 = 0xffffffffffffffff + memoryLimitMax uint64 = 0xffffffffffffffff ) func isFlagSet(flag, controlFlags uint32) bool { diff --git a/internal/layers/layers.go b/internal/layers/layers.go index 3fffd827be..f3f4e77edd 100644 --- a/internal/layers/layers.go +++ b/internal/layers/layers.go @@ -83,7 +83,7 @@ func MountContainerLayers(ctx context.Context, layerFolders []string, guestRoot } defer func() { if err != nil { - wclayer.DeactivateLayer(ctx, path) + _ = wclayer.DeactivateLayer(ctx, path) } }() @@ -92,7 +92,7 @@ func MountContainerLayers(ctx context.Context, layerFolders []string, guestRoot } defer func() { if err != nil { - wclayer.UnprepareLayer(ctx, path) + _ = wclayer.UnprepareLayer(ctx, path) } }() @@ -188,7 +188,8 @@ func MountContainerLayers(ctx context.Context, layerFolders []string, guestRoot if uvm.OS() == "windows" { // Load the filter at the C:\s location calculated above. We pass into this request each of the // read-only layer folders. - layers, err := GetHCSLayers(ctx, uvm, layersAdded) + var layers []hcsschema.Layer + layers, err = GetHCSLayers(ctx, uvm, layersAdded) if err != nil { return "", err } diff --git a/internal/lcow/disk.go b/internal/lcow/disk.go index ac68dcfcf0..a208cb7231 100644 --- a/internal/lcow/disk.go +++ b/internal/lcow/disk.go @@ -34,7 +34,7 @@ func FormatDisk(ctx context.Context, lcowUVM *uvm.UtilityVM, destPath string) er } defer func() { - scsi.Release(ctx) + _ = scsi.Release(ctx) }() log.G(ctx).WithFields(logrus.Fields{ diff --git a/internal/lcow/scratch.go b/internal/lcow/scratch.go index 212d8ac3e9..8d1e337b52 100644 --- a/internal/lcow/scratch.go +++ b/internal/lcow/scratch.go @@ -73,7 +73,7 @@ func CreateScratch(ctx context.Context, lcowUVM *uvm.UtilityVM, destFile string, removeSCSI := true defer func() { if removeSCSI { - lcowUVM.RemoveSCSI(ctx, destFile) + _ = lcowUVM.RemoveSCSI(ctx, destFile) } }() diff --git a/internal/queue/queue_test.go b/internal/queue/queue_test.go index 6bf181beca..0ebb35846f 100644 --- a/internal/queue/queue_test.go +++ b/internal/queue/queue_test.go @@ -40,9 +40,9 @@ func TestReadOrWaitClose(t *testing.T) { q := NewMessageQueue() go func() { - q.Write(1) - q.Write(2) - q.Write(3) + _ = q.Write(1) + _ = q.Write(2) + _ = q.Write(3) time.Sleep(time.Second * 5) q.Close() }() @@ -65,11 +65,11 @@ func TestReadOrWait(t *testing.T) { q := NewMessageQueue() go func() { - q.Write(1) - q.Write(2) - q.Write(3) + _ = q.Write(1) + _ = q.Write(2) + _ = q.Write(3) time.Sleep(time.Second * 5) - q.Write(4) + _ = q.Write(4) }() // Small sleep so that we can give time to ensure a value is written to the queue so we diff --git a/internal/regstate/regstate.go b/internal/regstate/regstate.go index 6c4a641561..6086c1dc52 100644 --- a/internal/regstate/regstate.go +++ b/internal/regstate/regstate.go @@ -9,6 +9,7 @@ import ( "reflect" "syscall" + "golang.org/x/sys/windows" "golang.org/x/sys/windows/registry" ) @@ -19,7 +20,6 @@ import ( const ( _REG_OPTION_VOLATILE = 1 - _REG_CREATED_NEW_KEY = 1 _REG_OPENED_EXISTING_KEY = 2 ) @@ -61,7 +61,8 @@ func createVolatileKey(k *Key, path string, access uint32) (newk *Key, openedExi d uint32 ) fullpath := filepath.Join(k.Name, path) - err = regCreateKeyEx(syscall.Handle(k.Key), syscall.StringToUTF16Ptr(path), 0, nil, _REG_OPTION_VOLATILE, access, nil, &h, &d) + pathPtr, _ := windows.UTF16PtrFromString(path) + err = regCreateKeyEx(syscall.Handle(k.Key), pathPtr, 0, nil, _REG_OPTION_VOLATILE, access, nil, &h, &d) if err != nil { return nil, false, &os.PathError{Op: "RegCreateKeyEx", Path: fullpath, Err: err} } diff --git a/internal/runhcs/container.go b/internal/runhcs/container.go index 2f39e5845a..a161c204e2 100644 --- a/internal/runhcs/container.go +++ b/internal/runhcs/container.go @@ -51,7 +51,7 @@ func GetErrorFromPipe(pipe io.Reader, p *os.Process) error { extra := "" if p != nil { - p.Kill() + _ = p.Kill() state, err := p.Wait() if err != nil { panic(err) diff --git a/internal/safefile/safeopen.go b/internal/safefile/safeopen.go index 05f22f39dd..66b8d7e035 100644 --- a/internal/safefile/safeopen.go +++ b/internal/safefile/safeopen.go @@ -244,7 +244,7 @@ func RemoveRelative(path string, root *os.File) error { err = deleteOnClose(f) if err == syscall.ERROR_ACCESS_DENIED { // Maybe the file is marked readonly. Clear the bit and retry. - clearReadOnly(f) + _ = clearReadOnly(f) err = deleteOnClose(f) } } diff --git a/internal/schema1/schema1.go b/internal/schema1/schema1.go index cd1ec84abb..b468ad6365 100644 --- a/internal/schema1/schema1.go +++ b/internal/schema1/schema1.go @@ -119,9 +119,9 @@ type PropertyType string const ( PropertyTypeStatistics PropertyType = "Statistics" // V1 and V2 - PropertyTypeProcessList = "ProcessList" // V1 and V2 - PropertyTypeMappedVirtualDisk = "MappedVirtualDisk" // Not supported in V2 schema call - PropertyTypeGuestConnection = "GuestConnection" // V1 and V2. Nil return from HCS before RS5 + PropertyTypeProcessList PropertyType = "ProcessList" // V1 and V2 + PropertyTypeMappedVirtualDisk PropertyType = "MappedVirtualDisk" // Not supported in V2 schema call + PropertyTypeGuestConnection PropertyType = "GuestConnection" // V1 and V2. Nil return from HCS before RS5 ) type PropertyQuery struct { diff --git a/internal/schema2/device.go b/internal/schema2/device.go index 0b9c0fbf7d..107caddada 100644 --- a/internal/schema2/device.go +++ b/internal/schema2/device.go @@ -13,8 +13,8 @@ type DeviceType string const ( ClassGUID DeviceType = "ClassGuid" - DeviceInstance = "DeviceInstance" - GPUMirror = "GpuMirror" + DeviceInstance DeviceType = "DeviceInstance" + GPUMirror DeviceType = "GpuMirror" ) type Device struct { diff --git a/internal/schema2/logical_processor.go b/internal/schema2/logical_processor.go index 676ad300dc..2e3aa5e175 100644 --- a/internal/schema2/logical_processor.go +++ b/internal/schema2/logical_processor.go @@ -11,8 +11,8 @@ package hcsschema type LogicalProcessor struct { LpIndex uint32 `json:"LpIndex,omitempty"` - NodeNumber uint8 `json:"NodeNumber, omitempty"` - PackageId uint32 `json:"PackageId, omitempty"` - CoreId uint32 `json:"CoreId, omitempty"` - RootVpIndex int32 `json:"RootVpIndex, omitempty"` + NodeNumber uint8 `json:"NodeNumber,omitempty"` + PackageId uint32 `json:"PackageId,omitempty"` + CoreId uint32 `json:"CoreId,omitempty"` + RootVpIndex int32 `json:"RootVpIndex,omitempty"` } diff --git a/internal/tools/uvmboot/lcow.go b/internal/tools/uvmboot/lcow.go index 4beb59f8df..99446b40d9 100644 --- a/internal/tools/uvmboot/lcow.go +++ b/internal/tools/uvmboot/lcow.go @@ -124,7 +124,9 @@ var lcowCommand = cli.Command{ if c.IsSet(outputHandlingArgName) { switch strings.ToLower(c.String(outputHandlingArgName)) { case "stdout": - options.OutputHandler = uvm.OutputHandler(func(r io.Reader) { io.Copy(os.Stdout, r) }) + options.OutputHandler = uvm.OutputHandler(func(r io.Reader) { + _, _ = io.Copy(os.Stdout, r) + }) default: logrus.Fatalf("Unrecognized value '%s' for option %s", c.String(outputHandlingArgName), outputHandlingArgName) } @@ -159,8 +161,8 @@ func runLCOW(ctx context.Context, options *uvm.OptionsLCOW, c *cli.Context) erro if err := execViaGcs(uvm, c); err != nil { return err } - uvm.Terminate(ctx) - uvm.Wait() + _ = uvm.Terminate(ctx) + _ = uvm.Wait() return uvm.ExitError() } @@ -180,7 +182,9 @@ func execViaGcs(vm *uvm.UtilityVM, c *cli.Context) error { if err != nil { return err } - defer con.Reset() + defer func() { + _ = con.Reset() + }() } } else if c.String(outputHandlingArgName) == "stdout" { if c.Bool(forwardStdoutArgName) { diff --git a/internal/tools/uvmboot/wcow.go b/internal/tools/uvmboot/wcow.go index 3347e3f8dd..808be645c0 100644 --- a/internal/tools/uvmboot/wcow.go +++ b/internal/tools/uvmboot/wcow.go @@ -98,7 +98,9 @@ var wcowCommand = cli.Command{ if err != nil { return err } - defer con.Reset() + defer func() { + _ = con.Reset() + }() } } else { cmd.Stdout = os.Stdout @@ -109,8 +111,8 @@ var wcowCommand = cli.Command{ return err } } - vm.Terminate(context.TODO()) - vm.Wait() + _ = vm.Terminate(context.TODO()) + _ = vm.Wait() return vm.ExitError() }) return nil diff --git a/internal/uvm/create.go b/internal/uvm/create.go index cb18835309..d688ef5733 100644 --- a/internal/uvm/create.go +++ b/internal/uvm/create.go @@ -217,8 +217,8 @@ func (uvm *UtilityVM) create(ctx context.Context, doc interface{}) error { } defer func() { if system != nil { - system.Terminate(ctx) - system.Wait() + _ = system.Terminate(ctx) + _ = system.Wait() } }() @@ -251,8 +251,8 @@ func (uvm *UtilityVM) Close() (err error) { if err := uvm.ReleaseCPUGroup(ctx); err != nil { log.G(ctx).WithError(err).Warn("failed to release VM resource") } - uvm.hcsSystem.Terminate(ctx) - uvm.Wait() + _ = uvm.hcsSystem.Terminate(ctx) + _ = uvm.Wait() } if err := uvm.CloseGCSConnection(); err != nil { diff --git a/internal/uvm/resourcepaths.go b/internal/uvm/resourcepaths.go index 395e5ea412..81f90d4122 100644 --- a/internal/uvm/resourcepaths.go +++ b/internal/uvm/resourcepaths.go @@ -1,5 +1,6 @@ package uvm +//nolint:deadcode,varcheck const ( gpuResourcePath string = "VirtualMachine/ComputeTopology/Gpu" memoryResourcePath string = "VirtualMachine/ComputeTopology/Memory/SizeInMB" diff --git a/internal/uvm/share.go b/internal/uvm/share.go index 55a4e4c292..ad0adfddaa 100644 --- a/internal/uvm/share.go +++ b/internal/uvm/share.go @@ -22,7 +22,7 @@ func (uvm *UtilityVM) Share(ctx context.Context, reqHostPath, reqUVMPath string, } defer func() { if err != nil { - vsmbShare.Release(ctx) + _ = vsmbShare.Release(ctx) } }() @@ -64,7 +64,7 @@ func (uvm *UtilityVM) Share(ctx context.Context, reqHostPath, reqUVMPath string, } defer func() { if err != nil { - plan9Share.Release(ctx) + _ = plan9Share.Release(ctx) } }() } diff --git a/internal/uvm/start.go b/internal/uvm/start.go index 7d8a8459e8..81c8a479d8 100644 --- a/internal/uvm/start.go +++ b/internal/uvm/start.go @@ -153,7 +153,9 @@ func (uvm *UtilityVM) configureHvSocketForGCS(ctx context.Context) (err error) { func (uvm *UtilityVM) Start(ctx context.Context) (err error) { ctx, cancel := context.WithTimeout(ctx, 2*time.Minute) g, gctx := errgroup.WithContext(ctx) - defer g.Wait() + defer func() { + _ = g.Wait() + }() defer cancel() // Prepare to provide entropy to the init process in the background. This @@ -198,8 +200,8 @@ func (uvm *UtilityVM) Start(ctx context.Context) (err error) { } defer func() { if err != nil { - uvm.hcsSystem.Terminate(ctx) - uvm.hcsSystem.Wait() + _ = uvm.hcsSystem.Terminate(ctx) + _ = uvm.hcsSystem.Wait() } }() diff --git a/internal/uvm/vsmb.go b/internal/uvm/vsmb.go index e15fb42554..85692d8824 100644 --- a/internal/uvm/vsmb.go +++ b/internal/uvm/vsmb.go @@ -79,7 +79,6 @@ func (uvm *UtilityVM) SetSaveableVSMBOptions(opts *hcsschema.VirtualSmbShareOpti opts.NoLocks = true opts.PseudoDirnotify = true opts.NoDirectmap = true - return } // findVSMBShare finds a share by `hostPath`. If not found returns `ErrNotAttached`. @@ -142,7 +141,9 @@ func forceNoDirectMap(path string) (bool, error) { if err != nil { return false, err } - defer windows.CloseHandle(h) + defer func() { + _ = windows.CloseHandle(h) + }() var info winapi.FILE_ID_INFO // We check for any error, rather than just ERROR_INVALID_PARAMETER. It seems better to also // fall back if e.g. some other backing filesystem is used which returns a different error. diff --git a/internal/vmcompute/vmcompute.go b/internal/vmcompute/vmcompute.go index 32491f2c31..e7f114b67a 100644 --- a/internal/vmcompute/vmcompute.go +++ b/internal/vmcompute/vmcompute.go @@ -62,7 +62,7 @@ type HcsCallback syscall.Handle type HcsProcessInformation struct { // ProcessId is the pid of the created process. ProcessId uint32 - reserved uint32 + reserved uint32 //nolint:structcheck // StdInput is the handle associated with the stdin of the process. StdInput syscall.Handle // StdOutput is the handle associated with the stdout of the process. diff --git a/internal/wclayer/activatelayer.go b/internal/wclayer/activatelayer.go index 81e454956a..ff81ac2c15 100644 --- a/internal/wclayer/activatelayer.go +++ b/internal/wclayer/activatelayer.go @@ -14,7 +14,7 @@ import ( // An activated layer must later be deactivated via DeactivateLayer. func ActivateLayer(ctx context.Context, path string) (err error) { title := "hcsshim::ActivateLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) diff --git a/internal/wclayer/createlayer.go b/internal/wclayer/createlayer.go index 41e5e6731e..ffee31ab12 100644 --- a/internal/wclayer/createlayer.go +++ b/internal/wclayer/createlayer.go @@ -12,7 +12,7 @@ import ( // the parent layer provided. func CreateLayer(ctx context.Context, path, parent string) (err error) { title := "hcsshim::CreateLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/internal/wclayer/deactivatelayer.go b/internal/wclayer/deactivatelayer.go index 70a711cf5d..d5bf2f5bdc 100644 --- a/internal/wclayer/deactivatelayer.go +++ b/internal/wclayer/deactivatelayer.go @@ -11,7 +11,7 @@ import ( // DeactivateLayer will dismount a layer that was mounted via ActivateLayer. func DeactivateLayer(ctx context.Context, path string) (err error) { title := "hcsshim::DeactivateLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) diff --git a/internal/wclayer/destroylayer.go b/internal/wclayer/destroylayer.go index bf197e3b0a..787054e794 100644 --- a/internal/wclayer/destroylayer.go +++ b/internal/wclayer/destroylayer.go @@ -12,7 +12,7 @@ import ( // path, including that layer's containing folder, if any. func DestroyLayer(ctx context.Context, path string) (err error) { title := "hcsshim::DestroyLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) diff --git a/internal/wclayer/getlayermountpath.go b/internal/wclayer/getlayermountpath.go index 942e3bbf9d..4d22d0ecf3 100644 --- a/internal/wclayer/getlayermountpath.go +++ b/internal/wclayer/getlayermountpath.go @@ -21,8 +21,7 @@ func GetLayerMountPath(ctx context.Context, path string) (_ string, err error) { defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) - var mountPathLength uintptr - mountPathLength = 0 + var mountPathLength uintptr = 0 // Call the procedure itself. log.G(ctx).Debug("Calling proc (1)") diff --git a/internal/wclayer/getsharedbaseimages.go b/internal/wclayer/getsharedbaseimages.go index a50378f492..bcc8fbd423 100644 --- a/internal/wclayer/getsharedbaseimages.go +++ b/internal/wclayer/getsharedbaseimages.go @@ -14,7 +14,7 @@ import ( // of registering them with the graphdriver, graph, and tagstore. func GetSharedBaseImages(ctx context.Context) (_ string, err error) { title := "hcsshim::GetSharedBaseImages" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() diff --git a/internal/wclayer/grantvmaccess.go b/internal/wclayer/grantvmaccess.go index aa7c8ae1fd..3eaca27808 100644 --- a/internal/wclayer/grantvmaccess.go +++ b/internal/wclayer/grantvmaccess.go @@ -11,7 +11,7 @@ import ( // GrantVmAccess adds access to a file for a given VM func GrantVmAccess(ctx context.Context, vmid string, filepath string) (err error) { title := "hcsshim::GrantVmAccess" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/internal/wclayer/layerexists.go b/internal/wclayer/layerexists.go index 6dd6f2d575..c6999973cb 100644 --- a/internal/wclayer/layerexists.go +++ b/internal/wclayer/layerexists.go @@ -12,7 +12,7 @@ import ( // to the system. func LayerExists(ctx context.Context, path string) (_ bool, err error) { title := "hcsshim::LayerExists" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) diff --git a/internal/wclayer/legacy.go b/internal/wclayer/legacy.go index dc3caf7510..83ba72cfad 100644 --- a/internal/wclayer/legacy.go +++ b/internal/wclayer/legacy.go @@ -390,7 +390,7 @@ func (w *legacyLayerWriter) CloseRoots() { w.destRoot = nil } for i := range w.parentRoots { - w.parentRoots[i].Close() + _ = w.parentRoots[i].Close() } w.parentRoots = nil } @@ -640,7 +640,7 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro defer func() { if f != nil { f.Close() - safefile.RemoveRelative(name, w.destRoot) + _ = safefile.RemoveRelative(name, w.destRoot) } }() @@ -676,7 +676,7 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro defer func() { if f != nil { f.Close() - safefile.RemoveRelative(fname, w.root) + _ = safefile.RemoveRelative(fname, w.root) } }() diff --git a/internal/wclayer/nametoguid.go b/internal/wclayer/nametoguid.go index b732857b32..bcf39c6b86 100644 --- a/internal/wclayer/nametoguid.go +++ b/internal/wclayer/nametoguid.go @@ -14,7 +14,7 @@ import ( // across all clients. func NameToGuid(ctx context.Context, name string) (_ guid.GUID, err error) { title := "hcsshim::NameToGuid" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("name", name)) diff --git a/internal/wclayer/processimage.go b/internal/wclayer/processimage.go index aabb313684..30bcdff5f5 100644 --- a/internal/wclayer/processimage.go +++ b/internal/wclayer/processimage.go @@ -12,7 +12,7 @@ import ( // The files should have been extracted to \Files. func ProcessBaseLayer(ctx context.Context, path string) (err error) { title := "hcsshim::ProcessBaseLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) @@ -28,7 +28,7 @@ func ProcessBaseLayer(ctx context.Context, path string) (err error) { // The files should have been extracted to \Files. func ProcessUtilityVMImage(ctx context.Context, path string) (err error) { title := "hcsshim::ProcessUtilityVMImage" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) diff --git a/internal/wclayer/unpreparelayer.go b/internal/wclayer/unpreparelayer.go index 84f81848ff..79fb986786 100644 --- a/internal/wclayer/unpreparelayer.go +++ b/internal/wclayer/unpreparelayer.go @@ -12,7 +12,7 @@ import ( // the given id. func UnprepareLayer(ctx context.Context, path string) (err error) { title := "hcsshim::UnprepareLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) diff --git a/osversion/osversion_windows.go b/osversion/osversion_windows.go index 477fe70783..42e58403de 100644 --- a/osversion/osversion_windows.go +++ b/osversion/osversion_windows.go @@ -15,21 +15,6 @@ type OSVersion struct { Build uint16 } -// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833(v=vs.85).aspx -type osVersionInfoEx struct { - OSVersionInfoSize uint32 - MajorVersion uint32 - MinorVersion uint32 - BuildNumber uint32 - PlatformID uint32 - CSDVersion [128]uint16 - ServicePackMajor uint16 - ServicePackMinor uint16 - SuiteMask uint16 - ProductType byte - Reserve byte -} - // Get gets the operating system version on Windows. // The calling application must be manifested to get the correct version information. func Get() OSVersion { diff --git a/pkg/go-runhcs/runhcs_create.go b/pkg/go-runhcs/runhcs_create.go index b10001e4b2..20d5d402ec 100644 --- a/pkg/go-runhcs/runhcs_create.go +++ b/pkg/go-runhcs/runhcs_create.go @@ -97,5 +97,5 @@ func (r *Runhcs) Create(context context.Context, id, bundle string, opts *Create if err == nil && status != 0 { err = fmt.Errorf("%s did not terminate sucessfully", cmd.Args[0]) } - return nil + return err } diff --git a/pkg/ociwclayer/export.go b/pkg/ociwclayer/export.go index d4d800384b..e3f1be333d 100644 --- a/pkg/ociwclayer/export.go +++ b/pkg/ociwclayer/export.go @@ -25,7 +25,9 @@ func ExportLayerToTar(ctx context.Context, w io.Writer, path string, parentLayer if err != nil { return err } - defer hcsshim.DeactivateLayer(driverInfo, path) + defer func() { + _ = hcsshim.DeactivateLayer(driverInfo, path) + }() // Prepare and unprepare the layer to ensure that it has been initialized. err = hcsshim.PrepareLayer(driverInfo, path, parentLayerPaths) diff --git a/test/functional/test.go b/test/functional/test.go index d942dd2898..28314d4928 100644 --- a/test/functional/test.go +++ b/test/functional/test.go @@ -14,8 +14,7 @@ import ( ) const ( - bytesPerMB = 1024 * 1024 - bytesPerPage = 4096 + bytesPerMB = 1024 * 1024 ) var pauseDurationOnCreateContainerFailure time.Duration @@ -36,7 +35,7 @@ func init() { // Try to stop any pre-existing compute processes cmd := exec.Command("powershell", `get-computeprocess | stop-computeprocess -force`) - cmd.Run() + _ = cmd.Run() } @@ -48,7 +47,7 @@ func CreateContainerTestWrapper(ctx context.Context, options *hcsoci.CreateOptio if err != nil { logrus.Warnf("Test is pausing for %s for debugging CreateContainer failure", pauseDurationOnCreateContainerFailure) time.Sleep(pauseDurationOnCreateContainerFailure) - resources.ReleaseResources(ctx, r, options.HostingSystem, true) + _ = resources.ReleaseResources(ctx, r, options.HostingSystem, true) } return s, r, err } diff --git a/test/functional/utilities/scratch.go b/test/functional/utilities/scratch.go index 23b7d92ec2..e7cf11028a 100644 --- a/test/functional/utilities/scratch.go +++ b/test/functional/utilities/scratch.go @@ -20,7 +20,7 @@ var ( func init() { if hcsSystem, err := hcs.OpenComputeSystem(context.Background(), lcowGlobalSVMID); err == nil { - hcsSystem.Terminate(context.Background()) + _ = hcsSystem.Terminate(context.Background()) } } diff --git a/test/vendor/github.com/Microsoft/hcsshim/computestorage/attach.go b/test/vendor/github.com/Microsoft/hcsshim/computestorage/attach.go index dcc61347c5..7f1f2823dd 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/computestorage/attach.go +++ b/test/vendor/github.com/Microsoft/hcsshim/computestorage/attach.go @@ -18,7 +18,7 @@ import ( // `layerData` is the parent read-only layer data. func AttachLayerStorageFilter(ctx context.Context, layerPath string, layerData LayerData) (err error) { title := "hcsshim.AttachLayerStorageFilter" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/test/vendor/github.com/Microsoft/hcsshim/computestorage/destroy.go b/test/vendor/github.com/Microsoft/hcsshim/computestorage/destroy.go index 39a9ba3812..8e28e6c504 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/computestorage/destroy.go +++ b/test/vendor/github.com/Microsoft/hcsshim/computestorage/destroy.go @@ -13,7 +13,7 @@ import ( // `layerPath` is a path to a directory containing the layer to export. func DestroyLayer(ctx context.Context, layerPath string) (err error) { title := "hcsshim.DestroyLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("layerPath", layerPath)) diff --git a/test/vendor/github.com/Microsoft/hcsshim/computestorage/detach.go b/test/vendor/github.com/Microsoft/hcsshim/computestorage/detach.go index 9c144c066b..435473257e 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/computestorage/detach.go +++ b/test/vendor/github.com/Microsoft/hcsshim/computestorage/detach.go @@ -13,7 +13,7 @@ import ( // `layerPath` is a path to a directory containing the layer to export. func DetachLayerStorageFilter(ctx context.Context, layerPath string) (err error) { title := "hcsshim.DetachLayerStorageFilter" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("layerPath", layerPath)) diff --git a/test/vendor/github.com/Microsoft/hcsshim/computestorage/export.go b/test/vendor/github.com/Microsoft/hcsshim/computestorage/export.go index 649b2602ae..a1b12dd129 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/computestorage/export.go +++ b/test/vendor/github.com/Microsoft/hcsshim/computestorage/export.go @@ -20,7 +20,7 @@ import ( // `options` are the export options applied to the exported layer. func ExportLayer(ctx context.Context, layerPath, exportFolderPath string, layerData LayerData, options ExportLayerOptions) (err error) { title := "hcsshim.ExportLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/test/vendor/github.com/Microsoft/hcsshim/computestorage/format.go b/test/vendor/github.com/Microsoft/hcsshim/computestorage/format.go index fe0861d2a0..83c0fa33f0 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/computestorage/format.go +++ b/test/vendor/github.com/Microsoft/hcsshim/computestorage/format.go @@ -14,7 +14,7 @@ import ( // If the VHD is not mounted it will be temporarily mounted. func FormatWritableLayerVhd(ctx context.Context, vhdHandle windows.Handle) (err error) { title := "hcsshim.FormatWritableLayerVhd" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() diff --git a/test/vendor/github.com/Microsoft/hcsshim/computestorage/helpers.go b/test/vendor/github.com/Microsoft/hcsshim/computestorage/helpers.go index d31efd6609..6b252f447b 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/computestorage/helpers.go +++ b/test/vendor/github.com/Microsoft/hcsshim/computestorage/helpers.go @@ -70,7 +70,7 @@ func SetupContainerBaseLayer(ctx context.Context, layerPath, baseVhdPath, diffVh defer func() { if err != nil { - syscall.CloseHandle(handle) + syscall.CloseHandle(handle) //nolint:errcheck os.RemoveAll(baseVhdPath) if os.Stat(diffVhdPath); err == nil { os.RemoveAll(diffVhdPath) @@ -148,7 +148,7 @@ func SetupUtilityVMBaseLayer(ctx context.Context, uvmPath, baseVhdPath, diffVhdP defer func() { if err != nil { - syscall.CloseHandle(handle) + syscall.CloseHandle(handle) //nolint:errcheck os.RemoveAll(baseVhdPath) if os.Stat(diffVhdPath); err == nil { os.RemoveAll(diffVhdPath) diff --git a/test/vendor/github.com/Microsoft/hcsshim/computestorage/import.go b/test/vendor/github.com/Microsoft/hcsshim/computestorage/import.go index 8ad2b085cb..0c61dab329 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/computestorage/import.go +++ b/test/vendor/github.com/Microsoft/hcsshim/computestorage/import.go @@ -20,7 +20,7 @@ import ( // `layerData` is the parent layer data. func ImportLayer(ctx context.Context, layerPath, sourceFolderPath string, layerData LayerData) (err error) { title := "hcsshim.ImportLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/test/vendor/github.com/Microsoft/hcsshim/computestorage/initialize.go b/test/vendor/github.com/Microsoft/hcsshim/computestorage/initialize.go index a50afd821e..53ed8ea6ed 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/computestorage/initialize.go +++ b/test/vendor/github.com/Microsoft/hcsshim/computestorage/initialize.go @@ -17,7 +17,7 @@ import ( // `layerData` is the parent read-only layer data. func InitializeWritableLayer(ctx context.Context, layerPath string, layerData LayerData) (err error) { title := "hcsshim.InitializeWritableLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/test/vendor/github.com/Microsoft/hcsshim/computestorage/mount.go b/test/vendor/github.com/Microsoft/hcsshim/computestorage/mount.go index 1c16ff4094..fcdbbef814 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/computestorage/mount.go +++ b/test/vendor/github.com/Microsoft/hcsshim/computestorage/mount.go @@ -13,7 +13,7 @@ import ( // GetLayerVhdMountPath returns the volume path for a virtual disk of a writable container layer. func GetLayerVhdMountPath(ctx context.Context, vhdHandle windows.Handle) (path string, err error) { title := "hcsshim.GetLayerVhdMountPath" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() diff --git a/test/vendor/github.com/Microsoft/hcsshim/computestorage/setup.go b/test/vendor/github.com/Microsoft/hcsshim/computestorage/setup.go index 7506709ca6..ca7b40ef66 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/computestorage/setup.go +++ b/test/vendor/github.com/Microsoft/hcsshim/computestorage/setup.go @@ -22,7 +22,7 @@ import ( // `options` are the options applied while processing the layer. func SetupBaseOSLayer(ctx context.Context, layerPath string, vhdHandle windows.Handle, options OsLayerOptions) (err error) { title := "hcsshim.SetupBaseOSLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( @@ -53,7 +53,7 @@ func SetupBaseOSVolume(ctx context.Context, layerPath, volumePath string, option return errors.New("SetupBaseOSVolume is not present on builds older than 19645") } title := "hcsshim.SetupBaseOSVolume" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/test/vendor/github.com/Microsoft/hcsshim/errors.go b/test/vendor/github.com/Microsoft/hcsshim/errors.go index 061727c679..5bdc23e45d 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/errors.go +++ b/test/vendor/github.com/Microsoft/hcsshim/errors.go @@ -132,15 +132,6 @@ func (e *ContainerError) Error() string { return s } -func makeContainerError(container *container, operation string, extraInfo string, err error) error { - // Don't double wrap errors - if _, ok := err.(*ContainerError); ok { - return err - } - containerError := &ContainerError{Container: container, Operation: operation, ExtraInfo: extraInfo, Err: err} - return containerError -} - func (e *ProcessError) Error() string { if e == nil { return "" @@ -171,15 +162,6 @@ func (e *ProcessError) Error() string { return s } -func makeProcessError(process *process, operation string, extraInfo string, err error) error { - // Don't double wrap errors - if _, ok := err.(*ProcessError); ok { - return err - } - processError := &ProcessError{Process: process, Operation: operation, ExtraInfo: extraInfo, Err: err} - return processError -} - // IsNotExist checks if an error is caused by the Container or Process not existing. // Note: Currently, ErrElementNotFound can mean that a Process has either // already exited, or does not exist. Both IsAlreadyStopped and IsNotExist diff --git a/test/vendor/github.com/Microsoft/hcsshim/hcn/hcn.go b/test/vendor/github.com/Microsoft/hcsshim/hcn/hcn.go index c75125e523..ed311fed9d 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/hcn/hcn.go +++ b/test/vendor/github.com/Microsoft/hcsshim/hcn/hcn.go @@ -3,7 +3,6 @@ package hcn import ( - "encoding/json" "fmt" "syscall" @@ -64,12 +63,6 @@ import ( //sys hcnDeleteRoute(id *_guid, result **uint16) (hr error) = computenetwork.HcnDeleteSdnRoute? //sys hcnCloseRoute(route hcnRoute) (hr error) = computenetwork.HcnCloseSdnRoute? -// Service -//sys hcnOpenService(service *hcnService, result **uint16) (hr error) = computenetwork.HcnOpenService? -//sys hcnRegisterServiceCallback(service hcnService, callback int32, context int32, callbackHandle *hcnCallbackHandle) (hr error) = computenetwork.HcnRegisterServiceCallback? -//sys hcnUnregisterServiceCallback(callbackHandle hcnCallbackHandle) (hr error) = computenetwork.HcnUnregisterServiceCallback? -//sys hcnCloseService(service hcnService) (hr error) = computenetwork.HcnCloseService? - type _guid = guid.GUID type hcnNetwork syscall.Handle @@ -77,8 +70,6 @@ type hcnEndpoint syscall.Handle type hcnNamespace syscall.Handle type hcnLoadBalancer syscall.Handle type hcnRoute syscall.Handle -type hcnService syscall.Handle -type hcnCallbackHandle syscall.Handle // SchemaVersion for HCN Objects/Queries. type SchemaVersion = Version // hcnglobals.go @@ -128,15 +119,6 @@ func defaultQuery() HostComputeQuery { return query } -func defaultQueryJson() string { - query := defaultQuery() - queryJson, err := json.Marshal(query) - if err != nil { - return "" - } - return string(queryJson) -} - // PlatformDoesNotSupportError happens when users are attempting to use a newer shim on an older OS func platformDoesNotSupportError(featureName string) error { return fmt.Errorf("Platform does not support feature %s", featureName) diff --git a/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnloadbalancer.go b/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnloadbalancer.go index 9ed59a669a..e74c77654b 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnloadbalancer.go +++ b/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnloadbalancer.go @@ -160,50 +160,6 @@ func createLoadBalancer(settings string) (*HostComputeLoadBalancer, error) { return &outputLoadBalancer, nil } -func modifyLoadBalancer(loadBalancerId string, settings string) (*HostComputeLoadBalancer, error) { - loadBalancerGuid, err := guid.FromString(loadBalancerId) - if err != nil { - return nil, errInvalidLoadBalancerID - } - // Open loadBalancer. - var ( - loadBalancerHandle hcnLoadBalancer - resultBuffer *uint16 - propertiesBuffer *uint16 - ) - hr := hcnOpenLoadBalancer(&loadBalancerGuid, &loadBalancerHandle, &resultBuffer) - if err := checkForErrors("hcnOpenLoadBalancer", hr, resultBuffer); err != nil { - return nil, err - } - // Modify loadBalancer. - hr = hcnModifyLoadBalancer(loadBalancerHandle, settings, &resultBuffer) - if err := checkForErrors("hcnModifyLoadBalancer", hr, resultBuffer); err != nil { - return nil, err - } - // Query loadBalancer. - hcnQuery := defaultQuery() - query, err := json.Marshal(hcnQuery) - if err != nil { - return nil, err - } - hr = hcnQueryLoadBalancerProperties(loadBalancerHandle, string(query), &propertiesBuffer, &resultBuffer) - if err := checkForErrors("hcnQueryLoadBalancerProperties", hr, resultBuffer); err != nil { - return nil, err - } - properties := interop.ConvertAndFreeCoTaskMemString(propertiesBuffer) - // Close loadBalancer. - hr = hcnCloseLoadBalancer(loadBalancerHandle) - if err := checkForErrors("hcnCloseLoadBalancer", hr, nil); err != nil { - return nil, err - } - // Convert output to LoadBalancer - var outputLoadBalancer HostComputeLoadBalancer - if err := json.Unmarshal([]byte(properties), &outputLoadBalancer); err != nil { - return nil, err - } - return &outputLoadBalancer, nil -} - func deleteLoadBalancer(loadBalancerId string) error { loadBalancerGuid, err := guid.FromString(loadBalancerId) if err != nil { diff --git a/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnnamespace.go b/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnnamespace.go index 22c7cf95f6..60d83ef135 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnnamespace.go +++ b/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnnamespace.go @@ -378,7 +378,7 @@ func (namespace *HostComputeNamespace) Sync() error { // The shim is likey gone. Simply ignore the sync as if it didn't exist. if perr, ok := err.(*os.PathError); ok && perr.Err == syscall.ERROR_FILE_NOT_FOUND { // Remove the reg key there is no point to try again - cfg.Remove() + cfg.Remove() //nolint:errcheck return nil } f := map[string]interface{}{ diff --git a/test/vendor/github.com/Microsoft/hcsshim/hcn/zsyscall_windows.go b/test/vendor/github.com/Microsoft/hcsshim/hcn/zsyscall_windows.go index 466d304572..7ec5b58b66 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/hcn/zsyscall_windows.go +++ b/test/vendor/github.com/Microsoft/hcsshim/hcn/zsyscall_windows.go @@ -78,10 +78,6 @@ var ( procHcnQuerySdnRouteProperties = modcomputenetwork.NewProc("HcnQuerySdnRouteProperties") procHcnDeleteSdnRoute = modcomputenetwork.NewProc("HcnDeleteSdnRoute") procHcnCloseSdnRoute = modcomputenetwork.NewProc("HcnCloseSdnRoute") - procHcnOpenService = modcomputenetwork.NewProc("HcnOpenService") - procHcnRegisterServiceCallback = modcomputenetwork.NewProc("HcnRegisterServiceCallback") - procHcnUnregisterServiceCallback = modcomputenetwork.NewProc("HcnUnregisterServiceCallback") - procHcnCloseService = modcomputenetwork.NewProc("HcnCloseService") ) func SetCurrentThreadCompartmentId(compartmentId uint32) (hr error) { @@ -797,59 +793,3 @@ func hcnCloseRoute(route hcnRoute) (hr error) { } return } - -func hcnOpenService(service *hcnService, result **uint16) (hr error) { - if hr = procHcnOpenService.Find(); hr != nil { - return - } - r0, _, _ := syscall.Syscall(procHcnOpenService.Addr(), 2, uintptr(unsafe.Pointer(service)), uintptr(unsafe.Pointer(result)), 0) - if int32(r0) < 0 { - if r0&0x1fff0000 == 0x00070000 { - r0 &= 0xffff - } - hr = syscall.Errno(r0) - } - return -} - -func hcnRegisterServiceCallback(service hcnService, callback int32, context int32, callbackHandle *hcnCallbackHandle) (hr error) { - if hr = procHcnRegisterServiceCallback.Find(); hr != nil { - return - } - r0, _, _ := syscall.Syscall6(procHcnRegisterServiceCallback.Addr(), 4, uintptr(service), uintptr(callback), uintptr(context), uintptr(unsafe.Pointer(callbackHandle)), 0, 0) - if int32(r0) < 0 { - if r0&0x1fff0000 == 0x00070000 { - r0 &= 0xffff - } - hr = syscall.Errno(r0) - } - return -} - -func hcnUnregisterServiceCallback(callbackHandle hcnCallbackHandle) (hr error) { - if hr = procHcnUnregisterServiceCallback.Find(); hr != nil { - return - } - r0, _, _ := syscall.Syscall(procHcnUnregisterServiceCallback.Addr(), 1, uintptr(callbackHandle), 0, 0) - if int32(r0) < 0 { - if r0&0x1fff0000 == 0x00070000 { - r0 &= 0xffff - } - hr = syscall.Errno(r0) - } - return -} - -func hcnCloseService(service hcnService) (hr error) { - if hr = procHcnCloseService.Find(); hr != nil { - return - } - r0, _, _ := syscall.Syscall(procHcnCloseService.Addr(), 1, uintptr(service), 0, 0) - if int32(r0) < 0 { - if r0&0x1fff0000 == 0x00070000 { - r0 &= 0xffff - } - hr = syscall.Errno(r0) - } - return -} diff --git a/test/vendor/github.com/Microsoft/hcsshim/hnsendpoint.go b/test/vendor/github.com/Microsoft/hcsshim/hnsendpoint.go index 09b3860a7b..408312672e 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/hnsendpoint.go +++ b/test/vendor/github.com/Microsoft/hcsshim/hnsendpoint.go @@ -40,6 +40,9 @@ func HNSListEndpointRequest() ([]HNSEndpoint, error) { // HotAttachEndpoint makes a HCS Call to attach the endpoint to the container func HotAttachEndpoint(containerID string, endpointID string) error { endpoint, err := GetHNSEndpointByID(endpointID) + if err != nil { + return err + } isAttached, err := endpoint.IsAttached(containerID) if isAttached { return err @@ -50,6 +53,9 @@ func HotAttachEndpoint(containerID string, endpointID string) error { // HotDetachEndpoint makes a HCS Call to detach the endpoint from the container func HotDetachEndpoint(containerID string, endpointID string) error { endpoint, err := GetHNSEndpointByID(endpointID) + if err != nil { + return err + } isAttached, err := endpoint.IsAttached(containerID) if !isAttached { return err diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/cmd.go b/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/cmd.go index 478455429f..6f877efae7 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/cmd.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/cmd.go @@ -215,7 +215,10 @@ func (c *Cmd) Start() error { c.stdinErr.Store(err) } // Notify the process that there is no more input. - p.CloseStdin(context.TODO()) + err = p.CloseStdin(context.TODO()) + if err != nil && c.Log != nil { + c.Log.WithError(err).Warn("failed to close pod stdin") + } }() } @@ -237,7 +240,7 @@ func (c *Cmd) Start() error { go func() { select { case <-c.Context.Done(): - c.Process.Kill(context.TODO()) + c.Process.Kill(context.TODO()) //nolint:errcheck case <-c.allDoneCh: } }() diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/io_binary.go b/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/io_binary.go index 1fde77e482..ac53d3c22f 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/io_binary.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/io_binary.go @@ -155,7 +155,7 @@ type binaryIO struct { binaryCloser sync.Once - stdin, stdout, stderr string + stdout, stderr string sout, serr io.ReadWriteCloser soutCloser sync.Once diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/copyfile/copyfile.go b/test/vendor/github.com/Microsoft/hcsshim/internal/copyfile/copyfile.go index 3f7bd23885..fe7a2faa11 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/copyfile/copyfile.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/copyfile/copyfile.go @@ -18,7 +18,7 @@ var ( // CopyFile is a utility for copying a file using CopyFileW win32 API for // performance. func CopyFile(ctx context.Context, srcFile, destFile string, overwrite bool) (err error) { - ctx, span := trace.StartSpan(ctx, "copyfile::CopyFile") + ctx, span := trace.StartSpan(ctx, "copyfile::CopyFile") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/cpugroup/cpugroup.go b/test/vendor/github.com/Microsoft/hcsshim/internal/cpugroup/cpugroup.go index e2d7e2b361..41caf24106 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/cpugroup/cpugroup.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/cpugroup/cpugroup.go @@ -54,6 +54,7 @@ func Create(ctx context.Context, id string, logicalProcessors []uint32) error { } // getCPUGroupConfig finds the cpugroup config information for group with `id` +//nolint:unused func getCPUGroupConfig(ctx context.Context, id string) (*hcsschema.CpuGroupConfig, error) { query := hcsschema.PropertyQuery{ PropertyTypes: []hcsschema.PropertyType{hcsschema.PTCPUGroup}, @@ -68,7 +69,7 @@ func getCPUGroupConfig(ctx context.Context, id string) (*hcsschema.CpuGroupConfi } for _, c := range groupConfigs.CpuGroups { - if strings.ToLower(c.GroupId) == strings.ToLower(id) { + if strings.EqualFold(c.GroupId, id) { return &c, nil } } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/devices/assigned_devices.go b/test/vendor/github.com/Microsoft/hcsshim/internal/devices/assigned_devices.go index de1ca247d7..f712009571 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/devices/assigned_devices.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/devices/assigned_devices.go @@ -145,10 +145,7 @@ func readCsPipeOutput(l net.Listener, errChan chan<- error, result *[]string) { elementsAsString := strings.TrimSuffix(string(bytes), "\n") elements := strings.Split(elementsAsString, ",") - - for _, elem := range elements { - *result = append(*result, elem) - } + *result = append(*result, elements...) if len(*result) == 0 { errChan <- errors.Wrapf(err, "failed to get any pipe output") diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/guestconnection.go b/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/guestconnection.go index 43f99fd62e..921e5f490b 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/guestconnection.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/guestconnection.go @@ -70,7 +70,7 @@ func (gcc *GuestConnectionConfig) Connect(ctx context.Context, isColdStart bool) gc.brdg = newBridge(gcc.Conn, gc.notify, gcc.Log) gc.brdg.Start() go func() { - gc.brdg.Wait() + gc.brdg.Wait() //nolint:errcheck gc.clearNotifies() }() err = gc.connect(ctx, isColdStart) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/process.go b/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/process.go index e82471ce3a..f496522c87 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/process.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/process.go @@ -145,7 +145,7 @@ func (p *Process) Close() error { // CloseStdin causes the process to read EOF on its stdin stream. func (p *Process) CloseStdin(ctx context.Context) (err error) { - ctx, span := trace.StartSpan(ctx, "gcs::Process::CloseStdin") + ctx, span := trace.StartSpan(ctx, "gcs::Process::CloseStdin") //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/protocol.go b/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/protocol.go index 23acd3cabd..f1a8346195 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/protocol.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/protocol.go @@ -66,9 +66,9 @@ type msgType uint32 const ( msgTypeRequest msgType = 0x10100000 - msgTypeResponse = 0x20100000 - msgTypeNotify = 0x30100000 - msgTypeMask = 0xfff00000 + msgTypeResponse msgType = 0x20100000 + msgTypeNotify msgType = 0x30100000 + msgTypeMask msgType = 0xfff00000 notifyContainer = 1<<8 | 1 ) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/resourcepaths.go b/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/resourcepaths.go index 8540af96c7..20b57b710a 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/resourcepaths.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/resourcepaths.go @@ -2,9 +2,9 @@ package gcs const ( // silo container resources paths - siloDeviceResourcePath string = "Container/Devices/Generic" - siloMappedDirectoryResourcePath string = "Container/MappedDirectories" - siloMappedPipeResourcePath string = "Container/MappedPipes" - siloMemoryResourcePath string = "Container/Memory/SizeInMB" - siloRegistryFlushStatePath string = "Container/RegistryFlushState" + siloDeviceResourcePath string = "Container/Devices/Generic" //nolint + siloMappedDirectoryResourcePath string = "Container/MappedDirectories" //nolint + siloMappedPipeResourcePath string = "Container/MappedPipes" //nolint + siloMemoryResourcePath string = "Container/Memory/SizeInMB" //nolint + siloRegistryFlushStatePath string = "Container/RegistryFlushState" //nolint ) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go index bca824b8e1..ce6616ac0b 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go @@ -332,12 +332,3 @@ func getInnerError(err error) error { } return err } - -func getOperationLogResult(err error) (string, error) { - switch err { - case nil: - return "Success", nil - default: - return "Error", err - } -} diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go index 2ad978f290..b74389eca2 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go @@ -64,11 +64,7 @@ type processStatus struct { LastWaitResult int32 } -const ( - stdIn string = "StdIn" - stdOut string = "StdOut" - stdErr string = "StdErr" -) +const stdIn string = "StdIn" const ( modifyConsoleSize string = "ConsoleSize" @@ -176,8 +172,10 @@ func (process *Process) waitBackground() { trace.Int64Attribute("pid", int64(process.processID))) var ( - err error - exitCode = -1 + err error + exitCode = -1 + propertiesJSON string + resultJSON string ) err = waitForNotification(ctx, process.callbackNumber, hcsNotificationProcessExited, nil) @@ -190,15 +188,15 @@ func (process *Process) waitBackground() { // Make sure we didnt race with Close() here if process.handle != 0 { - propertiesJSON, resultJSON, err := vmcompute.HcsGetProcessProperties(ctx, process.handle) + propertiesJSON, resultJSON, err = vmcompute.HcsGetProcessProperties(ctx, process.handle) events := processHcsResult(ctx, resultJSON) if err != nil { - err = makeProcessError(process, operation, err, events) + err = makeProcessError(process, operation, err, events) //nolint:ineffassign } else { properties := &processStatus{} err = json.Unmarshal([]byte(propertiesJSON), properties) if err != nil { - err = makeProcessError(process, operation, err, nil) + err = makeProcessError(process, operation, err, nil) //nolint:ineffassign } else { if properties.LastWaitResult != 0 { log.G(ctx).WithField("wait-result", properties.LastWaitResult).Warning("non-zero last wait result") @@ -468,7 +466,7 @@ func (process *Process) unregisterCallback(ctx context.Context) error { delete(callbackMap, callbackNumber) callbackMapLock.Unlock() - handle = 0 + handle = 0 //nolint:ineffassign return nil } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go index bda393a6d1..5eb140d511 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go @@ -73,7 +73,7 @@ func CreateComputeSystem(ctx context.Context, id string, hcsDocumentInterface in if err = computeSystem.registerCallback(ctx); err != nil { // Terminate the compute system if it still exists. We're okay to // ignore a failure here. - computeSystem.Terminate(ctx) + computeSystem.Terminate(ctx) //nolint:errcheck return nil, makeSystemError(computeSystem, operation, "", err, nil) } } @@ -83,7 +83,7 @@ func CreateComputeSystem(ctx context.Context, id string, hcsDocumentInterface in if err == ErrTimeout { // Terminate the compute system if it still exists. We're okay to // ignore a failure here. - computeSystem.Terminate(ctx) + computeSystem.Terminate(ctx) //nolint:errcheck } return nil, makeSystemError(computeSystem, operation, hcsDocument, err, events) } @@ -605,7 +605,7 @@ func (computeSystem *System) unregisterCallback(ctx context.Context) error { delete(callbackMap, callbackNumber) callbackMapLock.Unlock() - handle = 0 + handle = 0 //nolint:ineffassign return nil } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/waithelper.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/waithelper.go index f07f532c13..db4e14fdfb 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/waithelper.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/waithelper.go @@ -65,5 +65,4 @@ func waitForNotification(ctx context.Context, callbackNumber uintptr, expectedNo case <-c: return ErrTimeout } - return nil } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/create.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/create.go index 19689e9e01..8d58df2689 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/create.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/create.go @@ -83,11 +83,6 @@ func cmpSlices(s1, s2 []string) bool { return equal } -// Compares to mount structs and returns true if they are equal, returns false otherwise. -func compareMounts(m1, m2 specs.Mount) bool { - return cmpSlices(m1.Options, m2.Options) && (m1.Source == m2.Source) && (m1.Destination == m2.Destination) && (m1.Type == m2.Type) -} - // verifyCloneContainerSpecs compares the container creation spec provided during the template container // creation and the spec provided during cloned container creation and checks that all the fields match // (except for the certain fields that are allowed to be different). @@ -276,7 +271,7 @@ func CreateContainer(ctx context.Context, createOptions *CreateOptions) (_ cow.C defer func() { if err != nil { if !coi.DoNotReleaseResourcesOnFailure { - resources.ReleaseResources(ctx, r, coi.HostingSystem, true) + resources.ReleaseResources(ctx, r, coi.HostingSystem, true) //nolint:errcheck } } }() @@ -393,7 +388,7 @@ func CloneContainer(ctx context.Context, createOptions *CreateOptions) (_ cow.Co defer func() { if err != nil { if !coi.DoNotReleaseResourcesOnFailure { - resources.ReleaseResources(ctx, r, coi.HostingSystem, true) + resources.ReleaseResources(ctx, r, coi.HostingSystem, true) //nolint:errcheck } } }() diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/resources_lcow.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/resources_lcow.go index b6b7b40e32..66752d18a1 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/resources_lcow.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/resources_lcow.go @@ -99,7 +99,6 @@ func allocateLinuxResources(ctx context.Context, coi *createOptionsInternal, r * } uvmPathForFile = scsiMount.UVMPath - uvmPathForShare = scsiMount.UVMPath r.Add(scsiMount) coi.Spec.Mounts[i].Type = "none" } else if mount.Type == "virtual-disk" { @@ -114,7 +113,6 @@ func allocateLinuxResources(ctx context.Context, coi *createOptionsInternal, r * } uvmPathForFile = scsiMount.UVMPath - uvmPathForShare = scsiMount.UVMPath r.Add(scsiMount) coi.Spec.Mounts[i].Type = "none" } else if strings.HasPrefix(mount.Source, "sandbox://") { diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsnetwork.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsnetwork.go index b7ae96fddd..f12d3ab041 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsnetwork.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hns/hnsnetwork.go @@ -39,12 +39,6 @@ type HNSNetwork struct { AutomaticDNS bool `json:",omitempty"` } -type hnsNetworkResponse struct { - Success bool - Error string - Output HNSNetwork -} - type hnsResponse struct { Success bool Error string diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/layers/layers.go b/test/vendor/github.com/Microsoft/hcsshim/internal/layers/layers.go index 3fffd827be..0391d7450e 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/layers/layers.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/layers/layers.go @@ -83,7 +83,7 @@ func MountContainerLayers(ctx context.Context, layerFolders []string, guestRoot } defer func() { if err != nil { - wclayer.DeactivateLayer(ctx, path) + wclayer.DeactivateLayer(ctx, path) //nolint:errcheck } }() @@ -92,7 +92,7 @@ func MountContainerLayers(ctx context.Context, layerFolders []string, guestRoot } defer func() { if err != nil { - wclayer.UnprepareLayer(ctx, path) + wclayer.UnprepareLayer(ctx, path) //nolint:errcheck } }() @@ -188,7 +188,8 @@ func MountContainerLayers(ctx context.Context, layerFolders []string, guestRoot if uvm.OS() == "windows" { // Load the filter at the C:\s location calculated above. We pass into this request each of the // read-only layer folders. - layers, err := GetHCSLayers(ctx, uvm, layersAdded) + var layers []hcsschema.Layer + layers, err = GetHCSLayers(ctx, uvm, layersAdded) if err != nil { return "", err } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/disk.go b/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/disk.go index ac68dcfcf0..ebe6efcb1e 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/disk.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/disk.go @@ -34,7 +34,7 @@ func FormatDisk(ctx context.Context, lcowUVM *uvm.UtilityVM, destPath string) er } defer func() { - scsi.Release(ctx) + scsi.Release(ctx) //nolint:errcheck }() log.G(ctx).WithFields(logrus.Fields{ diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/scratch.go b/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/scratch.go index 212d8ac3e9..4060885a99 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/scratch.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/scratch.go @@ -73,7 +73,7 @@ func CreateScratch(ctx context.Context, lcowUVM *uvm.UtilityVM, destFile string, removeSCSI := true defer func() { if removeSCSI { - lcowUVM.RemoveSCSI(ctx, destFile) + lcowUVM.RemoveSCSI(ctx, destFile) //nolint:errcheck } }() diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/regstate/regstate.go b/test/vendor/github.com/Microsoft/hcsshim/internal/regstate/regstate.go index 6c4a641561..6086c1dc52 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/regstate/regstate.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/regstate/regstate.go @@ -9,6 +9,7 @@ import ( "reflect" "syscall" + "golang.org/x/sys/windows" "golang.org/x/sys/windows/registry" ) @@ -19,7 +20,6 @@ import ( const ( _REG_OPTION_VOLATILE = 1 - _REG_CREATED_NEW_KEY = 1 _REG_OPENED_EXISTING_KEY = 2 ) @@ -61,7 +61,8 @@ func createVolatileKey(k *Key, path string, access uint32) (newk *Key, openedExi d uint32 ) fullpath := filepath.Join(k.Name, path) - err = regCreateKeyEx(syscall.Handle(k.Key), syscall.StringToUTF16Ptr(path), 0, nil, _REG_OPTION_VOLATILE, access, nil, &h, &d) + pathPtr, _ := windows.UTF16PtrFromString(path) + err = regCreateKeyEx(syscall.Handle(k.Key), pathPtr, 0, nil, _REG_OPTION_VOLATILE, access, nil, &h, &d) if err != nil { return nil, false, &os.PathError{Op: "RegCreateKeyEx", Path: fullpath, Err: err} } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/runhcs/container.go b/test/vendor/github.com/Microsoft/hcsshim/internal/runhcs/container.go index 2f39e5845a..79f0dbfe36 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/runhcs/container.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/runhcs/container.go @@ -51,7 +51,7 @@ func GetErrorFromPipe(pipe io.Reader, p *os.Process) error { extra := "" if p != nil { - p.Kill() + p.Kill() //nolint:errcheck state, err := p.Wait() if err != nil { panic(err) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go b/test/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go index 05f22f39dd..b800e8e02c 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go @@ -244,7 +244,7 @@ func RemoveRelative(path string, root *os.File) error { err = deleteOnClose(f) if err == syscall.ERROR_ACCESS_DENIED { // Maybe the file is marked readonly. Clear the bit and retry. - clearReadOnly(f) + clearReadOnly(f) //nolint:errcheck err = deleteOnClose(f) } } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/schema1/schema1.go b/test/vendor/github.com/Microsoft/hcsshim/internal/schema1/schema1.go index cd1ec84abb..b468ad6365 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/schema1/schema1.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/schema1/schema1.go @@ -119,9 +119,9 @@ type PropertyType string const ( PropertyTypeStatistics PropertyType = "Statistics" // V1 and V2 - PropertyTypeProcessList = "ProcessList" // V1 and V2 - PropertyTypeMappedVirtualDisk = "MappedVirtualDisk" // Not supported in V2 schema call - PropertyTypeGuestConnection = "GuestConnection" // V1 and V2. Nil return from HCS before RS5 + PropertyTypeProcessList PropertyType = "ProcessList" // V1 and V2 + PropertyTypeMappedVirtualDisk PropertyType = "MappedVirtualDisk" // Not supported in V2 schema call + PropertyTypeGuestConnection PropertyType = "GuestConnection" // V1 and V2. Nil return from HCS before RS5 ) type PropertyQuery struct { diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/device.go b/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/device.go index 0b9c0fbf7d..107caddada 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/device.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/device.go @@ -13,8 +13,8 @@ type DeviceType string const ( ClassGUID DeviceType = "ClassGuid" - DeviceInstance = "DeviceInstance" - GPUMirror = "GpuMirror" + DeviceInstance DeviceType = "DeviceInstance" + GPUMirror DeviceType = "GpuMirror" ) type Device struct { diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/logical_processor.go b/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/logical_processor.go index 676ad300dc..2e3aa5e175 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/logical_processor.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/logical_processor.go @@ -11,8 +11,8 @@ package hcsschema type LogicalProcessor struct { LpIndex uint32 `json:"LpIndex,omitempty"` - NodeNumber uint8 `json:"NodeNumber, omitempty"` - PackageId uint32 `json:"PackageId, omitempty"` - CoreId uint32 `json:"CoreId, omitempty"` - RootVpIndex int32 `json:"RootVpIndex, omitempty"` + NodeNumber uint8 `json:"NodeNumber,omitempty"` + PackageId uint32 `json:"PackageId,omitempty"` + CoreId uint32 `json:"CoreId,omitempty"` + RootVpIndex int32 `json:"RootVpIndex,omitempty"` } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create.go index cb18835309..b40fce1280 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create.go @@ -216,6 +216,7 @@ func (uvm *UtilityVM) create(ctx context.Context, doc interface{}) error { return err } defer func() { + //nolint:errcheck if system != nil { system.Terminate(ctx) system.Wait() @@ -251,8 +252,8 @@ func (uvm *UtilityVM) Close() (err error) { if err := uvm.ReleaseCPUGroup(ctx); err != nil { log.G(ctx).WithError(err).Warn("failed to release VM resource") } - uvm.hcsSystem.Terminate(ctx) - uvm.Wait() + uvm.hcsSystem.Terminate(ctx) //nolint:errcheck + uvm.Wait() //nolint:errcheck } if err := uvm.CloseGCSConnection(); err != nil { diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/resourcepaths.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/resourcepaths.go index 395e5ea412..81f90d4122 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/resourcepaths.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/resourcepaths.go @@ -1,5 +1,6 @@ package uvm +//nolint:deadcode,varcheck const ( gpuResourcePath string = "VirtualMachine/ComputeTopology/Gpu" memoryResourcePath string = "VirtualMachine/ComputeTopology/Memory/SizeInMB" diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go index 55a4e4c292..71ff206954 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go @@ -22,7 +22,7 @@ func (uvm *UtilityVM) Share(ctx context.Context, reqHostPath, reqUVMPath string, } defer func() { if err != nil { - vsmbShare.Release(ctx) + vsmbShare.Release(ctx) //nolint:errcheck } }() @@ -64,7 +64,7 @@ func (uvm *UtilityVM) Share(ctx context.Context, reqHostPath, reqUVMPath string, } defer func() { if err != nil { - plan9Share.Release(ctx) + plan9Share.Release(ctx) //nolint:errcheck } }() } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go index 7d8a8459e8..bc3ac9503a 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go @@ -153,7 +153,7 @@ func (uvm *UtilityVM) configureHvSocketForGCS(ctx context.Context) (err error) { func (uvm *UtilityVM) Start(ctx context.Context) (err error) { ctx, cancel := context.WithTimeout(ctx, 2*time.Minute) g, gctx := errgroup.WithContext(ctx) - defer g.Wait() + defer g.Wait() //nolint:errcheck defer cancel() // Prepare to provide entropy to the init process in the background. This @@ -197,6 +197,7 @@ func (uvm *UtilityVM) Start(ctx context.Context) (err error) { return err } defer func() { + //nolint:errcheck if err != nil { uvm.hcsSystem.Terminate(ctx) uvm.hcsSystem.Wait() diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go index e15fb42554..5d2e3c2ff4 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go @@ -79,7 +79,6 @@ func (uvm *UtilityVM) SetSaveableVSMBOptions(opts *hcsschema.VirtualSmbShareOpti opts.NoLocks = true opts.PseudoDirnotify = true opts.NoDirectmap = true - return } // findVSMBShare finds a share by `hostPath`. If not found returns `ErrNotAttached`. @@ -142,7 +141,7 @@ func forceNoDirectMap(path string) (bool, error) { if err != nil { return false, err } - defer windows.CloseHandle(h) + defer windows.CloseHandle(h) //nolint:errcheck var info winapi.FILE_ID_INFO // We check for any error, rather than just ERROR_INVALID_PARAMETER. It seems better to also // fall back if e.g. some other backing filesystem is used which returns a different error. diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/vmcompute/vmcompute.go b/test/vendor/github.com/Microsoft/hcsshim/internal/vmcompute/vmcompute.go index 32491f2c31..e7f114b67a 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/vmcompute/vmcompute.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/vmcompute/vmcompute.go @@ -62,7 +62,7 @@ type HcsCallback syscall.Handle type HcsProcessInformation struct { // ProcessId is the pid of the created process. ProcessId uint32 - reserved uint32 + reserved uint32 //nolint:structcheck // StdInput is the handle associated with the stdin of the process. StdInput syscall.Handle // StdOutput is the handle associated with the stdout of the process. diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go index 81e454956a..ff81ac2c15 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go @@ -14,7 +14,7 @@ import ( // An activated layer must later be deactivated via DeactivateLayer. func ActivateLayer(ctx context.Context, path string) (err error) { title := "hcsshim::ActivateLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go index 41e5e6731e..ffee31ab12 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go @@ -12,7 +12,7 @@ import ( // the parent layer provided. func CreateLayer(ctx context.Context, path, parent string) (err error) { title := "hcsshim::CreateLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/deactivatelayer.go b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/deactivatelayer.go index 70a711cf5d..d5bf2f5bdc 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/deactivatelayer.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/deactivatelayer.go @@ -11,7 +11,7 @@ import ( // DeactivateLayer will dismount a layer that was mounted via ActivateLayer. func DeactivateLayer(ctx context.Context, path string) (err error) { title := "hcsshim::DeactivateLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/destroylayer.go b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/destroylayer.go index bf197e3b0a..787054e794 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/destroylayer.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/destroylayer.go @@ -12,7 +12,7 @@ import ( // path, including that layer's containing folder, if any. func DestroyLayer(ctx context.Context, path string) (err error) { title := "hcsshim::DestroyLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go index 942e3bbf9d..4d22d0ecf3 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go @@ -21,8 +21,7 @@ func GetLayerMountPath(ctx context.Context, path string) (_ string, err error) { defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) - var mountPathLength uintptr - mountPathLength = 0 + var mountPathLength uintptr = 0 // Call the procedure itself. log.G(ctx).Debug("Calling proc (1)") diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getsharedbaseimages.go b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getsharedbaseimages.go index a50378f492..bcc8fbd423 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getsharedbaseimages.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/getsharedbaseimages.go @@ -14,7 +14,7 @@ import ( // of registering them with the graphdriver, graph, and tagstore. func GetSharedBaseImages(ctx context.Context) (_ string, err error) { title := "hcsshim::GetSharedBaseImages" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go index aa7c8ae1fd..3eaca27808 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go @@ -11,7 +11,7 @@ import ( // GrantVmAccess adds access to a file for a given VM func GrantVmAccess(ctx context.Context, vmid string, filepath string) (err error) { title := "hcsshim::GrantVmAccess" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes( diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go index 6dd6f2d575..c6999973cb 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go @@ -12,7 +12,7 @@ import ( // to the system. func LayerExists(ctx context.Context, path string) (_ bool, err error) { title := "hcsshim::LayerExists" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go index dc3caf7510..043c56dee2 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go @@ -390,7 +390,7 @@ func (w *legacyLayerWriter) CloseRoots() { w.destRoot = nil } for i := range w.parentRoots { - w.parentRoots[i].Close() + w.parentRoots[i].Close() //nolint:errcheck } w.parentRoots = nil } @@ -640,7 +640,7 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro defer func() { if f != nil { f.Close() - safefile.RemoveRelative(name, w.destRoot) + safefile.RemoveRelative(name, w.destRoot) //nolint:errcheck } }() @@ -676,7 +676,7 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro defer func() { if f != nil { f.Close() - safefile.RemoveRelative(fname, w.root) + safefile.RemoveRelative(fname, w.root) //nolint:errcheck } }() diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go index b732857b32..bcf39c6b86 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go @@ -14,7 +14,7 @@ import ( // across all clients. func NameToGuid(ctx context.Context, name string) (_ guid.GUID, err error) { title := "hcsshim::NameToGuid" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("name", name)) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/processimage.go b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/processimage.go index aabb313684..30bcdff5f5 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/processimage.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/processimage.go @@ -12,7 +12,7 @@ import ( // The files should have been extracted to \Files. func ProcessBaseLayer(ctx context.Context, path string) (err error) { title := "hcsshim::ProcessBaseLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) @@ -28,7 +28,7 @@ func ProcessBaseLayer(ctx context.Context, path string) (err error) { // The files should have been extracted to \Files. func ProcessUtilityVMImage(ctx context.Context, path string) (err error) { title := "hcsshim::ProcessUtilityVMImage" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go index 84f81848ff..79fb986786 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go @@ -12,7 +12,7 @@ import ( // the given id. func UnprepareLayer(ctx context.Context, path string) (err error) { title := "hcsshim::UnprepareLayer" - ctx, span := trace.StartSpan(ctx, title) + ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck defer span.End() defer func() { oc.SetSpanStatus(span, err) }() span.AddAttributes(trace.StringAttribute("path", path)) diff --git a/test/vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go b/test/vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go index 477fe70783..42e58403de 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go +++ b/test/vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go @@ -15,21 +15,6 @@ type OSVersion struct { Build uint16 } -// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833(v=vs.85).aspx -type osVersionInfoEx struct { - OSVersionInfoSize uint32 - MajorVersion uint32 - MinorVersion uint32 - BuildNumber uint32 - PlatformID uint32 - CSDVersion [128]uint16 - ServicePackMajor uint16 - ServicePackMinor uint16 - SuiteMask uint16 - ProductType byte - Reserve byte -} - // Get gets the operating system version on Windows. // The calling application must be manifested to get the correct version information. func Get() OSVersion { diff --git a/test/vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs_create.go b/test/vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs_create.go index b10001e4b2..20d5d402ec 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs_create.go +++ b/test/vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs_create.go @@ -97,5 +97,5 @@ func (r *Runhcs) Create(context context.Context, id, bundle string, opts *Create if err == nil && status != 0 { err = fmt.Errorf("%s did not terminate sucessfully", cmd.Args[0]) } - return nil + return err }