Skip to content

Commit

Permalink
Explicitly reject encrypted and backing image for v2 volumes
Browse files Browse the repository at this point in the history
Longhorn 7404

Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit authored and David Ko committed Dec 26, 2023
1 parent b9e6569 commit 8cfda3e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 0 additions & 7 deletions webhook/resources/volume/mutator.go
Expand Up @@ -182,13 +182,6 @@ func (v *volumeMutator) Create(request *admission.Request, newObj runtime.Object

// TODO: Remove the mutations below after they are implemented for SPDK volumes
if datastore.IsBackendStoreDriverV2(volume.Spec.BackendStoreDriver) {
if volume.Spec.Encrypted {
patchOps = append(patchOps, `{"op": "replace", "path": "/spec/encrypted", "value": false}`)
}

if volume.Spec.BackingImage != "" {
patchOps = append(patchOps, `{"op": "replace", "path": "/spec/backingImage", "value": ""}`)
}
if volume.Spec.DataLocality != longhorn.DataLocalityDisabled {
patchOps = append(patchOps, fmt.Sprintf(`{"op": "replace", "path": "/spec/dataLocality", "value": "%s"}`, longhorn.DataLocalityDisabled))
}
Expand Down
6 changes: 5 additions & 1 deletion webhook/resources/volume/validator.go
Expand Up @@ -141,10 +141,14 @@ func (v *volumeValidator) Create(request *admission.Request, newObj runtime.Obje
}
}

if volume.Spec.BackendStoreDriver == longhorn.BackendStoreDriverTypeV2 {
// TODO: remove this check when we support the following features for SPDK volumes
if datastore.IsBackendStoreDriverV2(volume.Spec.BackendStoreDriver) {
if volume.Spec.Encrypted {
return werror.NewInvalidError("encrypted volume is not supported for backend store driver v2", "")
}
if volume.Spec.BackingImage != "" {
return werror.NewInvalidError("backing image is not supported for backend store driver v2", "")
}
}

return nil
Expand Down

0 comments on commit 8cfda3e

Please sign in to comment.