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

Closed
wants to merge 1 commit into 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 6356b95 to 27dc75c Compare November 25, 2024 14:12
@raaizik raaizik requested a review from leelavg November 25, 2024 14:12
@raaizik raaizik force-pushed the RHSTOR-5795 branch 2 times, most recently from d1858ea to 5af8ff3 Compare December 11, 2024 10:49
internal/controller/storageclaim_controller.go Outdated Show resolved Hide resolved
internal/controller/storageclaim_controller.go Outdated Show resolved Hide resolved
internal/controller/storageclaim_controller.go Outdated Show resolved Hide resolved
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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The CreateOrReplace body should contain only part of this snippet, as seen in current code

@@ -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.

Copy link
Contributor Author

@raaizik raaizik Jan 12, 2025

Choose a reason for hiding this comment

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

We do need it to create the VGSC resource prior to applying its labels, annotations, etc. I've altered it

@raaizik raaizik force-pushed the RHSTOR-5795 branch 2 times, most recently from b8e5f4f to f449325 Compare January 12, 2025 15:36
@raaizik raaizik requested a review from rewantsoni January 12, 2025 16:00
@rewantsoni
Copy link
Member

@raaizik Are the changes tested?

driver string) *groupsnapapi.VolumeGroupSnapshotClass {
volumegroupsnapshotclass := &groupsnapapi.VolumeGroupSnapshotClass{
ObjectMeta: metav1.ObjectMeta{
Name: 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.

please make sure we use the same class names as internal mode

Copy link
Contributor Author

@raaizik raaizik Jan 23, 2025

Choose a reason for hiding this comment

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

I will do that, keeping track of 2859

Signed-off-by: raaizik <132667934+raaizik@users.noreply.github.com>
Copy link
Member

@Madhu-1 Madhu-1 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jan 23, 2025
Copy link

openshift-ci bot commented Jan 23, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Madhu-1, raaizik

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

The pull request process is described 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

@Madhu-1
Copy link
Member

Madhu-1 commented Jan 23, 2025

Added hold, @rewantsoni any final comments, if changes looks good, please remove the hold

@raaizik
Copy link
Contributor Author

raaizik commented Jan 23, 2025

Added hold, @rewantsoni any final comments, if changes looks good, please remove the hold

Local testing still WIP @Madhu-1

@Madhu-1
Copy link
Member

Madhu-1 commented Jan 23, 2025

Added hold, @rewantsoni any final comments, if changes looks good, please remove the hold

Local testing still WIP @Madhu-1

Thank you , Lets do a final testing and update the results.

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

Successfully merging this pull request may close these issues.

6 participants