From 6adf428f004ea980974bfd743994284126845eba Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 23 Dec 2024 10:49:00 +0800 Subject: [PATCH] fix(backup): backing image of backup backing image does not exist if backup backing image is synchronized from remote backup target because backing image might not exist. ref longhorn/longhorn 10026, 6341 Signed-off-by: James Lu --- webhook/resources/backupbackingimage/validator.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webhook/resources/backupbackingimage/validator.go b/webhook/resources/backupbackingimage/validator.go index 8d9cabbd8e..492c1c4153 100644 --- a/webhook/resources/backupbackingimage/validator.go +++ b/webhook/resources/backupbackingimage/validator.go @@ -45,11 +45,11 @@ func (bbi *backupBackingImageValidator) Create(request *admission.Request, newOb backingImageName := backupBackingImage.Spec.BackingImage backingImage, err := bbi.ds.GetBackingImageRO(backingImageName) - if err != nil { + if err != nil && !datastore.ErrorIsNotFound(err) { return werror.NewInvalidError(fmt.Sprintf("failed to get the backing image %v for backup: %v", backingImageName, err), "") } // TODO: support backup for v2 data engine in the future - if types.IsDataEngineV2(backingImage.Spec.DataEngine) { + if backingImage != nil && types.IsDataEngineV2(backingImage.Spec.DataEngine) { return werror.NewInvalidError(fmt.Sprintf("backing image %v uses v2 data engine which doesn't support backup operations", backingImageName), "") }