From 2c4081de484e05a165c7f541cae71524ad8ed2b4 Mon Sep 17 00:00:00 2001 From: Derek Su Date: Fri, 7 Jul 2023 16:02:00 +0800 Subject: [PATCH] Remove orhapn UPDATE validation Longhorn 6246 Signed-off-by: Derek Su --- webhook/resources/orphan/validator.go | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/webhook/resources/orphan/validator.go b/webhook/resources/orphan/validator.go index 744da5fbd7..906454a8c5 100644 --- a/webhook/resources/orphan/validator.go +++ b/webhook/resources/orphan/validator.go @@ -2,7 +2,6 @@ package orphan import ( "fmt" - "reflect" admissionregv1 "k8s.io/api/admissionregistration/v1" "k8s.io/apimachinery/pkg/runtime" @@ -31,7 +30,6 @@ func (o *orphanValidator) Resource() admission.Resource { ObjectType: &longhorn.Orphan{}, OperationTypes: []admissionregv1.OperationType{ admissionregv1.Create, - admissionregv1.Update, }, } } @@ -53,30 +51,6 @@ func (o *orphanValidator) Create(request *admission.Request, newObj runtime.Obje return nil } -func (o *orphanValidator) Update(request *admission.Request, oldObj runtime.Object, newObj runtime.Object) error { - oldOrphan := oldObj.(*longhorn.Orphan) - newOrphan := newObj.(*longhorn.Orphan) - - if err := checkOrphanParameters(newOrphan); err != nil { - return werror.NewInvalidError(err.Error(), "") - } - - if !reflect.DeepEqual(oldOrphan.Spec, newOrphan.Spec) { - return werror.NewInvalidError(fmt.Sprintf("orphan %v spec fields are immutable", oldOrphan.Name), "") - } - - return nil -} - -func checkOrphanParameters(orphan *longhorn.Orphan) error { - switch { - case orphan.Spec.Type == longhorn.OrphanTypeReplica: - return checkOrphanForReplicaDirectory(orphan) - } - - return werror.NewInvalidError(fmt.Sprintf("unknown orphan type %v for orphan %v", orphan.Spec.Type, orphan.Name), "") -} - func checkOrphanForReplicaDirectory(orphan *longhorn.Orphan) error { params := []string{ longhorn.OrphanDataName,