From 20302cb65d959e5ee966c69926753bb73c8242be Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Sat, 20 Jul 2019 06:06:55 -0400 Subject: Cleanup Pull Message Currently the pull message on failure is UGLY. This patch removes a lot of the noice when pulling an image from multiple registries to make the user experience better. Our current messages are way too verbose and need to be dampened down. Still has verbose mode if you turn on log-level=debug. Signed-off-by: Daniel J Walsh --- libpod/image/pull.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libpod/image') diff --git a/libpod/image/pull.go b/libpod/image/pull.go index 2f1d1e912..78cfe3626 100644 --- a/libpod/image/pull.go +++ b/libpod/image/pull.go @@ -240,6 +240,12 @@ func (ir *Runtime) pullImageFromReference(ctx context.Context, srcRef types.Imag return ir.doPullImage(ctx, sc, *goal, writer, signingOptions, dockerOptions, nil) } +func cleanErrorMessage(err error) string { + errMessage := strings.TrimPrefix(errors.Cause(err).Error(), "errors:\n") + errMessage = strings.Split(errMessage, "\n")[0] + return fmt.Sprintf(" %s\n", errMessage) +} + // doPullImage is an internal helper interpreting pullGoal. Almost everyone should call one of the callers of doPullImage instead. func (ir *Runtime) doPullImage(ctx context.Context, sc *types.SystemContext, goal pullGoal, writer io.Writer, signingOptions SigningOptions, dockerOptions *DockerRegistryOptions, label *string) ([]string, error) { span, _ := opentracing.StartSpanFromContext(ctx, "doPullImage") @@ -281,9 +287,9 @@ func (ir *Runtime) doPullImage(ctx context.Context, sc *types.SystemContext, goa _, err = cp.Image(ctx, policyContext, imageInfo.dstRef, imageInfo.srcRef, copyOptions) if err != nil { pullErrors = multierror.Append(pullErrors, err) - logrus.Errorf("Error pulling image ref %s: %v", imageInfo.srcRef.StringWithinTransport(), err) + logrus.Debugf("Error pulling image ref %s: %v", imageInfo.srcRef.StringWithinTransport(), err) if writer != nil { - _, _ = io.WriteString(writer, "Failed\n") + _, _ = io.WriteString(writer, cleanErrorMessage(err)) } } else { if !goal.pullAllPairs { -- cgit v1.2.3-54-g00ecf