Skip to content
Merged
Show file tree
Hide file tree
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
22 changes: 11 additions & 11 deletions cmd/convertor/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (b *graphBuilder) Build(ctx context.Context) error {
if err != nil {
return fmt.Errorf("failed to build %q: %w", src.Digest, err)
}
log.G(gctx).Infof("converted to %q, digest: %q", b.TargetRef, target.Digest)
log.G(gctx).Debugf("converted to %q, digest: %q", b.TargetRef, target.Digest)
return nil
})
return g.Wait()
Expand All @@ -141,7 +141,7 @@ func (b *graphBuilder) process(ctx context.Context, src v1.Descriptor, tag bool)
if src.Platform != nil && src.Platform.OS == "unknown" && src.Platform.Architecture == "unknown" {
// This might be a provenance manifest, check if it should be skipped
if utils.IsProvenanceDescriptor(src) {
log.G(ctx).Infof("skipping provenance manifest: %s (platform: %s/%s)", src.Digest, src.Platform.OS, src.Platform.Architecture)
log.G(ctx).Debugf("skipping provenance manifest: %s (platform: %s/%s)", src.Digest, src.Platform.OS, src.Platform.Architecture)
// Return a special "skipped" descriptor instead of an error
return v1.Descriptor{}, nil
}
Expand Down Expand Up @@ -229,7 +229,7 @@ func (b *graphBuilder) process(ctx context.Context, src v1.Descriptor, tag bool)
if err := uploadBytesWithRetry(ctx, pusher, expected, indexBytes, b.RetryCount); err != nil {
return v1.Descriptor{}, fmt.Errorf("failed to upload index: %w", err)
}
log.G(ctx).Infof("index uploaded, %s", expected.Digest)
log.G(ctx).Debugf("index uploaded, %s", expected.Digest)
return expected, nil
default:
return v1.Descriptor{}, fmt.Errorf("unsupported media type %q", src.MediaType)
Expand Down Expand Up @@ -262,7 +262,7 @@ func (b *graphBuilder) buildOne(ctx context.Context, src v1.Descriptor, tag bool
ctx = log.WithLogger(ctx, log.G(ctx).WithField("platform", platform))
}
workdir := filepath.Join(b.WorkDir, fmt.Sprintf("%d-%s-%s", id, strings.ReplaceAll(platform, "/", "_"), src.Digest.Encoded()))
log.G(ctx).Infof("building %s ...", workdir)
log.G(ctx).Debugf("building %s ...", workdir)

// init build engine
manifest, config, err := fetchManifestAndConfig(ctx, b.fetcher, src)
Expand Down Expand Up @@ -335,10 +335,10 @@ func Build(ctx context.Context, opt BuilderOptions) error {

// Use custom resolver if provided, otherwise create default docker resolver
if opt.CustomResolver != nil {
log.G(ctx).Info("using custom resolver (tar import mode)")
log.G(ctx).Debug("using custom resolver (tar import mode)")
resolver = opt.CustomResolver
} else {
log.G(ctx).Info("using docker registry resolver")
log.G(ctx).Debug("using docker registry resolver")
tlsConfig, err := loadTLSConfig(opt.CertOption)
if err != nil {
return fmt.Errorf("failed to load certifications: %w", err)
Expand Down Expand Up @@ -403,7 +403,7 @@ func (b *overlaybdBuilder) Build(ctx context.Context) (v1.Descriptor, error) {
// check if manifest conversion result is already present in registry, if so, we can avoid conversion.
// 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)
logrus.Debugf("Image found already converted in registry with digest %s", convertedDesc.Digest)
// Even if the image has been found we still need to make sure the requested tag is set
// fetch the manifest then push again with the requested tag
if err := b.engine.TagPreviouslyConvertedManifest(ctx, convertedDesc); err != nil {
Expand Down Expand Up @@ -453,7 +453,7 @@ func (b *overlaybdBuilder) Build(ctx context.Context) (v1.Descriptor, error) {
// download the converted layer
err := b.engine.DownloadConvertedLayer(rctx, idx, *cachedLayer)
if err == nil {
logrus.Infof("downloaded cached layer %d", idx)
logrus.Debugf("downloaded cached layer %d", idx)
sendToChannel(rctx, downloaded[idx], nil)
return nil
}
Expand All @@ -463,7 +463,7 @@ func (b *overlaybdBuilder) Build(ctx context.Context) (v1.Descriptor, error) {
if err := b.engine.DownloadLayer(rctx, idx); err != nil {
return err
}
logrus.Infof("downloaded layer %d", idx)
logrus.Debugf("downloaded layer %d", idx)
sendToChannel(rctx, downloaded[idx], nil)
return nil
})
Expand All @@ -482,7 +482,7 @@ func (b *overlaybdBuilder) Build(ctx context.Context) (v1.Descriptor, error) {
if err := b.engine.BuildLayer(rctx, idx); err != nil {
return fmt.Errorf("failed to convert layer %d: %w", idx, err)
}
logrus.Infof("layer %d converted", idx)
logrus.Debugf("layer %d converted", idx)
// send to upload(idx) and convert(idx+1) once each
sendToChannel(rctx, converted[idx], nil)
if idx+1 < b.layers {
Expand All @@ -499,7 +499,7 @@ func (b *overlaybdBuilder) Build(ctx context.Context) (v1.Descriptor, error) {
return fmt.Errorf("failed to upload layer %d: %w", idx, err)
}
b.engine.StoreConvertedLayerDetails(rctx, idx)
logrus.Infof("layer %d uploaded", idx)
logrus.Debugf("layer %d uploaded", idx)
return nil
})
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/convertor/builder/builder_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func fetch(ctx context.Context, fetcher remotes.Fetcher, desc specs.Descriptor,

func fetchManifest(ctx context.Context, fetcher remotes.Fetcher, desc specs.Descriptor) (*specs.Manifest, error) {
platformMatcher := platforms.Default()
log.G(ctx).Infof("fetching manifest %v with type %v", desc.Digest, desc.MediaType)
log.G(ctx).Debugf("fetching manifest %v with type %v", desc.Digest, desc.MediaType)
switch desc.MediaType {
case images.MediaTypeDockerSchema2Manifest, specs.MediaTypeImageManifest:
manifest := specs.Manifest{}
Expand Down Expand Up @@ -279,7 +279,7 @@ func uploadBlobWithRetry(ctx context.Context, pusher remotes.Pusher, path string
cw, err := pusher.Push(ctx, desc)
if err != nil {
if errdefs.IsAlreadyExists(err) {
logrus.Infof("layer %s exists", desc.Digest.String())
logrus.Debugf("layer %s exists", desc.Digest.String())
return nil
}
return err
Expand Down
34 changes: 17 additions & 17 deletions cmd/convertor/builder/content_store_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,47 +113,47 @@ func NewContentStoreResolverFromTar(ctx context.Context, tarPath string) (*Conte
}

// Store image references (skip provenance layers)
log.G(ctx).Infof("processing %d manifests from index", len(index.Manifests))
log.G(ctx).Debugf("processing %d manifests from index", len(index.Manifests))
for i, manifest := range index.Manifests {
log.G(ctx).Infof("=== Processing manifest %d/%d ===", i+1, len(index.Manifests))
log.G(ctx).Infof(" MediaType: %s", manifest.MediaType)
log.G(ctx).Infof(" Digest: %s", manifest.Digest)
log.G(ctx).Infof(" Size: %d bytes", manifest.Size)
log.G(ctx).Debugf("=== Processing manifest %d/%d ===", i+1, len(index.Manifests))
log.G(ctx).Debugf(" MediaType: %s", manifest.MediaType)
log.G(ctx).Debugf(" Digest: %s", manifest.Digest)
log.G(ctx).Debugf(" Size: %d bytes", manifest.Size)

if manifest.Platform != nil {
log.G(ctx).Infof(" Platform: %s/%s", manifest.Platform.OS, manifest.Platform.Architecture)
log.G(ctx).Debugf(" Platform: %s/%s", manifest.Platform.OS, manifest.Platform.Architecture)
if manifest.Platform.Variant != "" {
log.G(ctx).Infof(" Platform Variant: %s", manifest.Platform.Variant)
log.G(ctx).Debugf(" Platform Variant: %s", manifest.Platform.Variant)
}
}

if manifest.ArtifactType != "" {
log.G(ctx).Infof(" ArtifactType: %s", manifest.ArtifactType)
log.G(ctx).Debugf(" ArtifactType: %s", manifest.ArtifactType)
}

if manifest.Annotations != nil && len(manifest.Annotations) > 0 {
log.G(ctx).Infof(" Annotations:")
log.G(ctx).Debugf(" Annotations:")
for key, value := range manifest.Annotations {
log.G(ctx).Infof(" %s: %s", key, value)
log.G(ctx).Debugf(" %s: %s", key, value)
}
}

// Skip provenance and attestation manifests
if isProvenanceManifestWithContent(ctx, store, manifest) {
log.G(ctx).Infof(" ❌ SKIPPING: Detected as provenance/attestation manifest")
log.G(ctx).Debugf(" ❌ SKIPPING: Detected as provenance/attestation manifest")
continue
}

// Check if this is an image index (multi-arch)
if manifest.MediaType == v1.MediaTypeImageIndex || manifest.MediaType == "application/vnd.docker.distribution.manifest.list.v2+json" {
log.G(ctx).Infof(" 📁 FOUND IMAGE INDEX: Importing as-is for multi-arch conversion")
log.G(ctx).Debugf(" 📁 FOUND IMAGE INDEX: Importing as-is for multi-arch conversion")

// Import the index itself - let the builder handle platform traversal
ref := fmt.Sprintf("imported:%s", manifest.Digest.Encoded()[:12])
if manifest.Annotations != nil {
if name, ok := manifest.Annotations["org.opencontainers.image.ref.name"]; ok {
ref = name
log.G(ctx).Infof(" Using annotation-based ref: %s", ref)
log.G(ctx).Debugf(" Using annotation-based ref: %s", ref)
}
}

Expand All @@ -162,18 +162,18 @@ func NewContentStoreResolverFromTar(ctx context.Context, tarPath string) (*Conte
Target: manifest,
}
imageStore.Create(ctx, image)
log.G(ctx).Infof(" ✅ IMPORTED INDEX: %s -> %s (will be processed as multi-arch)", ref, manifest.Digest)
log.G(ctx).Debugf(" ✅ IMPORTED INDEX: %s -> %s (will be processed as multi-arch)", ref, manifest.Digest)
continue
}

log.G(ctx).Infof(" ✅ PROCESSING: Regular container manifest")
log.G(ctx).Debugf(" ✅ PROCESSING: Regular container manifest")

// Generate a reference name for the imported image
ref := fmt.Sprintf("imported:%s", manifest.Digest.Encoded()[:12])
if manifest.Annotations != nil {
if name, ok := manifest.Annotations["org.opencontainers.image.ref.name"]; ok {
ref = name
log.G(ctx).Infof(" Using annotation-based ref: %s", ref)
log.G(ctx).Debugf(" Using annotation-based ref: %s", ref)
}
}

Expand All @@ -182,7 +182,7 @@ func NewContentStoreResolverFromTar(ctx context.Context, tarPath string) (*Conte
Target: manifest,
}
imageStore.Create(ctx, image)
log.G(ctx).Infof(" ✅ IMPORTED: %s -> %s", ref, manifest.Digest)
log.G(ctx).Debugf(" ✅ IMPORTED: %s -> %s", ref, manifest.Digest)
}

return NewContentStoreResolver(store, imageStore), nil
Expand Down
4 changes: 2 additions & 2 deletions cmd/convertor/builder/overlaybd_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func (e *overlaybdBuilderEngine) uploadBaseLayer(ctx context.Context) (specs.Des
if err = uploadBlobWithRetry(ctx, e.pusher, tarFile, baseDesc, e.retryCount); err != nil {
return specs.Descriptor{}, errors.Wrapf(err, "failed to upload baselayer")
}
logrus.Infof("baselayer uploaded")
logrus.Debugf("baselayer uploaded")
}
return baseDesc, nil
}
Expand Down Expand Up @@ -526,7 +526,7 @@ func (e *overlaybdBuilderEngine) commit(ctx context.Context, dir string, idx int
if err := utils.Commit(ctx, dir, dir, false, opts...); err != nil {
return err
}
logrus.Infof("layer %d committed, uuid: %s, parent uuid: %s", idx, curUUID, parentUUID)
logrus.Debugf("layer %d committed, uuid: %s, parent uuid: %s", idx, curUUID, parentUUID)
return nil
}

Expand Down
26 changes: 14 additions & 12 deletions cmd/convertor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Description: overlaybd convertor is a standalone userspace image conversion tool

Version: ` + commitID,
Run: func(cmd *cobra.Command, args []string) {
// Set default log level to Info, enable Debug with --verbose
logrus.SetLevel(logrus.InfoLevel)
if verbose {
logrus.SetLevel(logrus.DebugLevel)
}
Expand Down Expand Up @@ -127,7 +129,7 @@ Version: ` + commitID,

if importTar != "" {
// Import mode - create content store resolver from tar
logrus.Infof("importing from tar file: %s", importTar)
logrus.Debugf("importing from tar file: %s", importTar)
var err error
importResolver, err = builder.NewContentStoreResolverFromTar(ctx, importTar)
if err != nil {
Expand Down Expand Up @@ -159,23 +161,23 @@ Version: ` + commitID,
if ref == "" {
ref = images[0].Name
isMultiArch = (images[0].Target.MediaType == "application/vnd.oci.image.index.v1+json")
logrus.Warnf("no main index found, using first image: %s", ref)
logrus.Debugf("no main index found, using first image: %s", ref)
} else {
logrus.Infof("found main image reference: %s", ref)
logrus.Debugf("found main image reference: %s", ref)
}

// Log what we're building
if isMultiArch {
logrus.Infof("building multi-arch image with %d total imported images", len(images))
logrus.Debugf("building multi-arch image with %d total imported images", len(images))
} else {
logrus.Infof("building single-arch image: %s", ref)
logrus.Debugf("building single-arch image: %s", ref)
}

// Choose resolver based on export mode
var customResolver remotes.Resolver
if exportTar != "" {
// For tar export, use FileBasedResolver to capture converted layers locally
logrus.Infof("tar export mode: using file-based resolver to capture converted layers")
logrus.Debugf("tar export mode: using file-based resolver to capture converted layers")
var err error
exportResolver, err = builder.NewFileBasedResolver(importResolver.Store(), importResolver.ImageStore())
if err != nil {
Expand All @@ -199,7 +201,7 @@ Version: ` + commitID,
logrus.Error("repository is required when not using export-tar")
os.Exit(1)
}
logrus.Infof("registry export mode: creating hybrid resolver for tar import -> registry push")
logrus.Debugf("registry export mode: creating hybrid resolver for tar import -> registry push")

// Create registry resolver for pushing (simplified TLS config)
tlsConfig := &tls.Config{
Expand Down Expand Up @@ -318,7 +320,7 @@ Version: ` + commitID,
switch dbType {
case "mysql":
if dbstr == "" {
logrus.Warnf("no db-str was provided, falling back to no deduplication")
logrus.Debugf("no db-str was provided, falling back to no deduplication")
}
db, err := sql.Open("mysql", dbstr)
if err != nil {
Expand All @@ -328,8 +330,8 @@ Version: ` + commitID,
opt.DB = database.NewSqlDB(db)
case "":
default:
logrus.Warnf("db-type %s was provided but is not one of known db types. Available: mysql", dbType)
logrus.Warnf("falling back to no deduplication")
logrus.Debugf("db-type %s was provided but is not one of known db types. Available: mysql", dbType)
logrus.Debugf("falling back to no deduplication")
}

if err := builder.Build(ctx, opt); err != nil {
Expand All @@ -340,7 +342,7 @@ Version: ` + commitID,

// Handle tar export if requested
if exportTar != "" && exportResolver != nil {
logrus.Infof("exporting converted overlaybd layers to tar file: %s", exportTar)
logrus.Debugf("exporting converted overlaybd layers to tar file: %s", exportTar)
if err := builder.ExportContentStoreToTar(ctx, exportResolver.OutputStore(), exportResolver.OutputImageStore(), exportTar); err != nil {
logrus.Errorf("failed to export tar file: %v", err)
os.Exit(1)
Expand All @@ -360,7 +362,7 @@ Version: ` + commitID,

// Handle tar export if requested
if exportTar != "" && exportResolver != nil {
logrus.Infof("exporting converted turboOCI layers to tar file: %s", exportTar)
logrus.Debugf("exporting converted turboOCI layers to tar file: %s", exportTar)
if err := builder.ExportContentStoreToTar(ctx, exportResolver.OutputStore(), exportResolver.OutputImageStore(), exportTar); err != nil {
logrus.Errorf("failed to export tar file: %v", err)
os.Exit(1)
Expand Down
Loading