Skip to content

Commit eeebeb8

Browse files
iPraveenPariharmergify[bot]
authored andcommitted
vgr: update VolumeGroupAttributes in VolumeGroupReplicationContent
This commit adds the VolumeGroupContext key-value data returned by CSI driver in CreateVolumeGroupResponse to the VolumeGroupReplicationContent.Spec.VolumeGroupAttributes. Signed-off-by: Praveen M <m.praveen@ibm.com>
1 parent aa2aff8 commit eeebeb8

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

internal/controller/replication.storage/volumegroupreplication_controller.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ func (r *VolumeGroupReplicationReconciler) Reconcile(ctx context.Context, req ct
127127
return reconcile.Result{}, err
128128
}
129129

130+
secretName := vgrClassObj.Spec.Parameters[prefixedGroupReplicationSecretNameKey]
131+
secretNamespace := vgrClassObj.Spec.Parameters[prefixedGroupReplicationSecretNamespaceKey]
132+
130133
// Declare all dependent resources
131134
vgrContentName := fmt.Sprintf("vgrcontent-%s", instance.UID)
132135
if instance.Spec.VolumeGroupReplicationContentName != "" {
@@ -137,6 +140,11 @@ func (r *VolumeGroupReplicationReconciler) Reconcile(ctx context.Context, req ct
137140
Name: vgrContentName,
138141
},
139142
}
143+
if secretName != "" && secretNamespace != "" {
144+
metav1.SetMetaDataAnnotation(&vgrContentObj.ObjectMeta, prefixedGroupReplicationSecretNameKey, secretName)
145+
metav1.SetMetaDataAnnotation(&vgrContentObj.ObjectMeta, prefixedGroupReplicationSecretNamespaceKey, secretNamespace)
146+
}
147+
140148
vrName := fmt.Sprintf("vr-%s", instance.UID)
141149
if instance.Spec.VolumeReplicationName != "" {
142150
vrName = instance.Spec.VolumeReplicationName
@@ -656,9 +664,7 @@ func (r *VolumeGroupReplicationReconciler) createOrUpdateVolumeGroupReplicationC
656664
return errors.New("dependent VGRContent resource is not yet created, waiting for it to be created")
657665
}
658666
if vgrContentObj.CreationTimestamp.IsZero() {
659-
vgrContentObj.Annotations = map[string]string{
660-
volumeGroupReplicationRef: vgrRef,
661-
}
667+
metav1.SetMetaDataAnnotation(&vgrContentObj.ObjectMeta, volumeGroupReplicationRef, vgrRef)
662668
vgrContentObj.Spec = replicationv1alpha1.VolumeGroupReplicationContentSpec{
663669
VolumeGroupReplicationRef: &corev1.ObjectReference{
664670
APIVersion: vgr.APIVersion,
@@ -678,7 +684,7 @@ func (r *VolumeGroupReplicationReconciler) createOrUpdateVolumeGroupReplicationC
678684
}
679685

680686
if vgrContentObj.Annotations[volumeGroupReplicationRef] != vgrRef {
681-
vgrContentObj.Annotations[volumeGroupReplicationRef] = vgrRef
687+
metav1.SetMetaDataAnnotation(&vgrContentObj.ObjectMeta, volumeGroupReplicationRef, vgrRef)
682688
}
683689

684690
if vgrContentObj.Spec.VolumeGroupReplicationRef == nil {

internal/controller/replication.storage/volumegroupreplicationcontent_controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,12 @@ func (r *VolumeGroupReplicationContentReconciler) Reconcile(ctx context.Context,
187187
return reconcile.Result{}, err
188188
}
189189

190-
// Update the group handle in the VolumeGroupReplicationContent CR
191-
instance.Spec.VolumeGroupReplicationHandle = resp.GetVolumeGroup().VolumeGroupId
190+
// Update the VGRContent resource with the group id and group attributes
191+
instance.Spec.VolumeGroupAttributes = resp.GetVolumeGroup().GetVolumeGroupContext()
192+
instance.Spec.VolumeGroupReplicationHandle = resp.GetVolumeGroup().GetVolumeGroupId()
192193
err = r.Update(ctx, instance)
193194
if err != nil {
194-
logger.Error(err, "failed to update group id in VGRContent")
195+
logger.Error(err, "failed to update VGRContent resource")
195196
return reconcile.Result{}, err
196197
}
197198
} else {

0 commit comments

Comments
 (0)