From ae9ab9ff5064c34699025e757969ce28394f1505 Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Tue, 4 Feb 2025 18:13:41 +0530 Subject: [PATCH 1/3] api: update the odf-info api the ocs-provider-server endpoint will not always be reachable from the other side. The user might have configured the networking differently. To address this, we need to make sure that user can specify the exported endpoint as a annotation to the storageCluster and we add and pass the info to the odf-info config map to be used by MCO in case of establishing DR Signed-off-by: Rewant Soni --- api/v1alpha1/odfinfoconfig.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/v1alpha1/odfinfoconfig.go b/api/v1alpha1/odfinfoconfig.go index 8ece02ee82..75ebeec7e6 100644 --- a/api/v1alpha1/odfinfoconfig.go +++ b/api/v1alpha1/odfinfoconfig.go @@ -18,6 +18,8 @@ package v1alpha1 import "k8s.io/apimachinery/pkg/types" +const ApiServerExportedAddressAnnotationName = "ocs.openshift.io/api-server-exported-address" + // ConnectedClient describes the connected clients of the storage cluster key type ConnectedClient struct { Name string `yaml:"name"` @@ -31,6 +33,7 @@ type InfoStorageCluster struct { StorageProviderEndpoint string `yaml:"storageProviderEndpoint"` CephClusterFSID string `yaml:"cephClusterFSID"` StorageClusterUID string `yaml:"storageClusterUID"` + Annotations map[string]string `yaml:"annotations"` } // OdfInfoData describes odf-info CM's data From a7b946e22801cc4116362bc401c83b5275af69f0 Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Tue, 4 Feb 2025 18:21:43 +0530 Subject: [PATCH 2/3] add generated files Signed-off-by: Rewant Soni --- api/v1alpha1/zz_generated.deepcopy.go | 9 ++++++++- .../ocs-operator/api/v4/v1alpha1/odfinfoconfig.go | 3 +++ .../api/v4/v1alpha1/zz_generated.deepcopy.go | 9 ++++++++- .../ocs-operator/api/v4/v1alpha1/odfinfoconfig.go | 3 +++ .../api/v4/v1alpha1/zz_generated.deepcopy.go | 9 ++++++++- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 0c503d10e1..b14dbb9ac6 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -80,6 +80,13 @@ func (in *ConnectedClient) DeepCopy() *ConnectedClient { func (in *InfoStorageCluster) DeepCopyInto(out *InfoStorageCluster) { *out = *in out.NamespacedName = in.NamespacedName + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InfoStorageCluster. @@ -100,7 +107,7 @@ func (in *OdfInfoData) DeepCopyInto(out *OdfInfoData) { *out = make([]ConnectedClient, len(*in)) copy(*out, *in) } - out.StorageCluster = in.StorageCluster + in.StorageCluster.DeepCopyInto(&out.StorageCluster) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OdfInfoData. diff --git a/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/odfinfoconfig.go b/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/odfinfoconfig.go index 8ece02ee82..75ebeec7e6 100644 --- a/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/odfinfoconfig.go +++ b/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/odfinfoconfig.go @@ -18,6 +18,8 @@ package v1alpha1 import "k8s.io/apimachinery/pkg/types" +const ApiServerExportedAddressAnnotationName = "ocs.openshift.io/api-server-exported-address" + // ConnectedClient describes the connected clients of the storage cluster key type ConnectedClient struct { Name string `yaml:"name"` @@ -31,6 +33,7 @@ type InfoStorageCluster struct { StorageProviderEndpoint string `yaml:"storageProviderEndpoint"` CephClusterFSID string `yaml:"cephClusterFSID"` StorageClusterUID string `yaml:"storageClusterUID"` + Annotations map[string]string `yaml:"annotations"` } // OdfInfoData describes odf-info CM's data diff --git a/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/zz_generated.deepcopy.go b/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/zz_generated.deepcopy.go index 0c503d10e1..b14dbb9ac6 100644 --- a/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/zz_generated.deepcopy.go +++ b/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/zz_generated.deepcopy.go @@ -80,6 +80,13 @@ func (in *ConnectedClient) DeepCopy() *ConnectedClient { func (in *InfoStorageCluster) DeepCopyInto(out *InfoStorageCluster) { *out = *in out.NamespacedName = in.NamespacedName + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InfoStorageCluster. @@ -100,7 +107,7 @@ func (in *OdfInfoData) DeepCopyInto(out *OdfInfoData) { *out = make([]ConnectedClient, len(*in)) copy(*out, *in) } - out.StorageCluster = in.StorageCluster + in.StorageCluster.DeepCopyInto(&out.StorageCluster) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OdfInfoData. diff --git a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/odfinfoconfig.go b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/odfinfoconfig.go index 8ece02ee82..75ebeec7e6 100644 --- a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/odfinfoconfig.go +++ b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/odfinfoconfig.go @@ -18,6 +18,8 @@ package v1alpha1 import "k8s.io/apimachinery/pkg/types" +const ApiServerExportedAddressAnnotationName = "ocs.openshift.io/api-server-exported-address" + // ConnectedClient describes the connected clients of the storage cluster key type ConnectedClient struct { Name string `yaml:"name"` @@ -31,6 +33,7 @@ type InfoStorageCluster struct { StorageProviderEndpoint string `yaml:"storageProviderEndpoint"` CephClusterFSID string `yaml:"cephClusterFSID"` StorageClusterUID string `yaml:"storageClusterUID"` + Annotations map[string]string `yaml:"annotations"` } // OdfInfoData describes odf-info CM's data diff --git a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/zz_generated.deepcopy.go index 0c503d10e1..b14dbb9ac6 100644 --- a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/zz_generated.deepcopy.go @@ -80,6 +80,13 @@ func (in *ConnectedClient) DeepCopy() *ConnectedClient { func (in *InfoStorageCluster) DeepCopyInto(out *InfoStorageCluster) { *out = *in out.NamespacedName = in.NamespacedName + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InfoStorageCluster. @@ -100,7 +107,7 @@ func (in *OdfInfoData) DeepCopyInto(out *OdfInfoData) { *out = make([]ConnectedClient, len(*in)) copy(*out, *in) } - out.StorageCluster = in.StorageCluster + in.StorageCluster.DeepCopyInto(&out.StorageCluster) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OdfInfoData. From 53e7ab1d1d25d8a2dba01887af6492d9eb817f36 Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Tue, 4 Feb 2025 18:26:18 +0530 Subject: [PATCH 3/3] controllers: update the configMap to contain the annotation update the configmap to contain the annotation for ocs-api-server -endpoint-exported Signed-off-by: Rewant Soni --- controllers/storagecluster/odfinfoconfig.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/controllers/storagecluster/odfinfoconfig.go b/controllers/storagecluster/odfinfoconfig.go index 4036cedb1d..076a091329 100644 --- a/controllers/storagecluster/odfinfoconfig.go +++ b/controllers/storagecluster/odfinfoconfig.go @@ -137,6 +137,14 @@ func getOdfInfoData(r *StorageClusterReconciler, storageCluster *ocsv1.StorageCl return "", err } + annotations := map[string]string{} + for key, value := range storageCluster.GetAnnotations() { + parts := strings.Split(key, "/") + if len(parts) == 2 && strings.HasSuffix(parts[0], "ocs.openshift.io") { + annotations[key] = value + } + } + data := ocsv1a1.OdfInfoData{ Version: ocsVersion, DeploymentType: odfDeploymentType, @@ -147,6 +155,7 @@ func getOdfInfoData(r *StorageClusterReconciler, storageCluster *ocsv1.StorageCl StorageProviderEndpoint: storageCluster.Status.StorageProviderEndpoint, CephClusterFSID: cephFSId, StorageClusterUID: string(storageCluster.UID), + Annotations: annotations, }, } yamlData, err := yaml.Marshal(data)