Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions internal/cri/instrument/instrumented_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,6 @@ func (in *instrumentedService) PullImage(ctx context.Context, r *runtime.PullIma
log.G(ctx).Infof("PullImage %q", r.GetImage().GetImage())
defer func() {
if err != nil {
// Sanitize error to remove sensitive information
err = ctrdutil.SanitizeError(err)
log.G(ctx).WithError(err).Errorf("PullImage %q failed", r.GetImage().GetImage())
} else {
log.G(ctx).Infof("PullImage %q returns image reference %q",
Expand All @@ -364,6 +362,10 @@ func (in *instrumentedService) PullImage(ctx context.Context, r *runtime.PullIma
span.RecordError(err)
}()
res, err = in.c.PullImage(ctrdutil.WithNamespace(ctx), r)
// Sanitize error to remove sensitive information from both logs and returned gRPC error
if err != nil {
err = ctrdutil.SanitizeError(err)
}
return res, errgrpc.ToGRPC(err)
}

Expand All @@ -374,15 +376,17 @@ func (in *instrumentedService) ListImages(ctx context.Context, r *runtime.ListIm
log.G(ctx).Tracef("ListImages with filter %+v", r.GetFilter())
defer func() {
if err != nil {
// Sanitize error to remove sensitive information
err = ctrdutil.SanitizeError(err)
log.G(ctx).WithError(err).Errorf("ListImages with filter %+v failed", r.GetFilter())
} else {
log.G(ctx).Tracef("ListImages with filter %+v returns image list %+v",
r.GetFilter(), res.GetImages())
}
}()
res, err = in.c.ListImages(ctrdutil.WithNamespace(ctx), r)
// Sanitize error to remove sensitive information from both logs and returned gRPC error
if err != nil {
err = ctrdutil.SanitizeError(err)
}
return res, errgrpc.ToGRPC(err)
}

Expand All @@ -393,15 +397,17 @@ func (in *instrumentedService) ImageStatus(ctx context.Context, r *runtime.Image
log.G(ctx).Tracef("ImageStatus for %q", r.GetImage().GetImage())
defer func() {
if err != nil {
// Sanitize error to remove sensitive information
err = ctrdutil.SanitizeError(err)
log.G(ctx).WithError(err).Errorf("ImageStatus for %q failed", r.GetImage().GetImage())
} else {
log.G(ctx).Tracef("ImageStatus for %q returns image status %+v",
r.GetImage().GetImage(), res.GetImage())
}
}()
res, err = in.c.ImageStatus(ctrdutil.WithNamespace(ctx), r)
// Sanitize error to remove sensitive information from both logs and returned gRPC error
if err != nil {
err = ctrdutil.SanitizeError(err)
}
return res, errgrpc.ToGRPC(err)
}

Expand All @@ -413,15 +419,17 @@ func (in *instrumentedService) RemoveImage(ctx context.Context, r *runtime.Remov
log.G(ctx).Infof("RemoveImage %q", r.GetImage().GetImage())
defer func() {
if err != nil {
// Sanitize error to remove sensitive information
err = ctrdutil.SanitizeError(err)
log.G(ctx).WithError(err).Errorf("RemoveImage %q failed", r.GetImage().GetImage())
} else {
log.G(ctx).Infof("RemoveImage %q returns successfully", r.GetImage().GetImage())
}
span.RecordError(err)
}()
res, err := in.c.RemoveImage(ctrdutil.WithNamespace(ctx), r)
// Sanitize error to remove sensitive information from both logs and returned gRPC error
if err != nil {
err = ctrdutil.SanitizeError(err)
}
return res, errgrpc.ToGRPC(err)
}

Expand Down
Loading