Skip to content

Commit

Permalink
style: format cri logs
Browse files Browse the repository at this point in the history
Signed-off-by: Starnop <starnop@163.com>
  • Loading branch information
starnop committed Aug 23, 2018
1 parent dabdb55 commit e7ef62c
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 113 deletions.
2 changes: 1 addition & 1 deletion cri/criservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func RunCriService(daemonconfig *config.Config, containerMgr mgr.ContainerMgr, i
err = runv1alpha2(daemonconfig, containerMgr, imageMgr, volumeMgr, readyCh)
default:
readyCh <- false
err = fmt.Errorf("invalid CRI version,failed to start CRI service")
err = fmt.Errorf("failed to start CRI service: invalid CRI version")
}
return
}
Expand Down
108 changes: 54 additions & 54 deletions cri/v1alpha1/cri_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ func (c *CriWrapper) StreamServerStart() (err error) {
logrus.Infof("StreamServerStart starts stream server of cri manager")
defer func() {
if err != nil {
logrus.Errorf("StreamServerStart failed: %v", err)
logrus.Errorf("failed to start StreamServer: %v", err)
} else {
logrus.Infof("StreamServerStart has started stream server of cri manager")
logrus.Infof("success to start StreamServer of cri manager")
}
}()
return c.CriManager.StreamServerStart()
Expand All @@ -34,9 +34,9 @@ func (c *CriWrapper) Version(ctx context.Context, r *runtime.VersionRequest) (re
logrus.Infof("Version shows the basic information of cri Manager")
defer func() {
if err != nil {
logrus.Errorf("Version failed: %v", err)
logrus.Errorf("failed to get version: %v", err)
} else {
logrus.Infof("Version has operated successfully")
logrus.Infof("success to get version")
}
}()
return c.CriManager.Version(ctx, r)
Expand All @@ -49,9 +49,9 @@ func (c *CriWrapper) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
logrus.Infof("RunPodSandbox with config %+v", r.GetConfig())
defer func() {
if err != nil {
logrus.Errorf("RunPodSandbox for %+v failed, error: %v", r.GetConfig().GetMetadata(), err)
logrus.Errorf("failed to run PodSandbox: %+v, %v", r.GetConfig().GetMetadata(), err)
} else {
logrus.Infof("RunPodSandbox for %+v returns sandbox id %q", r.GetConfig().GetMetadata(), res.GetPodSandboxId())
logrus.Infof("success to run PodSandbox: %+v, return sandbox id: %q", r.GetConfig().GetMetadata(), res.GetPodSandboxId())
}
}()
return c.CriManager.RunPodSandbox(ctx, r)
Expand All @@ -63,9 +63,9 @@ func (c *CriWrapper) StopPodSandbox(ctx context.Context, r *runtime.StopPodSandb
logrus.Infof("StopPodSandbox for %q", r.GetPodSandboxId())
defer func() {
if err != nil {
logrus.Errorf("StopPodSandbox for %q failed, error: %v", r.GetPodSandboxId(), err)
logrus.Errorf("failed to stop PodSandbox: %q, %v", r.GetPodSandboxId(), err)
} else {
logrus.Infof("StopPodSandbox for %q returns successfully", r.GetPodSandboxId())
logrus.Infof("success to stop PodSandbox: %q", r.GetPodSandboxId())
}
}()
return c.CriManager.StopPodSandbox(ctx, r)
Expand All @@ -77,9 +77,9 @@ func (c *CriWrapper) RemovePodSandbox(ctx context.Context, r *runtime.RemovePodS
logrus.Infof("RemovePodSandbox for %q", r.GetPodSandboxId())
defer func() {
if err != nil {
logrus.Errorf("RemovePodSandbox for %q failed, error: %v", r.GetPodSandboxId(), err)
logrus.Errorf("failed to remove PodSandbox: %q, %v", r.GetPodSandboxId(), err)
} else {
logrus.Infof("RemovePodSandbox %q returns successfully", r.GetPodSandboxId())
logrus.Infof("success to remove PodSandbox: %q", r.GetPodSandboxId())
}
}()
return c.CriManager.RemovePodSandbox(ctx, r)
Expand All @@ -90,9 +90,9 @@ func (c *CriWrapper) PodSandboxStatus(ctx context.Context, r *runtime.PodSandbox
logrus.Infof("PodSandboxStatus for %q", r.GetPodSandboxId())
defer func() {
if err != nil {
logrus.Errorf("PodSandboxStatus for %q failed, error: %v", r.GetPodSandboxId(), err)
logrus.Errorf("failed to get PodSandboxStatus: %q, %v", r.GetPodSandboxId(), err)
} else {
logrus.Infof("PodSandboxStatus for %q returns status %+v", r.GetPodSandboxId(), res.GetStatus())
logrus.Infof("success to get PodSandboxStatus: %q, %+v", r.GetPodSandboxId(), res.GetStatus())
}
}()
return c.CriManager.PodSandboxStatus(ctx, r)
Expand All @@ -103,10 +103,10 @@ func (c *CriWrapper) ListPodSandbox(ctx context.Context, r *runtime.ListPodSandb
logrus.Infof("ListPodSandbox with filter %+v", r.GetFilter())
defer func() {
if err != nil {
logrus.Errorf("ListPodSandbox failed, error: %v", err)
logrus.Errorf("failed to ListPodSandbox: %v", err)
} else {
// NOTE: maybe log detailed sandbox items with higher log level.
logrus.Infof("ListPodSandbox returns sandboxes list successfully")
logrus.Infof("success to ListPodSandbox: %+v", res.Items)
}
}()
return c.CriManager.ListPodSandbox(ctx, r)
Expand All @@ -119,10 +119,10 @@ func (c *CriWrapper) CreateContainer(ctx context.Context, r *runtime.CreateConta
r.GetPodSandboxId(), r.GetConfig(), r.GetSandboxConfig())
defer func() {
if err != nil {
logrus.Errorf("CreateContainer within sandbox %q for %+v failed, error: %v",
logrus.Errorf("failed to create container within sandbox %q with container config %+v: %v",
r.GetPodSandboxId(), r.GetConfig().GetMetadata(), err)
} else {
logrus.Infof("CreateContainer within sandbox %q for %+v returns container id %q",
logrus.Infof("success to create container within sandbox %q with container config %+v, return container id %q",
r.GetPodSandboxId(), r.GetConfig().GetMetadata(), res.GetContainerId())
}
}()
Expand All @@ -134,9 +134,9 @@ func (c *CriWrapper) StartContainer(ctx context.Context, r *runtime.StartContain
logrus.Infof("StartContainer for %q", r.GetContainerId())
defer func() {
if err != nil {
logrus.Errorf("StartContainer for %q failed, error: %v", r.GetContainerId(), err)
logrus.Errorf("failed to start container: %q, %v", r.GetContainerId(), err)
} else {
logrus.Infof("StartContainer for %q returns successfully", r.GetContainerId())
logrus.Infof("success to start container: %q", r.GetContainerId())
}
}()
return c.CriManager.StartContainer(ctx, r)
Expand All @@ -147,9 +147,9 @@ func (c *CriWrapper) StopContainer(ctx context.Context, r *runtime.StopContainer
logrus.Infof("StopContainer for %q with timeout %d (s)", r.GetContainerId(), r.GetTimeout())
defer func() {
if err != nil {
logrus.Errorf("StopContainer for %q failed, error: %v", r.GetContainerId(), err)
logrus.Errorf("failed to stop container: %q, %v", r.GetContainerId(), err)
} else {
logrus.Infof("StopContainer for %q returns successfully", r.GetContainerId())
logrus.Infof("success to stop container: %q", r.GetContainerId())
}
}()
return c.CriManager.StopContainer(ctx, r)
Expand All @@ -160,9 +160,9 @@ func (c *CriWrapper) RemoveContainer(ctx context.Context, r *runtime.RemoveConta
logrus.Infof("RemoveContainer for %q", r.GetContainerId())
defer func() {
if err != nil {
logrus.Errorf("RemoveContainer for %q failed, error: %v", r.GetContainerId(), err)
logrus.Errorf("failed to remove container: %q, %v", r.GetContainerId(), err)
} else {
logrus.Infof("RemoveContainer for %q returns successfully", r.GetContainerId())
logrus.Infof("success to remove container: %q", r.GetContainerId())
}
}()
return c.CriManager.RemoveContainer(ctx, r)
Expand All @@ -173,10 +173,10 @@ func (c *CriWrapper) ListContainers(ctx context.Context, r *runtime.ListContaine
logrus.Infof("ListContainers with filter %+v", r.GetFilter())
defer func() {
if err != nil {
logrus.Errorf("ListContainers with filter %+v failed, error: %v", r.GetFilter(), err)
logrus.Errorf("failed to list containers with filter %+v: %v", r.GetFilter(), err)
} else {
// NOTE: maybe log detailed container items with higher log level.
logrus.Infof("ListContainers with filter %+v returns container list successfully", r.GetFilter())
logrus.Infof("success to list containers with filter: %+v", r.GetFilter())
}
}()
return c.CriManager.ListContainers(ctx, r)
Expand All @@ -187,9 +187,9 @@ func (c *CriWrapper) ContainerStatus(ctx context.Context, r *runtime.ContainerSt
logrus.Infof("ContainerStatus for %q", r.GetContainerId())
defer func() {
if err != nil {
logrus.Errorf("ContainerStatus for %q failed, error: %v", r.GetContainerId(), err)
logrus.Errorf("failed to get ContainerStatus: %q, %v", r.GetContainerId(), err)
} else {
logrus.Infof("ContainerStatus for %q returns status %+v", r.GetContainerId(), res.GetStatus())
logrus.Infof("success to get ContainerStatus: %q, %+v", r.GetContainerId(), res.GetStatus())
}
}()
return c.CriManager.ContainerStatus(ctx, r)
Expand All @@ -201,9 +201,9 @@ func (c *CriWrapper) ContainerStats(ctx context.Context, r *runtime.ContainerSta
logrus.Infof("ContainerStats for %q", r.GetContainerId())
defer func() {
if err != nil {
logrus.Errorf("ContainerStats for %q failed, error: %v", r.GetContainerId(), err)
logrus.Errorf("failed to get ContainerStats: %q, %v", r.GetContainerId(), err)
} else {
logrus.Infof("ContainerStats for %q returns stats %+v", r.GetContainerId(), res.GetStats())
logrus.Infof("success to get ContainerStats: %q, %+v", r.GetContainerId(), res.GetStats())
}
}()
return c.CriManager.ContainerStats(ctx, r)
Expand All @@ -214,9 +214,9 @@ func (c *CriWrapper) ListContainerStats(ctx context.Context, r *runtime.ListCont
logrus.Infof("ListContainerStats with filter %+v", r.GetFilter())
defer func() {
if err != nil {
logrus.Errorf("ListContainerStats failed, error: %v", err)
logrus.Errorf("failed to get ListContainerStats: %v", err)
} else {
logrus.Infof("ListContainerStats returns stats %+v", res.GetStats())
logrus.Infof("success to get ListContainerStats: %+v", res.GetStats())
}
}()
return c.CriManager.ListContainerStats(ctx, r)
Expand All @@ -227,9 +227,9 @@ func (c *CriWrapper) UpdateContainerResources(ctx context.Context, r *runtime.Up
logrus.Infof("UpdateContainerResources for %q with %+v", r.GetContainerId(), r.GetLinux())
defer func() {
if err != nil {
logrus.Errorf("UpdateContainerResources for %q failed", r.GetContainerId())
logrus.Errorf("failed to update ContainerResources: %q", r.GetContainerId())
} else {
logrus.Infof("UpdateContainerResources for %q returns successfully", r.GetContainerId())
logrus.Infof("success to update ContainerResources: %q", r.GetContainerId())
}
}()
return c.CriManager.UpdateContainerResources(ctx, r)
Expand All @@ -241,9 +241,9 @@ func (c *CriWrapper) ExecSync(ctx context.Context, r *runtime.ExecSyncRequest) (
logrus.Infof("ExecSync for %q with command %+v and timeout %d (s)", r.GetContainerId(), r.GetCmd(), r.GetTimeout())
defer func() {
if err != nil {
logrus.Errorf("ExecSync for %q failed, error: %v", r.GetContainerId(), err)
logrus.Errorf("failed to ExecSync: %q, %v", r.GetContainerId(), err)
} else {
logrus.Infof("ExecSync for %q returns with exit code %d", r.GetContainerId(), res.GetExitCode())
logrus.Infof("success to ExecSync %q, return with exit code %d", r.GetContainerId(), res.GetExitCode())
}
}()
return c.CriManager.ExecSync(ctx, r)
Expand All @@ -255,9 +255,9 @@ func (c *CriWrapper) Exec(ctx context.Context, r *runtime.ExecRequest) (res *run
r.GetContainerId(), r.GetCmd(), r.GetTty(), r.GetStdin())
defer func() {
if err != nil {
logrus.Errorf("Exec for %q failed, error: %v", r.GetContainerId(), err)
logrus.Errorf("failed to Exec %q, %v", r.GetContainerId(), err)
} else {
logrus.Infof("Exec for %q returns URL %q", r.GetContainerId(), res.GetUrl())
logrus.Infof("success to Exec %q, return URL %q", r.GetContainerId(), res.GetUrl())
}
}()
return c.CriManager.Exec(ctx, r)
Expand All @@ -268,9 +268,9 @@ func (c *CriWrapper) Attach(ctx context.Context, r *runtime.AttachRequest) (res
logrus.Infof("Attach for %q with tty %v and stdin %v", r.GetContainerId(), r.GetTty(), r.GetStdin())
defer func() {
if err != nil {
logrus.Errorf("Attach for %q failed, error: %v", r.GetContainerId(), err)
logrus.Errorf("failed to attach: %q, %v", r.GetContainerId(), err)
} else {
logrus.Infof("Attach for %q returns URL %q", r.GetContainerId(), res.GetUrl())
logrus.Infof("success to attach: %q, return URL %q", r.GetContainerId(), res.GetUrl())
}
}()
return c.CriManager.Attach(ctx, r)
Expand All @@ -281,9 +281,9 @@ func (c *CriWrapper) PortForward(ctx context.Context, r *runtime.PortForwardRequ
logrus.Infof("Portforward for %q port %v", r.GetPodSandboxId(), r.GetPort())
defer func() {
if err != nil {
logrus.Errorf("Portforward for %q failed, error: %v", r.GetPodSandboxId(), err)
logrus.Errorf("failed to portforward: %q, %v", r.GetPodSandboxId(), err)
} else {
logrus.Infof("Portforward for %q returns URL %q", r.GetPodSandboxId(), res.GetUrl())
logrus.Infof("success to portforward: %q, return URL %q", r.GetPodSandboxId(), res.GetUrl())
}
}()
return c.CriManager.PortForward(ctx, r)
Expand All @@ -294,9 +294,9 @@ func (c *CriWrapper) UpdateRuntimeConfig(ctx context.Context, r *runtime.UpdateR
logrus.Infof("UpdateRuntimeConfig with config %+v", r.GetRuntimeConfig())
defer func() {
if err != nil {
logrus.Errorf("UpdateRuntimeConfig failed, error: %v", err)
logrus.Errorf("failed to update RuntimeConfig: %v", err)
} else {
logrus.Infof("UpdateRuntimeConfig returns returns successfully")
logrus.Infof("success to update RuntimeConfig")
}
}()
return c.CriManager.UpdateRuntimeConfig(ctx, r)
Expand All @@ -307,9 +307,9 @@ func (c *CriWrapper) Status(ctx context.Context, r *runtime.StatusRequest) (res
logrus.Infof("Status of cri manager")
defer func() {
if err != nil {
logrus.Errorf("Status failed, error: %v", err)
logrus.Errorf("failed to get status: %v", err)
} else {
logrus.Infof("Status returns status %+v", res.GetStatus())
logrus.Infof("success to get status: %+v", res.GetStatus())
}
}()
return c.CriManager.Status(ctx, r)
Expand All @@ -320,10 +320,10 @@ func (c *CriWrapper) ListImages(ctx context.Context, r *runtime.ListImagesReques
logrus.Infof("ListImages with filter %+v", r.GetFilter())
defer func() {
if err != nil {
logrus.Errorf("ListImages with filter %+v failed, error: %v", r.GetFilter(), err)
logrus.Errorf("failed to list images with filter %+v: %v", r.GetFilter(), err)
} else {
// NOTE: maybe log detailed image items with higher log level.
logrus.Infof("ListImages with filter %+v returns image list successfully", r.GetFilter())
logrus.Infof("success to list images with filter: %+v", r.GetFilter())
}
}()
return c.CriManager.ListImages(ctx, r)
Expand All @@ -334,9 +334,9 @@ func (c *CriWrapper) ImageStatus(ctx context.Context, r *runtime.ImageStatusRequ
logrus.Infof("ImageStatus for %q", r.GetImage().GetImage())
defer func() {
if err != nil {
logrus.Errorf("ImageStatus for %q failed, error: %v", r.GetImage().GetImage(), err)
logrus.Errorf("failed to get ImageStatus: %q, %v", r.GetImage().GetImage(), err)
} else {
logrus.Infof("ImageStatus for %q returns image status %+v",
logrus.Infof("success to get ImageStatus: %q, %+v",
r.GetImage().GetImage(), res.GetImage())
}
}()
Expand All @@ -348,9 +348,9 @@ func (c *CriWrapper) PullImage(ctx context.Context, r *runtime.PullImageRequest)
logrus.Infof("PullImage %q with auth config %+v", r.GetImage().GetImage(), r.GetAuth())
defer func() {
if err != nil {
logrus.Errorf("PullImage %q failed, error: %v", r.GetImage().GetImage(), err)
logrus.Errorf("failed to pull image: %q, %v", r.GetImage().GetImage(), err)
} else {
logrus.Infof("PullImage %q returns image reference %q",
logrus.Infof("success to pull image %q, return image reference %q",
r.GetImage().GetImage(), res.GetImageRef())
}
}()
Expand All @@ -362,9 +362,9 @@ func (c *CriWrapper) RemoveImage(ctx context.Context, r *runtime.RemoveImageRequ
logrus.Infof("RemoveImage %q", r.GetImage().GetImage())
defer func() {
if err != nil {
logrus.Errorf("RemoveImage %q failed, error: %v", r.GetImage().GetImage(), err)
logrus.Errorf("failed to remove image: %q, %v", r.GetImage().GetImage(), err)
} else {
logrus.Infof("RemoveImage %q returns successfully", r.GetImage().GetImage())
logrus.Infof("success to remove image: %q", r.GetImage().GetImage())
}
}()
return c.CriManager.RemoveImage(ctx, r)
Expand All @@ -375,9 +375,9 @@ func (c *CriWrapper) ImageFsInfo(ctx context.Context, r *runtime.ImageFsInfoRequ
logrus.Infof("ImageFsInfo of cri manager")
defer func() {
if err != nil {
logrus.Errorf("ImageFsInfo failed, error: %v", err)
logrus.Errorf("faild to get ImageFsInfo: %v", err)
} else {
logrus.Infof("ImageFsInfo returns filesystem info %+v", res.GetImageFilesystems())
logrus.Infof("success to get ImageFsInfo, return filesystem info %+v", res.GetImageFilesystems())
}
}()
return c.CriManager.ImageFsInfo(ctx, r)
Expand Down
Loading

0 comments on commit e7ef62c

Please sign in to comment.