Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generates and labels VolumeGroupSnapshotClass #168

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

raaizik
Copy link
Contributor

@raaizik raaizik commented Jun 3, 2024

Changes

  • Have storage claim controller own VolumeGroupSnapshotClass with the required labels for RDR added to both VGSC and VSC.
  • Adds Available CRDs functionality to k8sutils
  • Upgrades k8s-csi
    • Requires go >= 1.22.0 which uses client-go v0.30 which works with CR v0.18 and CG v0.14

RHSTOR-5795

TODO

  • Change to v1beta1 once available for VolumeGroupSnapshotClass #1150
  • Test complete workflow

@raaizik raaizik force-pushed the RHSTOR-5795 branch 4 times, most recently from d68c5d2 to 7e993b3 Compare June 3, 2024 13:59
@pull-request-size pull-request-size bot added size/L and removed size/M labels Jun 3, 2024
@pull-request-size pull-request-size bot added size/M and removed size/L labels Jun 3, 2024
@raaizik raaizik force-pushed the RHSTOR-5795 branch 2 times, most recently from 38c58d7 to b148266 Compare June 4, 2024 10:21
@raaizik raaizik changed the title [WIP] Generates VolumeGroupSnapshotClass [WIP] Generates and labels Volume*SnapshotClass Jun 4, 2024
@raaizik raaizik changed the title [WIP] Generates and labels Volume*SnapshotClass Generates and labels Volume*SnapshotClass Jun 4, 2024
@raaizik
Copy link
Contributor Author

raaizik commented Jun 4, 2024

/cc @rewantsoni

@openshift-ci openshift-ci bot requested a review from rewantsoni June 4, 2024 13:50
@raaizik raaizik changed the title Generates and labels Volume*SnapshotClass [WIP] Generates and labels Volume*SnapshotClass Jun 5, 2024
@raaizik raaizik changed the title [WIP] Generates and labels Volume*SnapshotClass Generates and labels Volume*SnapshotClass Jun 6, 2024
@raaizik raaizik force-pushed the RHSTOR-5795 branch 2 times, most recently from 63d1586 to 0af9ddc Compare June 6, 2024 13:04
Comment on lines 407 to 410
labels["ramendr.openshift.io/replicationID"] = r.storageClaimHash
labels["ramendr.openshift.io/storageID"] = storageID
if resource.Name == "cephfs" {
volumeSnapshotClass = r.getCephFSVolumeSnapshotClass(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The labels are not being applied to the cephfs or rbd VolumeSnapshotClass

Suggested change
labels["ramendr.openshift.io/replicationID"] = r.storageClaimHash
labels["ramendr.openshift.io/storageID"] = storageID
if resource.Name == "cephfs" {
volumeSnapshotClass = r.getCephFSVolumeSnapshotClass(data)
labels["ramendr.openshift.io/replicationID"] = r.storageClaimHash
labels["ramendr.openshift.io/storageID"] = storageID
if resource.Name == "cephfs" {
volumeSnapshotClass = r.getCephFSVolumeSnapshotClass(data,labels)

Comment on lines 720 to 713
if reflect.DeepEqual(existing.Parameters, volumeGroupSnapshotClass.Parameters) {
return nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also check for labels?

@raaizik raaizik force-pushed the RHSTOR-5795 branch 2 times, most recently from ad64a3a to 15d83d2 Compare November 4, 2024 15:59
@raaizik raaizik requested a review from rewantsoni November 4, 2024 16:41
return err
}

obj.SetResourceVersion("")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment reg why this is required?
something like:

k8s doesn't allow us to create objects when resourceVersion is set, as we are DeepCopying the object, the resource version also gets copied, hence we need to set it to empty before creating it

} else if resource.Name == "ceph-rbd" {
volumeSnapshotClass = r.getCephRBDVolumeSnapshotClass(data)
}
volumeSnapshotClass = r.getCephDriverVolumeSnapshotClass(resource.Labels, resource.Annotations)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also set the Labels and annotation in CreateOrReplace for all resources

@raaizik raaizik force-pushed the RHSTOR-5795 branch 2 times, most recently from 89f459e to 8865ae0 Compare November 5, 2024 13:54
@raaizik raaizik requested a review from rewantsoni November 5, 2024 13:57
@Madhu-1
Copy link
Member

Madhu-1 commented Nov 6, 2024

@raaizik can we split this in to Two PR's one for volumesnapshotclass and another one for volumegroupsnapshotclass? we can get the volumesnapshotclass PR merged and we can visit the volumegroupsnapshotclass PR once we have the feature in betav1 state.

@raaizik raaizik changed the title Generates and labels Volume*SnapshotClass Generates and labels VolumeSnapshotClass Nov 10, 2024
@raaizik raaizik changed the title Generates and labels VolumeSnapshotClass Generates and labels VolumeGroupSnapshotClass Nov 10, 2024
@raaizik
Copy link
Contributor Author

raaizik commented Nov 10, 2024

@raaizik can we split this in to Two PR's one for volumesnapshotclass and another one for volumegroupsnapshotclass? we can get the volumesnapshotclass PR merged and we can visit the volumegroupsnapshotclass PR once we have the feature in betav1 state.

Yes #266 @Madhu-1

@@ -141,6 +184,17 @@ func (r *StorageClaimReconciler) Reconcile(ctx context.Context, req ctrl.Request
r.ctx = ctrllog.IntoContext(ctx, r.log)
r.log.Info("Reconciling StorageClaim.")

crd := &metav1.PartialObjectMetadata{}
for _, crdName := range []string{volumeGroupSnapshotClassCrd, drClusterConfigCRDName} {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have drClusterConfigCRDName isnt this PR only for VGSC?

return nil
})
if err != nil {
return reconcile.Result{}, fmt.Errorf("failed to create or update StorageClass: %s", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failed to create or update StorageClass to failed to create or update VolumeGroupSnapshotClass

Labels: labels,
Annotations: annotations,
},
Driver: templates.RBDDriverName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be configurable as we need to support for both cephfs and rbd

Copy link

openshift-ci bot commented Dec 17, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: raaizik
Once this PR has been reviewed and has the lgtm label, please ask for approval from madhu-1. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@raaizik raaizik requested a review from Madhu-1 December 17, 2024 11:23
Copy link
Member

@rewantsoni rewantsoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also test this PR on a cluster to see if the VGSC is created with the required fields

@@ -401,7 +454,35 @@ func (r *StorageClaimReconciler) reconcilePhases() (reconcile.Result, error) {
return nil
})
if err != nil {
return reconcile.Result{}, fmt.Errorf("failed to create or update VolumeSnapshotClass: %s", err)
return reconcile.Result{}, fmt.Errorf("failed to create or update StorageClass: %s", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return reconcile.Result{}, fmt.Errorf("failed to create or update StorageClass: %s", err)
return reconcile.Result{}, fmt.Errorf("failed to create or update VolumeSnapshotClass: %s", err)

You are under the VolumeSnapshotClass case here not StorageClass

Comment on lines +463 to +478
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)
}
data["csi.storage.k8s.io/group-snapshotter-secret-namespace"] = r.OperatorNamespace
// generate a new clusterID for cephfs subvolumegroup, as
// storageclaim is clusterscoped resources using its
// hash as the clusterID
data["clusterID"] = r.storageClaimHash
driverName := templates.CephFsDriverName
if strings.Contains(strings.ToLower(resource.Name), "rbd") {
driverName = templates.RBDDriverName
}
volumeGroupSnapshotClass = r.getCephDriverVolumeGroupSnapshotClass(resource.Labels, resource.Annotations, driverName)
utils.AddAnnotation(volumeGroupSnapshotClass, storageClaimAnnotation, r.storageClaim.Name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move everything under CreateOrReplace

@@ -550,6 +636,20 @@ func (r *StorageClaimReconciler) getCephRBDVolumeSnapshotClass() *snapapi.Volume
return volumesnapshotclass
}

func (r *StorageClaimReconciler) getCephDriverVolumeGroupSnapshotClass(
labels map[string]string, annotations map[string]string, driver string) *groupsnapapi.VolumeGroupSnapshotClass {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add the labels/annotations directly in the CreateOrReplace

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might not need this function, we could have everything under CreateOrReplace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants