diff --git a/oci/oci.go b/oci/oci.go index 5faf90c7..ff19d59e 100644 --- a/oci/oci.go +++ b/oci/oci.go @@ -149,7 +149,7 @@ func (r *Runtime) CreateContainer(c *Container, cgroupParent string) error { if cgroupParent != "" { if r.cgroupManager == "systemd" { logrus.Infof("Running conmon under slice %s and unitName %s", cgroupParent, createUnitName("ocid", c.name)) - if err := utils.RunUnderSystemdScope(cmd.Process.Pid, cgroupParent, createUnitName("ocid", c.name)); err != nil { + if err = utils.RunUnderSystemdScope(cmd.Process.Pid, cgroupParent, createUnitName("ocid", c.name)); err != nil { logrus.Warnf("Failed to add conmon to sandbox cgroup: %v", err) } } diff --git a/server/container_list.go b/server/container_list.go index fee3219d..ce6171db 100644 --- a/server/container_list.go +++ b/server/container_list.go @@ -80,7 +80,7 @@ func (s *Server) ListContainers(ctx context.Context, req *pb.ListContainersReque c := &pb.Container{ Id: cID, PodSandboxId: podSandboxID, - CreatedAt: int64(created), + CreatedAt: created, Labels: ctr.Labels(), Metadata: ctr.Metadata(), Annotations: ctr.Annotations(), diff --git a/server/container_status.go b/server/container_status.go index 4d3dd4bf..6e4d9312 100644 --- a/server/container_status.go +++ b/server/container_status.go @@ -44,22 +44,22 @@ func (s *Server) ContainerStatus(ctx context.Context, req *pb.ContainerStatusReq case oci.ContainerStateCreated: rStatus = pb.ContainerState_CONTAINER_CREATED created := cState.Created.UnixNano() - resp.Status.CreatedAt = int64(created) + resp.Status.CreatedAt = created case oci.ContainerStateRunning: rStatus = pb.ContainerState_CONTAINER_RUNNING created := cState.Created.UnixNano() - resp.Status.CreatedAt = int64(created) + resp.Status.CreatedAt = created started := cState.Started.UnixNano() - resp.Status.StartedAt = int64(started) + resp.Status.StartedAt = started case oci.ContainerStateStopped: rStatus = pb.ContainerState_CONTAINER_EXITED created := cState.Created.UnixNano() - resp.Status.CreatedAt = int64(created) + resp.Status.CreatedAt = created started := cState.Started.UnixNano() - resp.Status.StartedAt = int64(started) + resp.Status.StartedAt = started finished := cState.Finished.UnixNano() - resp.Status.FinishedAt = int64(finished) - resp.Status.ExitCode = int32(cState.ExitCode) + resp.Status.FinishedAt = finished + resp.Status.ExitCode = cState.ExitCode } resp.Status.State = rStatus diff --git a/server/sandbox.go b/server/sandbox.go index 8ed20b64..b1c9eede 100644 --- a/server/sandbox.go +++ b/server/sandbox.go @@ -201,8 +201,8 @@ func (s *sandbox) netNsCreate() error { if err := s.netns.symlinkCreate(s.name); err != nil { logrus.Warnf("Could not create nentns symlink %v", err) - if err := s.netns.ns.Close(); err != nil { - return err + if err1 := s.netns.ns.Close(); err1 != nil { + return err1 } return err diff --git a/server/sandbox_list.go b/server/sandbox_list.go index 51ec1d25..b45220cb 100644 --- a/server/sandbox_list.go +++ b/server/sandbox_list.go @@ -72,7 +72,7 @@ func (s *Server) ListPodSandbox(ctx context.Context, req *pb.ListPodSandboxReque pod := &pb.PodSandbox{ Id: sb.id, - CreatedAt: int64(created), + CreatedAt: created, State: rStatus, Labels: sb.labels, Annotations: sb.annotations, diff --git a/server/sandbox_run.go b/server/sandbox_run.go index 9d8f606a..00063984 100644 --- a/server/sandbox_run.go +++ b/server/sandbox_run.go @@ -407,11 +407,7 @@ func (s *Server) setPodSandboxMountLabel(id, mountLabel string) error { return err } storageMetadata.SetMountLabel(mountLabel) - err = s.storage.SetContainerMetadata(id, storageMetadata) - if err != nil { - return err - } - return nil + return s.storage.SetContainerMetadata(id, storageMetadata) } func getSELinuxLabels(selinuxOptions *pb.SELinuxOption) (processLabel string, mountLabel string, err error) { diff --git a/server/sandbox_status.go b/server/sandbox_status.go index 40943e47..ea16802d 100644 --- a/server/sandbox_status.go +++ b/server/sandbox_status.go @@ -44,7 +44,7 @@ func (s *Server) PodSandboxStatus(ctx context.Context, req *pb.PodSandboxStatusR resp := &pb.PodSandboxStatusResponse{ Status: &pb.PodSandboxStatus{ Id: sandboxID, - CreatedAt: int64(created), + CreatedAt: created, Linux: &pb.LinuxPodSandboxStatus{ Namespaces: &pb.Namespace{ Network: netNsPath, diff --git a/server/server.go b/server/server.go index 69eaad7e..6e67e476 100644 --- a/server/server.go +++ b/server/server.go @@ -113,10 +113,7 @@ func (s *Server) loadContainer(id string) error { return fmt.Errorf("error updating status for container %s: %v", ctr.ID(), err) } s.addContainer(ctr) - if err = s.ctrIDIndex.Add(id); err != nil { - return err - } - return nil + return s.ctrIDIndex.Add(id) } func configNetNsPath(spec rspec.Spec) (string, error) { diff --git a/test/copyimg/copyimg.go b/test/copyimg/copyimg.go index aa260521..6d5d4c36 100644 --- a/test/copyimg/copyimg.go +++ b/test/copyimg/copyimg.go @@ -110,7 +110,9 @@ func main() { logrus.Errorf("error opening storage: %v", err) os.Exit(1) } - defer store.Shutdown(false) + defer func() { + _, _ = store.Shutdown(false) + }() storage.Transport.SetStore(store) ref, err = storage.Transport.ParseStoreReference(store, imageName) @@ -133,7 +135,9 @@ func main() { logrus.Errorf("error loading signature policy: %v", err) os.Exit(1) } - defer policyContext.Destroy() + defer func() { + _ = policyContext.Destroy() + }() options := ©.Options{} if importFrom != "" { @@ -161,9 +165,9 @@ func main() { } } if addName != "" { - destImage, err := storage.Transport.GetStoreImage(store, ref) - if err != nil { - logrus.Errorf("error finding image: %v", err) + destImage, err1 := storage.Transport.GetStoreImage(store, ref) + if err1 != nil { + logrus.Errorf("error finding image: %v", err1) os.Exit(1) } names := append(destImage.Names, imageName, addName)