Skip to content

Commit

Permalink
Remove orphapn UPDATE immutable validation
Browse files Browse the repository at this point in the history
Longhorn 6246

Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit authored and David Ko committed Jul 7, 2023
1 parent a9d6289 commit 6f809b3
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions webhook/resources/orphan/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package orphan

import (
"fmt"
"reflect"

admissionregv1 "k8s.io/api/admissionregistration/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -54,17 +53,12 @@ func (o *orphanValidator) Create(request *admission.Request, newObj runtime.Obje
}

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
}

Expand All @@ -83,6 +77,7 @@ func checkOrphanForReplicaDirectory(orphan *longhorn.Orphan) error {
longhorn.OrphanDiskName,
longhorn.OrphanDiskUUID,
longhorn.OrphanDiskPath,
longhorn.OrphanDiskType,
}

for _, param := range params {
Expand Down

0 comments on commit 6f809b3

Please sign in to comment.