Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the issue that a new output tag would not be uploaded if a cach… #311

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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
// push output tag only 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
Loading