From fd2c36e11f6b9892683001e34c7d26b8a59a4bd2 Mon Sep 17 00:00:00 2001 From: Sam Batschelet Date: Fri, 26 Apr 2024 11:49:41 -0400 Subject: [PATCH] daemon/pinned-image-set: ensure cleanup of crio config file on delete Signed-off-by: Sam Batschelet --- pkg/daemon/pinned_image_set.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/daemon/pinned_image_set.go b/pkg/daemon/pinned_image_set.go index ee43a9886b..759b83bcbf 100644 --- a/pkg/daemon/pinned_image_set.go +++ b/pkg/daemon/pinned_image_set.go @@ -273,7 +273,7 @@ func (p *PinnedImageSetManager) syncMachineConfigPools(ctx context.Context, pool } if !exists { p.cache.Clear() - return errFailedToPullImage + return fmt.Errorf("%w: image removed during sync: %s", errFailedToPullImage, image) } } @@ -497,6 +497,8 @@ func ensureCrioPinnedImagesConfigFile(path string, imageNames []string) error { return fmt.Errorf("failed to remove CRI-O config file: %w", err) } return crioReload() + } else if len(imageNames) == 0 { + return nil } var existingCfgBytes []byte @@ -1180,6 +1182,10 @@ func uniqueSortedImageNames(images []mcfgv1alpha1.PinnedImageRef) []string { for _, image := range images { if _, ok := seen[image.Name]; !ok { + trimmedName := strings.TrimSpace(image.Name) + if trimmedName == "" { + continue + } seen[image.Name] = struct{}{} unique = append(unique, image.Name) }