Skip to content

Commit

Permalink
Merge pull request #259 from leelavg/unmarshal-refactor
Browse files Browse the repository at this point in the history
DFBUGS-445:[release-4.16] controllers: refactor unmarshaling of storageclaim configuration
  • Loading branch information
openshift-merge-bot[bot] authored Nov 19, 2024
2 parents 5ea0a64 + a998fc5 commit 4beea0d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions controllers/storageclaim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,15 @@ func (r *StorageClaimReconciler) reconcilePhases() (reconcile.Result, error) {
}
// Go over the received objects and operate on them accordingly.
for _, resource := range resources {
data := map[string]string{}
err = json.Unmarshal(resource.Data, &data)
if err != nil {
return reconcile.Result{}, fmt.Errorf("failed to unmarshal StorageClaim configuration response: %v", err)
}

// Create the received resources, if necessary.
switch resource.Kind {
case "Secret":
data := map[string]string{}
err = json.Unmarshal(resource.Data, &data)
if err != nil {
return reconcile.Result{}, fmt.Errorf("failed to unmarshal StorageClaim configuration response as Secret: %v", err)
}
secret := &corev1.Secret{}
secret.Name = resource.Name
secret.Namespace = r.OperatorNamespace
Expand All @@ -356,6 +356,11 @@ func (r *StorageClaimReconciler) reconcilePhases() (reconcile.Result, error) {
return reconcile.Result{}, fmt.Errorf("failed to create or update secret %v: %s", secret, err)
}
case "StorageClass":
data := map[string]string{}
err = json.Unmarshal(resource.Data, &data)
if err != nil {
return reconcile.Result{}, fmt.Errorf("failed to unmarshal StorageClaim configuration response as StorageClass: %v", err)
}
if rns, ok := data["radosnamespace"]; ok {
csiClusterConfigEntry.CephRBD = new(csi.CephRBDSpec)
csiClusterConfigEntry.CephRBD.RadosNamespace = rns
Expand Down Expand Up @@ -392,6 +397,11 @@ func (r *StorageClaimReconciler) reconcilePhases() (reconcile.Result, error) {
return reconcile.Result{}, fmt.Errorf("failed to create or update StorageClass: %s", err)
}
case "VolumeSnapshotClass":
data := map[string]string{}
err = json.Unmarshal(resource.Data, &data)
if err != nil {
return reconcile.Result{}, fmt.Errorf("failed to unmarshal StorageClaim configuration response as VolumeSnapshotClass: %v", err)
}
var volumeSnapshotClass *snapapi.VolumeSnapshotClass
data["csi.storage.k8s.io/snapshotter-secret-namespace"] = r.OperatorNamespace
// generate a new clusterID for cephfs subvolumegroup, as
Expand Down

0 comments on commit 4beea0d

Please sign in to comment.