From b626410cea0fc136bd7f7b1f1bfa89a0eb3ce57f Mon Sep 17 00:00:00 2001 From: Luca Seritan Date: Thu, 9 May 2024 14:42:05 +0300 Subject: [PATCH] fix(oci): Don't delete dependencies of index When we package an application it can be the case that we have a dependency on another package (e.g. a kernel). In these cases, the dependency is not actually packed together with our application, instead we just keep a reference to it. The problem arises when we attempt to overwrite such a package. Because all dependencies were previously deleted, this meant that both of the underlying packages would be removed, but only the application would get repackaged, resulting in an app that cannot be run due to missing layers. Setting this flag to false and not removing dependencies solves this issue, but causes the cache to grow indefinitely, which is less than ideal. Signed-off-by: Luca Seritan --- oci/pack.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oci/pack.go b/oci/pack.go index 8fca363f9..b391c9eaa 100644 --- a/oci/pack.go +++ b/oci/pack.go @@ -291,7 +291,7 @@ func NewPackageFromTarget(ctx context.Context, targ target.Target, opts ...packm } case packmanager.StrategyOverwrite: - if err := ocipack.handle.DeleteIndex(ctx, ocipack.ref.Name(), true); err != nil { + if err := ocipack.handle.DeleteIndex(ctx, ocipack.ref.Name(), false); err != nil { return nil, fmt.Errorf("could not remove existing index: %w", err) }