From bfcc85dab7bb8db5f0723f14a783702dd88888d8 Mon Sep 17 00:00:00 2001 From: Nitin Goyal Date: Thu, 7 Mar 2024 17:33:22 +0530 Subject: [PATCH] Add status field to track toleration modifications Introduce a new status field to track addition of tolerations in the rook-ceph-operator-config configmap. The added field status indicates whether tolerations were successfully added to the configmap. This information is crucial for ensuring safe deletion, as we will only proceed with deletion if the tolerations were added by our mechanism. If they were added by user we will not proceed with the deletion. Signed-off-by: Nitin Goyal --- api/v1/ocsinitialization_types.go | 16 ++++++++++++---- api/v1/zz_generated.deepcopy.go | 16 ++++++++++++++++ .../ocs.openshift.io_ocsinitializations.yaml | 11 +++++++++++ .../ocs/ocs.openshift.io_ocsinitializations.yaml | 11 +++++++++++ .../manifests/ocsinitialization.crd.yaml | 11 +++++++++++ .../api/v4/v1/ocsinitialization_types.go | 16 ++++++++++++---- .../api/v4/v1/zz_generated.deepcopy.go | 16 ++++++++++++++++ 7 files changed, 89 insertions(+), 8 deletions(-) diff --git a/api/v1/ocsinitialization_types.go b/api/v1/ocsinitialization_types.go index 5b23ee0f94..300dff76f6 100644 --- a/api/v1/ocsinitialization_types.go +++ b/api/v1/ocsinitialization_types.go @@ -54,10 +54,18 @@ type OCSInitializationStatus struct { // operator. Object references will be added to this list after they have // been created AND found in the cluster. // +optional - RelatedObjects []corev1.ObjectReference `json:"relatedObjects,omitempty"` - ErrorMessage string `json:"errorMessage,omitempty"` - SCCsCreated bool `json:"sCCsCreated,omitempty"` - RookCephOperatorConfigCreated bool `json:"rookCephOperatorConfigCreated,omitempty"` + RelatedObjects []corev1.ObjectReference `json:"relatedObjects,omitempty"` + ErrorMessage string `json:"errorMessage,omitempty"` + SCCsCreated bool `json:"sCCsCreated,omitempty"` + RookCephOperatorConfigCreated bool `json:"rookCephOperatorConfigCreated,omitempty"` + RookCephOperatorConfig RookCephOperatorConfigStatus `json:"rookCephOperatorConfig,omitempty"` +} + +type RookCephOperatorConfigStatus struct { + // CsiPluginTolerationsModified indicates if CsiPluginTolerations are added in the configmap via controller + CsiPluginTolerationsModified bool `json:"csiPluginTolerationsModified,omitempty"` + // CsiProvisionerTolerationsModified indicates if CsiProvisionerTolerations are added in the configmap via controller + CsiProvisionerTolerationsModified bool `json:"csiProvisionerTolerationsModified,omitempty"` } // +kubebuilder:object:root=true diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 55ef5bc1be..621ae5c27c 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -662,6 +662,7 @@ func (in *OCSInitializationStatus) DeepCopyInto(out *OCSInitializationStatus) { *out = make([]corev1.ObjectReference, len(*in)) copy(*out, *in) } + out.RookCephOperatorConfig = in.RookCephOperatorConfig } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCSInitializationStatus. @@ -691,6 +692,21 @@ func (in *OverprovisionControlSpec) DeepCopy() *OverprovisionControlSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RookCephOperatorConfigStatus) DeepCopyInto(out *RookCephOperatorConfigStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RookCephOperatorConfigStatus. +func (in *RookCephOperatorConfigStatus) DeepCopy() *RookCephOperatorConfigStatus { + if in == nil { + return nil + } + out := new(RookCephOperatorConfigStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SharedFilesystemConfigurationSpec) DeepCopyInto(out *SharedFilesystemConfigurationSpec) { *out = *in diff --git a/config/crd/bases/ocs.openshift.io_ocsinitializations.yaml b/config/crd/bases/ocs.openshift.io_ocsinitializations.yaml index ce5313ac6f..3a393e4c5f 100644 --- a/config/crd/bases/ocs.openshift.io_ocsinitializations.yaml +++ b/config/crd/bases/ocs.openshift.io_ocsinitializations.yaml @@ -196,6 +196,17 @@ spec: type: object x-kubernetes-map-type: atomic type: array + rookCephOperatorConfig: + properties: + csiPluginTolerationsModified: + description: CsiPluginTolerationsModified indicates if CsiPluginTolerations + are added in the configmap via controller + type: boolean + csiProvisionerTolerationsModified: + description: CsiProvisionerTolerationsModified indicates if CsiProvisionerTolerations + are added in the configmap via controller + type: boolean + type: object rookCephOperatorConfigCreated: type: boolean sCCsCreated: diff --git a/deploy/csv-templates/crds/ocs/ocs.openshift.io_ocsinitializations.yaml b/deploy/csv-templates/crds/ocs/ocs.openshift.io_ocsinitializations.yaml index ce5313ac6f..3a393e4c5f 100644 --- a/deploy/csv-templates/crds/ocs/ocs.openshift.io_ocsinitializations.yaml +++ b/deploy/csv-templates/crds/ocs/ocs.openshift.io_ocsinitializations.yaml @@ -196,6 +196,17 @@ spec: type: object x-kubernetes-map-type: atomic type: array + rookCephOperatorConfig: + properties: + csiPluginTolerationsModified: + description: CsiPluginTolerationsModified indicates if CsiPluginTolerations + are added in the configmap via controller + type: boolean + csiProvisionerTolerationsModified: + description: CsiProvisionerTolerationsModified indicates if CsiProvisionerTolerations + are added in the configmap via controller + type: boolean + type: object rookCephOperatorConfigCreated: type: boolean sCCsCreated: diff --git a/deploy/ocs-operator/manifests/ocsinitialization.crd.yaml b/deploy/ocs-operator/manifests/ocsinitialization.crd.yaml index a658a9ab85..916549881f 100644 --- a/deploy/ocs-operator/manifests/ocsinitialization.crd.yaml +++ b/deploy/ocs-operator/manifests/ocsinitialization.crd.yaml @@ -195,6 +195,17 @@ spec: type: object x-kubernetes-map-type: atomic type: array + rookCephOperatorConfig: + properties: + csiPluginTolerationsModified: + description: CsiPluginTolerationsModified indicates if CsiPluginTolerations + are added in the configmap via controller + type: boolean + csiProvisionerTolerationsModified: + description: CsiProvisionerTolerationsModified indicates if CsiProvisionerTolerations + are added in the configmap via controller + type: boolean + type: object rookCephOperatorConfigCreated: type: boolean sCCsCreated: diff --git a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/ocsinitialization_types.go b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/ocsinitialization_types.go index 5b23ee0f94..300dff76f6 100644 --- a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/ocsinitialization_types.go +++ b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/ocsinitialization_types.go @@ -54,10 +54,18 @@ type OCSInitializationStatus struct { // operator. Object references will be added to this list after they have // been created AND found in the cluster. // +optional - RelatedObjects []corev1.ObjectReference `json:"relatedObjects,omitempty"` - ErrorMessage string `json:"errorMessage,omitempty"` - SCCsCreated bool `json:"sCCsCreated,omitempty"` - RookCephOperatorConfigCreated bool `json:"rookCephOperatorConfigCreated,omitempty"` + RelatedObjects []corev1.ObjectReference `json:"relatedObjects,omitempty"` + ErrorMessage string `json:"errorMessage,omitempty"` + SCCsCreated bool `json:"sCCsCreated,omitempty"` + RookCephOperatorConfigCreated bool `json:"rookCephOperatorConfigCreated,omitempty"` + RookCephOperatorConfig RookCephOperatorConfigStatus `json:"rookCephOperatorConfig,omitempty"` +} + +type RookCephOperatorConfigStatus struct { + // CsiPluginTolerationsModified indicates if CsiPluginTolerations are added in the configmap via controller + CsiPluginTolerationsModified bool `json:"csiPluginTolerationsModified,omitempty"` + // CsiProvisionerTolerationsModified indicates if CsiProvisionerTolerations are added in the configmap via controller + CsiProvisionerTolerationsModified bool `json:"csiProvisionerTolerationsModified,omitempty"` } // +kubebuilder:object:root=true diff --git a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/zz_generated.deepcopy.go b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/zz_generated.deepcopy.go index 55ef5bc1be..621ae5c27c 100644 --- a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/zz_generated.deepcopy.go +++ b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/zz_generated.deepcopy.go @@ -662,6 +662,7 @@ func (in *OCSInitializationStatus) DeepCopyInto(out *OCSInitializationStatus) { *out = make([]corev1.ObjectReference, len(*in)) copy(*out, *in) } + out.RookCephOperatorConfig = in.RookCephOperatorConfig } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCSInitializationStatus. @@ -691,6 +692,21 @@ func (in *OverprovisionControlSpec) DeepCopy() *OverprovisionControlSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RookCephOperatorConfigStatus) DeepCopyInto(out *RookCephOperatorConfigStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RookCephOperatorConfigStatus. +func (in *RookCephOperatorConfigStatus) DeepCopy() *RookCephOperatorConfigStatus { + if in == nil { + return nil + } + out := new(RookCephOperatorConfigStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SharedFilesystemConfigurationSpec) DeepCopyInto(out *SharedFilesystemConfigurationSpec) { *out = *in