From 0f1141313f3d769a1026b2bb644536db21f239f7 Mon Sep 17 00:00:00 2001 From: parth-gr Date: Tue, 12 Dec 2023 21:20:43 +0530 Subject: [PATCH] build: add cel rule to make resource immutable added the cel rules at sunvolumgroup and rados namesapce spec closes: #13315 Signed-off-by: parth-gr (cherry picked from commit 098f1fe5e8123134e8460e0117e4d7f2341092b1) --- .../charts/rook-ceph/templates/resources.yaml | 12 ++++++++++++ deploy/examples/crds.yaml | 12 ++++++++++++ pkg/apis/ceph.rook.io/v1/types.go | 4 ++++ .../ceph.rook.io/v1/zz_generated.deepcopy.go | 17 +++++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/deploy/charts/rook-ceph/templates/resources.yaml b/deploy/charts/rook-ceph/templates/resources.yaml index 09d3b9da1..dae49adf1 100644 --- a/deploy/charts/rook-ceph/templates/resources.yaml +++ b/deploy/charts/rook-ceph/templates/resources.yaml @@ -36,9 +36,15 @@ spec: blockPoolName: description: BlockPoolName is the name of Ceph BlockPool. Typically it's the name of the CephBlockPool CR. type: string + x-kubernetes-validations: + - message: blockPoolName is immutable + rule: self == oldSelf name: description: The name of the CephBlockPoolRadosNamespaceSpec namespace. If not set, the default is the name of the CR. type: string + x-kubernetes-validations: + - message: name is immutable + rule: self == oldSelf required: - blockPoolName type: object @@ -7987,9 +7993,15 @@ spec: filesystemName: description: FilesystemName is the name of Ceph Filesystem SubVolumeGroup volume name. Typically it's the name of the CephFilesystem CR. If not coming from the CephFilesystem CR, it can be retrieved from the list of Ceph Filesystem volumes with `ceph fs volume ls`. To learn more about Ceph Filesystem abstractions see https://docs.ceph.com/en/latest/cephfs/fs-volumes/#fs-volumes-and-subvolumes type: string + x-kubernetes-validations: + - message: filesystemName is immutable + rule: self == oldSelf name: description: The name of the subvolume group. If not set, the default is the name of the subvolumeGroup CR. type: string + x-kubernetes-validations: + - message: name is immutable + rule: self == oldSelf pinning: description: Pinning configuration of CephFilesystemSubVolumeGroup, reference https://docs.ceph.com/en/latest/cephfs/fs-volumes/#pinning-subvolumes-and-subvolume-groups only one out of (export, distributed, random) can be set at a time properties: diff --git a/deploy/examples/crds.yaml b/deploy/examples/crds.yaml index 439eeed9a..fa232557c 100644 --- a/deploy/examples/crds.yaml +++ b/deploy/examples/crds.yaml @@ -39,9 +39,15 @@ spec: blockPoolName: description: BlockPoolName is the name of Ceph BlockPool. Typically it's the name of the CephBlockPool CR. type: string + x-kubernetes-validations: + - message: blockPoolName is immutable + rule: self == oldSelf name: description: The name of the CephBlockPoolRadosNamespaceSpec namespace. If not set, the default is the name of the CR. type: string + x-kubernetes-validations: + - message: name is immutable + rule: self == oldSelf required: - blockPoolName type: object @@ -7981,9 +7987,15 @@ spec: filesystemName: description: FilesystemName is the name of Ceph Filesystem SubVolumeGroup volume name. Typically it's the name of the CephFilesystem CR. If not coming from the CephFilesystem CR, it can be retrieved from the list of Ceph Filesystem volumes with `ceph fs volume ls`. To learn more about Ceph Filesystem abstractions see https://docs.ceph.com/en/latest/cephfs/fs-volumes/#fs-volumes-and-subvolumes type: string + x-kubernetes-validations: + - message: filesystemName is immutable + rule: self == oldSelf name: description: The name of the subvolume group. If not set, the default is the name of the subvolumeGroup CR. type: string + x-kubernetes-validations: + - message: name is immutable + rule: self == oldSelf pinning: description: Pinning configuration of CephFilesystemSubVolumeGroup, reference https://docs.ceph.com/en/latest/cephfs/fs-volumes/#pinning-subvolumes-and-subvolume-groups only one out of (export, distributed, random) can be set at a time properties: diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go index 0a4575bbf..050977f42 100755 --- a/pkg/apis/ceph.rook.io/v1/types.go +++ b/pkg/apis/ceph.rook.io/v1/types.go @@ -2923,12 +2923,14 @@ type CephFilesystemSubVolumeGroupList struct { // CephFilesystemSubVolumeGroupSpec represents the specification of a Ceph Filesystem SubVolumeGroup type CephFilesystemSubVolumeGroupSpec struct { // The name of the subvolume group. If not set, the default is the name of the subvolumeGroup CR. + // +kubebuilder:validation:XValidation:message="name is immutable",rule="self == oldSelf" // +optional Name string `json:"name,omitempty"` // FilesystemName is the name of Ceph Filesystem SubVolumeGroup volume name. Typically it's the name of // the CephFilesystem CR. If not coming from the CephFilesystem CR, it can be retrieved from the // list of Ceph Filesystem volumes with `ceph fs volume ls`. To learn more about Ceph Filesystem // abstractions see https://docs.ceph.com/en/latest/cephfs/fs-volumes/#fs-volumes-and-subvolumes + // +kubebuilder:validation:XValidation:message="filesystemName is immutable",rule="self == oldSelf" FilesystemName string `json:"filesystemName"` // Pinning configuration of CephFilesystemSubVolumeGroup, // reference https://docs.ceph.com/en/latest/cephfs/fs-volumes/#pinning-subvolumes-and-subvolume-groups @@ -2998,10 +3000,12 @@ type CephBlockPoolRadosNamespaceList struct { // CephBlockPoolRadosNamespaceSpec represents the specification of a CephBlockPool Rados Namespace type CephBlockPoolRadosNamespaceSpec struct { // The name of the CephBlockPoolRadosNamespaceSpec namespace. If not set, the default is the name of the CR. + // +kubebuilder:validation:XValidation:message="name is immutable",rule="self == oldSelf" // +optional Name string `json:"name,omitempty"` // BlockPoolName is the name of Ceph BlockPool. Typically it's the name of // the CephBlockPool CR. + // +kubebuilder:validation:XValidation:message="blockPoolName is immutable",rule="self == oldSelf" BlockPoolName string `json:"blockPoolName"` } diff --git a/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go b/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go index 57bd0bceb..4d30bb219 100644 --- a/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go +++ b/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go @@ -1904,6 +1904,23 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { in.Security.DeepCopyInto(&out.Security) in.LogCollector.DeepCopyInto(&out.LogCollector) in.CSI.DeepCopyInto(&out.CSI) + if in.CephConfig != nil { + in, out := &in.CephConfig, &out.CephConfig + *out = make(map[string]map[string]string, len(*in)) + for key, val := range *in { + var outVal map[string]string + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + (*out)[key] = outVal + } + } return }