Skip to content

Commit 2e9cea4

Browse files
committed
manifest inspect: add some debug logs
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent d5ed037 commit 2e9cea4

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

cli/command/manifest/inspect.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/docker/cli/cli/command"
1212
"github.com/docker/cli/cli/manifest/types"
1313
"github.com/docker/distribution/manifest/manifestlist"
14+
"github.com/sirupsen/logrus"
1415
"github.com/spf13/cobra"
1516
)
1617

@@ -69,10 +70,12 @@ func runInspect(ctx context.Context, dockerCli command.Cli, opts inspectOptions)
6970
}
7071

7172
// Try a local manifest list first
73+
logrus.WithFields(logrus.Fields{"name": namedRef}).Debug("trying local manifest")
7274
localManifestList, err := newManifestStore(dockerCli).GetList(namedRef)
7375
if err == nil {
7476
return printManifestList(dockerCli, namedRef, localManifestList, opts)
7577
}
78+
logrus.WithFields(logrus.Fields{"name": namedRef}).Debug("trying remote manifest")
7679

7780
// Next try a remote manifest
7881
registryClient := newRegistryClient(dockerCli, opts.insecure)
@@ -82,6 +85,7 @@ func runInspect(ctx context.Context, dockerCli command.Cli, opts inspectOptions)
8285
}
8386

8487
// Finally try a remote manifest list
88+
logrus.WithFields(logrus.Fields{"name": namedRef}).Debug("trying remote manifest list")
8589
manifestList, err := registryClient.GetManifestList(ctx, namedRef)
8690
if err != nil {
8791
return err

internal/registry/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, use
6767
// Try next endpoint
6868
log.G(ctx).WithFields(log.Fields{
6969
"error": err,
70-
"endpoint": endpoint,
70+
"endpoint": endpoint.URL,
7171
}).Infof("Error logging in to endpoint, trying next endpoint")
7272
lastErr = err
7373
continue

internal/registryclient/client.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,26 +161,24 @@ func (c *client) getHTTPTransportForRepoEndpoint(ctx context.Context, repoEndpoi
161161
// GetManifest returns an ImageManifest for the reference
162162
func (c *client) GetManifest(ctx context.Context, ref reference.Named) (manifesttypes.ImageManifest, error) {
163163
var result manifesttypes.ImageManifest
164-
fetch := func(ctx context.Context, repo distribution.Repository, ref reference.Named) (bool, error) {
164+
err := c.iterateEndpoints(ctx, ref, func(fetchCtx context.Context, repo distribution.Repository, ref reference.Named) (bool, error) {
165165
var err error
166-
result, err = fetchManifest(ctx, repo, ref)
166+
logrus.WithFields(logrus.Fields{"ref": ref}).Debug("fetching manifest")
167+
result, err = fetchManifest(fetchCtx, repo, ref)
167168
return result.Ref != nil, err
168-
}
169-
170-
err := c.iterateEndpoints(ctx, ref, fetch)
169+
})
171170
return result, err
172171
}
173172

174173
// GetManifestList returns a list of ImageManifest for the reference
175174
func (c *client) GetManifestList(ctx context.Context, ref reference.Named) ([]manifesttypes.ImageManifest, error) {
176175
result := []manifesttypes.ImageManifest{}
177-
fetch := func(ctx context.Context, repo distribution.Repository, ref reference.Named) (bool, error) {
176+
err := c.iterateEndpoints(ctx, ref, func(ctx context.Context, repo distribution.Repository, ref reference.Named) (bool, error) {
178177
var err error
178+
logrus.WithFields(logrus.Fields{"ref": ref}).Debug("fetching manifest list")
179179
result, err = fetchList(ctx, repo, ref)
180180
return len(result) > 0, err
181-
}
182-
183-
err := c.iterateEndpoints(ctx, ref, fetch)
181+
})
184182
return result, err
185183
}
186184

internal/registryclient/fetcher.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ func fetchManifest(ctx context.Context, repo distribution.Repository, ref refere
3737
return pullManifestOCISchema(ctx, ref, repo, *v)
3838
case *manifestlist.DeserializedManifestList:
3939
return types.ImageManifest{}, fmt.Errorf("%s is a manifest list", ref)
40+
default:
41+
return types.ImageManifest{}, fmt.Errorf("%s is not a manifest", ref)
4042
}
41-
return types.ImageManifest{}, fmt.Errorf("%s is not a manifest", ref)
4243
}
4344

4445
func fetchList(ctx context.Context, repo distribution.Repository, ref reference.Named) ([]types.ImageManifest, error) {
@@ -163,6 +164,7 @@ func pullManifestList(ctx context.Context, ref reference.Named, repo distributio
163164
if err != nil {
164165
return nil, err
165166
}
167+
logrus.WithFields(logrus.Fields{"digest": manifestDescriptor.Digest}).Debug("pulling manifest")
166168
manifest, err := manSvc.Get(ctx, manifestDescriptor.Digest)
167169
if err != nil {
168170
return nil, err
@@ -286,7 +288,11 @@ func allEndpoints(ctx context.Context, namedRef reference.Named, insecure bool)
286288
return nil, err
287289
}
288290
endpoints, err := registryService.Endpoints(ctx, reference.Domain(namedRef))
289-
logrus.Debugf("endpoints for %s: %v", namedRef, endpoints)
291+
var epUrls []string
292+
for _, ep := range endpoints {
293+
epUrls = append(epUrls, ep.URL.String())
294+
}
295+
logrus.WithField("endpoints", epUrls).Debugf("resolved endpoints for %s", namedRef)
290296
return endpoints, err
291297
}
292298

0 commit comments

Comments
 (0)