Skip to content

Commit

Permalink
Merge release v0.1.18
Browse files Browse the repository at this point in the history
Release v0.1.18
  • Loading branch information
roehrich-hpe authored Dec 11, 2024
2 parents 95022f7 + 952f89c commit 8f546cc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha4/nnfstorageprofile_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ type NnfStorageProfileData struct {
// +kubebuilder:default:=false
Default bool `json:"default,omitempty"`

// Pinned is true if this instance is an immutable copy
// Pinned is true if this instance is describing an active storage resource
// +kubebuilder:default:=false
Pinned bool `json:"pinned,omitempty"`

Expand Down
17 changes: 5 additions & 12 deletions api/v1alpha4/nnfstorageprofile_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package v1alpha4
import (
"fmt"
"os"
"reflect"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -76,17 +75,11 @@ func (r *NnfStorageProfile) ValidateUpdate(old runtime.Object) (admission.Warnin
nnfstorageprofilelog.Error(err, "invalid")
return nil, err
}
if obj.Data.Pinned {
// Allow metadata to be updated, for things like finalizers,
// ownerReferences, and labels, but do not allow Data to be
// updated.
if !reflect.DeepEqual(r.Data, obj.Data) {
msg := "update on pinned resource not allowed"
err := fmt.Errorf(msg)
nnfstorageprofilelog.Error(err, "invalid")
return nil, err
}
}

// WARNING: NnfStorageProfile allows the obj.Data section to be modified.
// This is the place in the webhook where our other profile types, such as
// NnfContainerProfile or NnfDataMovementProfile, would verify that their
// obj.Data has not been modified.

if err := r.validateContent(); err != nil {
nnfstorageprofilelog.Error(err, "invalid NnfStorageProfile resource")
Expand Down
10 changes: 7 additions & 3 deletions api/v1alpha4/nnfstorageprofile_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,14 @@ var _ = Describe("NnfStorageProfile Webhook", func() {
nnfProfile = nil
})

It("Should not allow modification of Data in a pinned resource", func() {
It("Should allow modification of Data in a pinned resource", func() {
// WARNING: Our other profile types, such as NnfContainerProfile or
// NnfDataMovementProfile, do not allow this.

nnfProfile.ObjectMeta.Name = pinnedResourceName
nnfProfile.ObjectMeta.Namespace = otherNamespaceName
nnfProfile.Data.Pinned = true
nnfProfile.Data.RawStorage.CmdLines.LvRemove = "lvremove $VG_NAME"

Expect(k8sClient.Create(context.TODO(), nnfProfile)).To(Succeed())
Eventually(func() error {
Expand All @@ -184,8 +188,8 @@ var _ = Describe("NnfStorageProfile Webhook", func() {

Expect(k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(nnfProfile), newProfile)).To(Succeed())
Expect(newProfile.Data.Pinned).To(BeTrue())
newProfile.Data.Pinned = false
Expect(k8sClient.Update(context.TODO(), newProfile)).ToNot(Succeed())
newProfile.Data.RawStorage.CmdLines.LvRemove = "lvremove $VG_NAME/$LV_NAME"
Expect(k8sClient.Update(context.TODO(), newProfile)).To(Succeed())
})

It("Should allow modification of Meta in a pinned resource", func() {
Expand Down
3 changes: 2 additions & 1 deletion config/crd/bases/nnf.cray.hpe.com_nnfstorageprofiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1784,7 +1784,8 @@ spec:
type: object
pinned:
default: false
description: Pinned is true if this instance is an immutable copy
description: Pinned is true if this instance is describing an active
storage resource
type: boolean
rawStorage:
description: RawStorage defines the Raw-specific configuration
Expand Down
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ kind: Kustomization
images:
- name: controller
newName: ghcr.io/nearnodeflash/nnf-sos
newTag: 0.1.17
newTag: 0.1.18

0 comments on commit 8f546cc

Please sign in to comment.