Skip to content

Commit

Permalink
Fixed the issue that a new output tag would not be uploaded if a cach…
Browse files Browse the repository at this point in the history
…e was found in the database during the dup convert process.

Signed-off-by: fourierrr <[email protected]>
  • Loading branch information
fourierrr committed Oct 22, 2024
1 parent 0c2f057 commit ec23730
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/convertor/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (b *graphBuilder) Build(ctx context.Context) error {
if err != nil {
return fmt.Errorf("failed to obtain new pusher: %w", err)
}
tagPusher, err := b.Resolver.Pusher(ctx, b.TargetRef) // append '@' to avoid tag
tagPusher, err := b.Resolver.Pusher(ctx, b.TargetRef)
if err != nil {
return fmt.Errorf("failed to obtain new tag pusher: %w", err)
}
Expand Down Expand Up @@ -285,6 +285,7 @@ func (b *graphBuilder) buildOne(ctx context.Context, src v1.Descriptor, tag bool
builder := &overlaybdBuilder{
layers: len(engineBase.manifest.Layers),
engine: engine,
pusher: engineBase.pusher,
}
desc, err := builder.Build(ctx)
if err != nil {
Expand Down Expand Up @@ -349,6 +350,7 @@ func Build(ctx context.Context, opt BuilderOptions) error {
type overlaybdBuilder struct {
layers int
engine builderEngine
pusher remotes.Pusher
}

// Build return a descriptor of the converted target, as the caller may need it
Expand All @@ -363,6 +365,16 @@ func (b *overlaybdBuilder) Build(ctx context.Context) (v1.Descriptor, error) {
// when errors are encountered fallback to regular conversion
if convertedDesc, err := b.engine.CheckForConvertedManifest(ctx); err == nil && convertedDesc.Digest != "" {
logrus.Infof("Image found already converted in registry with digest %s", convertedDesc.Digest)
cbuf, err := json.Marshal(convertedDesc)
if err != nil {
return v1.Descriptor{}, err
}
// ensure that output tag is pushed even if the manifest is already converted and found in registry
// only push output tag if the pusher is tagPusher
if err := uploadBytes(ctx, b.pusher, convertedDesc, cbuf); err != nil {
return v1.Descriptor{}, fmt.Errorf("failed to upload converted manifest: %w", err)
}
log.G(ctx).Infof("converted manifest uploaded, %s", convertedDesc.Digest)
return convertedDesc, nil
}

Expand Down

0 comments on commit ec23730

Please sign in to comment.