Don't call setupInit in a temp mount if setupInit is nil

This is consistent with layerStore's CreateRWLayer behaviour.

Potentially this can be refactored to avoid creating the -init layer,
but as noted in layerStore's initMount, this name may be special, and
should be cleared-out all-at-once.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paul "TBBle" Hampson 2023-09-23 18:36:53 +09:00 committed by Paweł Gronowski
parent efadb70ef8
commit a1f6b64e24
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -87,10 +87,12 @@ func (i *ImageService) prepareInitLayer(ctx context.Context, id string, parent s
return err
}
if err := mount.WithTempMount(ctx, mounts, func(root string) error {
return setupInit(root)
}); err != nil {
return err
if setupInit != nil {
if err := mount.WithTempMount(ctx, mounts, func(root string) error {
return setupInit(root)
}); err != nil {
return err
}
}
return snapshotter.Commit(ctx, id+"-init", id+"-init-key")