mirror of
https://github.com/containerd/containerd.git
synced 2026-08-04 15:10:45 +00:00
erofs-differ: use same UUID append style in tar index mode as tar conversion mode
Use the same approach for appending UUID arguments in GenerateTarIndexAndAppendTar as done in ConvertTarErofs for consistency between the two modes. Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
This commit is contained in:
@@ -54,7 +54,7 @@ func ConvertTarErofs(ctx context.Context, r io.Reader, layerPath, uuid string, m
|
||||
// The `--tar=i` option instructs mkfs.erofs to only generate the tar index
|
||||
// for the tar content. The resulting file structure is:
|
||||
// [Tar index][Original tar content]
|
||||
func GenerateTarIndexAndAppendTar(ctx context.Context, r io.Reader, layerPath string, mkfsExtraOpts []string) error {
|
||||
func GenerateTarIndexAndAppendTar(ctx context.Context, r io.Reader, layerPath, uuid string, mkfsExtraOpts []string) error {
|
||||
// Create a temporary file for storing the tar content
|
||||
tarFile, err := os.CreateTemp("", "erofs-tar-*")
|
||||
if err != nil {
|
||||
@@ -68,6 +68,9 @@ func GenerateTarIndexAndAppendTar(ctx context.Context, r io.Reader, layerPath st
|
||||
|
||||
// Generate tar index directly to layerPath using --tar=i option
|
||||
args := append([]string{"--tar=i", "--aufs", "--quiet"}, mkfsExtraOpts...)
|
||||
if uuid != "" {
|
||||
args = append(args, []string{"-U", uuid}...)
|
||||
}
|
||||
args = append(args, layerPath)
|
||||
cmd := exec.CommandContext(ctx, "mkfs.erofs", args...)
|
||||
cmd.Stdin = teeReader
|
||||
|
||||
@@ -174,16 +174,17 @@ func (s erofsDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mounts []
|
||||
}
|
||||
|
||||
// Choose between tar index or tar conversion mode
|
||||
// Generate deterministic UUID from layer digest
|
||||
u := uuid.NewSHA1(uuid.NameSpaceURL, []byte("erofs:blobs/"+desc.Digest))
|
||||
if s.enableTarIndex {
|
||||
// Use the tar index method: generate tar index and append tar
|
||||
err = erofsutils.GenerateTarIndexAndAppendTar(ctx, rc, layerBlobPath, s.mkfsExtraOpts)
|
||||
err = erofsutils.GenerateTarIndexAndAppendTar(ctx, rc, layerBlobPath, u.String(), s.mkfsExtraOpts)
|
||||
if err != nil {
|
||||
return emptyDesc, fmt.Errorf("failed to generate tar index: %w", err)
|
||||
}
|
||||
log.G(ctx).WithField("path", layerBlobPath).Debug("Applied layer using tar index mode")
|
||||
} else {
|
||||
// Use the tar method: fully convert tar to EROFS
|
||||
u := uuid.NewSHA1(uuid.NameSpaceURL, []byte("erofs:blobs/"+desc.Digest))
|
||||
err = erofsutils.ConvertTarErofs(ctx, rc, layerBlobPath, u.String(), s.mkfsExtraOpts)
|
||||
if err != nil {
|
||||
return emptyDesc, fmt.Errorf("failed to convert tar to erofs: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user