Skip to content

Commit

Permalink
refactor: refact daemon log
Browse files Browse the repository at this point in the history
Change the log level of all the "Get" method from "Info" to "Debug".
Add the log to show set the disk quota information.

Signed-off-by: Rudy Zhang <[email protected]>
  • Loading branch information
rudyfly authored and fuweid committed Oct 23, 2018
1 parent 555e253 commit fb0d5e3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cri/v1alpha1/cri.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ func (c *CriManager) ListContainerStats(ctx context.Context, r *runtime.ListCont
for _, container := range containers {
cs, err := c.getContainerMetrics(ctx, container)
if err != nil {
logrus.Errorf("failed to decode metrics of container %q: %v", container.ID, err)
logrus.Warnf("failed to decode metrics of container %q: %v", container.ID, err)
continue
}

Expand Down
24 changes: 12 additions & 12 deletions cri/v1alpha1/cri_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ func (c *CriWrapper) RemovePodSandbox(ctx context.Context, r *runtime.RemovePodS

// PodSandboxStatus returns the status of the PodSandbox.
func (c *CriWrapper) PodSandboxStatus(ctx context.Context, r *runtime.PodSandboxStatusRequest) (res *runtime.PodSandboxStatusResponse, err error) {
logrus.Infof("PodSandboxStatus for %q", r.GetPodSandboxId())
logrus.Debugf("PodSandboxStatus for %q", r.GetPodSandboxId())
defer func() {
if err != nil {
logrus.Errorf("failed to get PodSandboxStatus: %q, %v", r.GetPodSandboxId(), err)
} else {
logrus.Infof("success to get PodSandboxStatus: %q, %+v", r.GetPodSandboxId(), res.GetStatus())
logrus.Debugf("success to get PodSandboxStatus: %q, %+v", r.GetPodSandboxId(), res.GetStatus())
}
}()
return c.CriManager.PodSandboxStatus(ctx, r)
Expand Down Expand Up @@ -191,12 +191,12 @@ func (c *CriWrapper) ListContainers(ctx context.Context, r *runtime.ListContaine

// ContainerStatus inspects the container and returns the status.
func (c *CriWrapper) ContainerStatus(ctx context.Context, r *runtime.ContainerStatusRequest) (res *runtime.ContainerStatusResponse, err error) {
logrus.Infof("ContainerStatus for %q", r.GetContainerId())
logrus.Debugf("ContainerStatus for %q", r.GetContainerId())
defer func() {
if err != nil {
logrus.Errorf("failed to get ContainerStatus: %q, %v", r.GetContainerId(), err)
} else {
logrus.Infof("success to get ContainerStatus: %q, %+v", r.GetContainerId(), res.GetStatus())
logrus.Debugf("success to get ContainerStatus: %q, %+v", r.GetContainerId(), res.GetStatus())
}
}()
return c.CriManager.ContainerStatus(ctx, r)
Expand All @@ -205,12 +205,12 @@ func (c *CriWrapper) ContainerStatus(ctx context.Context, r *runtime.ContainerSt
// ContainerStats returns stats of the container. If the container does not
// exist, the call returns an error.
func (c *CriWrapper) ContainerStats(ctx context.Context, r *runtime.ContainerStatsRequest) (res *runtime.ContainerStatsResponse, err error) {
logrus.Infof("ContainerStats for %q", r.GetContainerId())
logrus.Debugf("ContainerStats for %q", r.GetContainerId())
defer func() {
if err != nil {
logrus.Errorf("failed to get ContainerStats: %q, %v", r.GetContainerId(), err)
} else {
logrus.Infof("success to get ContainerStats: %q, %+v", r.GetContainerId(), res.GetStats())
logrus.Debugf("success to get ContainerStats: %q, %+v", r.GetContainerId(), res.GetStats())
}
}()
return c.CriManager.ContainerStats(ctx, r)
Expand Down Expand Up @@ -311,12 +311,12 @@ func (c *CriWrapper) UpdateRuntimeConfig(ctx context.Context, r *runtime.UpdateR

// Status returns the status of the runtime.
func (c *CriWrapper) Status(ctx context.Context, r *runtime.StatusRequest) (res *runtime.StatusResponse, err error) {
logrus.Infof("Status of cri manager")
logrus.Debugf("Status of cri manager")
defer func() {
if err != nil {
logrus.Errorf("failed to get status: %v", err)
} else {
logrus.Infof("success to get status: %+v", res.GetStatus())
logrus.Debugf("success to get status: %+v", res.GetStatus())
}
}()
return c.CriManager.Status(ctx, r)
Expand All @@ -338,12 +338,12 @@ func (c *CriWrapper) ListImages(ctx context.Context, r *runtime.ListImagesReques

// ImageStatus returns the status of the image, returns nil if the image isn't present.
func (c *CriWrapper) ImageStatus(ctx context.Context, r *runtime.ImageStatusRequest) (res *runtime.ImageStatusResponse, err error) {
logrus.Infof("ImageStatus for %q", r.GetImage().GetImage())
logrus.Debugf("ImageStatus for %q", r.GetImage().GetImage())
defer func() {
if err != nil {
logrus.Errorf("failed to get ImageStatus: %q, %v", r.GetImage().GetImage(), err)
} else {
logrus.Infof("success to get ImageStatus: %q, %+v",
logrus.Debugf("success to get ImageStatus: %q, %+v",
r.GetImage().GetImage(), res.GetImage())
}
}()
Expand Down Expand Up @@ -379,12 +379,12 @@ func (c *CriWrapper) RemoveImage(ctx context.Context, r *runtime.RemoveImageRequ

// ImageFsInfo returns information of the filesystem that is used to store images.
func (c *CriWrapper) ImageFsInfo(ctx context.Context, r *runtime.ImageFsInfoRequest) (res *runtime.ImageFsInfoResponse, err error) {
logrus.Infof("ImageFsInfo of cri manager")
logrus.Debugf("ImageFsInfo of cri manager")
defer func() {
if err != nil {
logrus.Errorf("faild to get ImageFsInfo: %v", err)
} else {
logrus.Infof("success to get ImageFsInfo, return filesystem info %+v", res.GetImageFilesystems())
logrus.Debugf("success to get ImageFsInfo, return filesystem info %+v", res.GetImageFilesystems())
}
}()
return c.CriManager.ImageFsInfo(ctx, r)
Expand Down
24 changes: 12 additions & 12 deletions cri/v1alpha2/cri_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ func (c *CriWrapper) RemovePodSandbox(ctx context.Context, r *runtime.RemovePodS

// PodSandboxStatus returns the status of the PodSandbox.
func (c *CriWrapper) PodSandboxStatus(ctx context.Context, r *runtime.PodSandboxStatusRequest) (res *runtime.PodSandboxStatusResponse, err error) {
logrus.Infof("PodSandboxStatus for %q", r.GetPodSandboxId())
logrus.Debugf("PodSandboxStatus for %q", r.GetPodSandboxId())
defer func() {
if err != nil {
logrus.Errorf("failed to get PodSandboxStatus: %q, %v", r.GetPodSandboxId(), err)
} else {
logrus.Infof("success to get PodSandboxStatus: %q, %+v", r.GetPodSandboxId(), res.GetStatus())
logrus.Debugf("success to get PodSandboxStatus: %q, %+v", r.GetPodSandboxId(), res.GetStatus())
}
}()
return c.CriManager.PodSandboxStatus(ctx, r)
Expand Down Expand Up @@ -206,12 +206,12 @@ func (c *CriWrapper) ListContainers(ctx context.Context, r *runtime.ListContaine

// ContainerStatus inspects the container and returns the status.
func (c *CriWrapper) ContainerStatus(ctx context.Context, r *runtime.ContainerStatusRequest) (res *runtime.ContainerStatusResponse, err error) {
logrus.Infof("ContainerStatus for %q", r.GetContainerId())
logrus.Debugf("ContainerStatus for %q", r.GetContainerId())
defer func() {
if err != nil {
logrus.Warnf("failed to get ContainerStatus: %q, %v", r.GetContainerId(), err)
} else {
logrus.Infof("success to get ContainerStatus: %q, %+v", r.GetContainerId(), res.GetStatus())
logrus.Debugf("success to get ContainerStatus: %q, %+v", r.GetContainerId(), res.GetStatus())
}
}()
return c.CriManager.ContainerStatus(ctx, r)
Expand All @@ -220,12 +220,12 @@ func (c *CriWrapper) ContainerStatus(ctx context.Context, r *runtime.ContainerSt
// ContainerStats returns stats of the container. If the container does not
// exist, the call returns an error.
func (c *CriWrapper) ContainerStats(ctx context.Context, r *runtime.ContainerStatsRequest) (res *runtime.ContainerStatsResponse, err error) {
logrus.Infof("ContainerStats for %q", r.GetContainerId())
logrus.Debugf("ContainerStats for %q", r.GetContainerId())
defer func() {
if err != nil {
logrus.Errorf("failed to get ContainerStats: %q, %v", r.GetContainerId(), err)
} else {
logrus.Infof("success to get ContainerStats: %q, %+v", r.GetContainerId(), res.GetStats())
logrus.Debugf("success to get ContainerStats: %q, %+v", r.GetContainerId(), res.GetStats())
}
}()
return c.CriManager.ContainerStats(ctx, r)
Expand Down Expand Up @@ -343,12 +343,12 @@ func (c *CriWrapper) UpdateRuntimeConfig(ctx context.Context, r *runtime.UpdateR

// Status returns the status of the runtime.
func (c *CriWrapper) Status(ctx context.Context, r *runtime.StatusRequest) (res *runtime.StatusResponse, err error) {
logrus.Infof("Status of cri manager")
logrus.Debugf("Status of cri manager")
defer func() {
if err != nil {
logrus.Errorf("failed to get status: %v", err)
} else {
logrus.Infof("success to get status: %+v", res.GetStatus())
logrus.Debugf("success to get status: %+v", res.GetStatus())
}
}()
return c.CriManager.Status(ctx, r)
Expand All @@ -370,12 +370,12 @@ func (c *CriWrapper) ListImages(ctx context.Context, r *runtime.ListImagesReques

// ImageStatus returns the status of the image, returns nil if the image isn't present.
func (c *CriWrapper) ImageStatus(ctx context.Context, r *runtime.ImageStatusRequest) (res *runtime.ImageStatusResponse, err error) {
logrus.Infof("ImageStatus for %q", r.GetImage().GetImage())
logrus.Debugf("ImageStatus for %q", r.GetImage().GetImage())
defer func() {
if err != nil {
logrus.Errorf("failed to get ImageStatus: %q, %v", r.GetImage().GetImage(), err)
} else {
logrus.Infof("success to get ImageStatus: %q, %+v",
logrus.Debugf("success to get ImageStatus: %q, %+v",
r.GetImage().GetImage(), res.GetImage())
}
}()
Expand Down Expand Up @@ -411,12 +411,12 @@ func (c *CriWrapper) RemoveImage(ctx context.Context, r *runtime.RemoveImageRequ

// ImageFsInfo returns information of the filesystem that is used to store images.
func (c *CriWrapper) ImageFsInfo(ctx context.Context, r *runtime.ImageFsInfoRequest) (res *runtime.ImageFsInfoResponse, err error) {
logrus.Infof("ImageFsInfo of cri manager")
logrus.Debugf("ImageFsInfo of cri manager")
defer func() {
if err != nil {
logrus.Errorf("faild to get ImageFsInfo: %v", err)
} else {
logrus.Infof("success to get ImageFsInfo, return filesystem info %+v", res.GetImageFilesystems())
logrus.Debugf("success to get ImageFsInfo, return filesystem info %+v", res.GetImageFilesystems())
}
}()
return c.CriManager.ImageFsInfo(ctx, r)
Expand Down
1 change: 1 addition & 0 deletions storage/quota/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func SetSubtree(dir string, qid uint32) (uint32, error) {

// SetDiskQuota is used to set quota for directory.
func SetDiskQuota(dir string, size string, quotaID uint32) error {
logrus.Infof("set disk quota, dir: (%s), size: (%s), quotaID: (%d)", dir, size, quotaID)
return GQuotaDriver.SetDiskQuota(dir, size, quotaID)
}

Expand Down

0 comments on commit fb0d5e3

Please sign in to comment.