Skip to content

Commit

Permalink
Change to accept 'KMSServerAddress' automatically
Browse files Browse the repository at this point in the history
A minor code change to automatically set 'KMSServerAddress'
while we add a new KMS configuration.

Signed-off-by: Arun Kumar Mohan <amohan@redhat.com>
  • Loading branch information
aruniiird committed Aug 2, 2024
1 parent 858d548 commit a7bd59e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions controllers/storagecluster/cephcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,17 @@ func (obj *ocsCephCluster) ensureCreated(r *StorageClusterReconciler, sc *ocsv1.
// reset the KMS connection's error field,
// it will be anyway set if there is an error
sc.Status.KMSServerConnection.KMSServerConnectionError = ""
if kmsConfigMap.Data["KMS_PROVIDER"] == "vault" {
sc.Status.KMSServerConnection.KMSServerAddress = kmsConfigMap.Data["VAULT_ADDR"]
} else if kmsConfigMap.Data["KMS_PROVIDER"] == AzureKSMProvider {
sc.Status.KMSServerConnection.KMSServerAddress = kmsConfigMap.Data["AZURE_VAULT_URL"]
} else if kmsConfigMap.Data["KMS_PROVIDER"] == ThalesKMSProvider {
sc.Status.KMSServerConnection.KMSServerAddress = kmsConfigMap.Data["KMIP_ENDPOINT"]
}
if err = reachKMSProvider(kmsConfigMap); err != nil {
// get the current KMS provider name
currKMSProvider := kmsConfigMap.Data[KMSProviderKey]
// according to the KMS provider, get the corresponding address/endpoint key
// and use it to set 'KMSServerAddress' status
kmsAddrssKey := kmsProviderAddressKeyMap[currKMSProvider]
sc.Status.KMSServerConnection.KMSServerAddress = kmsConfigMap.Data[kmsAddrssKey]
// if the KMS connection address is empty, log it as an error and continue
if sc.Status.KMSServerConnection.KMSServerAddress == "" {
r.Log.Error(nil, "An empty KMS server connection address found",
"KMSProviderName", currKMSProvider, "KMSAddressKey", kmsAddrssKey)
} else if err = reachKMSProvider(kmsConfigMap); err != nil {
sc.Status.KMSServerConnection.KMSServerConnectionError = err.Error()
r.Log.Error(err, "Address provided in KMS ConfigMap is not reachable.", "KMSConfigMap", klog.KRef(kmsConfigMap.Namespace, kmsConfigMap.Name))
return reconcile.Result{}, err
Expand Down

0 comments on commit a7bd59e

Please sign in to comment.