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

Sends and labels V*ReplicationClass, V*SnapClass, StorageClass to client #2727

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

Conversation

raaizik
Copy link
Contributor

@raaizik raaizik commented Aug 1, 2024

Changes

RHSTOR-5753, RHSTOR-5794, RHSTOR-5754

@raaizik
Copy link
Contributor Author

raaizik commented Aug 1, 2024

/cc @Madhu-1

@openshift-ci openshift-ci bot requested a review from Madhu-1 August 1, 2024 13:03
@raaizik raaizik force-pushed the RHSTOR-5753 branch 2 times, most recently from cb85825 to eeb74d1 Compare August 6, 2024 10:31
@raaizik
Copy link
Contributor Author

raaizik commented Aug 6, 2024

/cc @rewantsoni

@openshift-ci openshift-ci bot requested a review from rewantsoni August 6, 2024 10:35
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.

For Volume*ReplicationClass we are sending only the parameters field like we did for Volume*SnapshotClass and StorageClass, Should we send the entire spec for it or maybe the entire object that will allow us to add labels/annotations required (ramen labels, reclaimspace annotation) from the provider itself and the client would be responsible for adding missing fields like ProvisionerName and namespace for secrets and then creating/upating it.

@nb-ohad WDYT?

Comment on lines +680 to +773
Data: mustMarshal(map[string]string{
"replication.storage.openshift.io/replication-secret-name": provisionerSecretName,
Copy link
Member

Choose a reason for hiding this comment

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

For flattening VRC, we require the special parameter flattenMode: force to be added, we should add it from the provider side

Copy link
Member

Choose a reason for hiding this comment

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

@raaizik I think this was missed

Comment on lines 673 to 753
Data: mustMarshal(map[string]string{
"replication.storage.openshift.io/replication-secret-name": provisionerSecretName,
}),
Copy link
Member

Choose a reason for hiding this comment

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

Along with the replication secret name, we also require mirroringMode key that can we sent from the provider, could you add that as well in all the V*RC?
Ref: https://github.com/red-hat-storage/odf-multicluster-orchestrator/blob/main/controllers/drpolicy_controller.go#L170-L178

Comment on lines 694 to 795
Data: mustMarshal(map[string]string{
"replication.storage.openshift.io/group-replication-secret-name": provisionerSecretName,
}),
Copy link
Member

Choose a reason for hiding this comment

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

For flattening VGRC, we require the special parameter flattenMode: force to be added, we should add it from the provider side

Copy link
Contributor

openshift-ci bot commented Aug 6, 2024

@raaizik: GitHub didn't allow me to request PR reviews from the following users: Rakshith-R.

Note that only red-hat-storage members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @Rakshith-R

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@raaizik
Copy link
Contributor Author

raaizik commented Aug 6, 2024

/cc @Rakshith-R

Copy link
Contributor

openshift-ci bot commented Aug 6, 2024

@raaizik: GitHub didn't allow me to request PR reviews from the following users: Rakshith-R.

Note that only red-hat-storage members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @Rakshith-R

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@raaizik raaizik force-pushed the RHSTOR-5753 branch 3 times, most recently from ffd5355 to 5c428c0 Compare August 7, 2024 12:47
Copy link
Member

@Rakshith-R Rakshith-R left a comment

Choose a reason for hiding this comment

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

"replication.storage.openshift.io/is-default-class": "true",
This should be added as a annotation

and
"replication.storage.openshift.io/flatten-mode": "force",

This as a label

hope both of the above will be handled accordingly in consumer side.

Other than the above, everything else looks good to me.

@raaizik
Copy link
Contributor Author

raaizik commented Aug 7, 2024

"replication.storage.openshift.io/is-default-class": "true", This should be added as a annotation

and "replication.storage.openshift.io/flatten-mode": "force",

This as a label

hope both of the above will be handled accordingly in consumer side.

Other than the above, everything else looks good to me.

@Rakshith-R I'm aware and it will.

@nb-ohad
Copy link
Contributor

nb-ohad commented Aug 7, 2024

For VolumeReplicationClass we are sending only the parameters field like we did for VolumeSnapshotClass and StorageClass, Should we send the entire spec for it or maybe the entire object that will allow us to add labels/annotations required (ramen labels, reclaimspace annotation) from the provider itself and the client would be responsible for adding missing fields like ProvisionerName and namespace for secrets and then creating/upating it.

@nb-ohad WDYT?

I will start with the later proposal first:

maybe the entire object that will allow us to add labels/annotations required

We do not want to do that, an object contains not just desired state but also status and some metadata that is local to the provider cluster. In internal discussions, we already acknowledged the need to send labels and annotations but not as part of the serialized spec we send (the data field of the ExternalResource struct). The plan is to add it to the metadata of the ExternalResource object, similar to the kind and name. Until that is implemented we will keep on having logic in the client to add the missing metadata.

Should we send the entire spec
This depends on the structure of the type, we originally used data because that was the desired state for configmaps and secrets. If the Volume*ReplicationClass has a formal spec field it will make sense to serialize it instead of a map[string]string.
As a matter of fact, we are already doing something similar for the ClusterResourceQuota CR (https://github.com/red-hat-storage/ocs-operator/blob/main/services/provider/server/server.go#L376-L399)

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 12, 2024
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 26, 2024
@raaizik
Copy link
Contributor Author

raaizik commented Aug 26, 2024

/test ocs-operator-bundle-e2e-aws

1 similar comment
@raaizik
Copy link
Contributor Author

raaizik commented Aug 26, 2024

/test ocs-operator-bundle-e2e-aws

@raaizik
Copy link
Contributor Author

raaizik commented Sep 5, 2024

/test ocs-operator-bundle-e2e-aws

@nb-ohad
Copy link
Contributor

nb-ohad commented Sep 8, 2024

/lgtm

@raaizik raaizik force-pushed the RHSTOR-5753 branch 4 times, most recently from fe9ea70 to 6c69b93 Compare November 4, 2024 16:40
rns := &rookCephv1.CephBlockPoolRadosNamespace{}
err = s.client.Get(ctx, types.NamespacedName{Name: cephRes.Name, Namespace: s.namespace}, rns)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get %s CephBlockPoolRadosNamespace. %v", cephRes.Name, err)
}

mirroringEnabled := len(rns.Spec.Mirroring.Mode) > 0
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 change it to If rns.Spec.Mirroring is not nil then mirroring is enabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is more precise check (it checks both)

Copy link
Member

Choose a reason for hiding this comment

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

What do you mean by it checks both?
We need to set this if mirroring is enabled, checking only if it is not nil should be sufficient

switch kind {
case "VolumeReplicationClass", "VolumeGroupReplicationClass":
if isMirroringReplicationEnabled {
replicationID := replicationID
Copy link
Member

Choose a reason for hiding this comment

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

I think this is redundant

@raaizik raaizik force-pushed the RHSTOR-5753 branch 3 times, most recently from a8d44cb to 16961db Compare November 4, 2024 18:22
rns := &rookCephv1.CephBlockPoolRadosNamespace{}
err = s.client.Get(ctx, types.NamespacedName{Name: cephRes.Name, Namespace: s.namespace}, rns)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get %s CephBlockPoolRadosNamespace. %v", cephRes.Name, err)
}

mirroringEnabled := len(rns.Spec.Mirroring.Mode) > 0
Copy link
Member

Choose a reason for hiding this comment

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

What do you mean by it checks both?
We need to set this if mirroring is enabled, checking only if it is not nil should be sufficient

}
case "StorageClass":
if isMirroringReplicationEnabled {
labels["ramendr.openshift.io/replicationid"] = replicationID
Copy link
Member

Choose a reason for hiding this comment

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

storageClass doesn't need the replicationID label

@raaizik raaizik force-pushed the RHSTOR-5753 branch 2 times, most recently from d65b1f2 to cae0219 Compare November 5, 2024 13:52
Comment on lines +680 to +773
Data: mustMarshal(map[string]string{
"replication.storage.openshift.io/replication-secret-name": provisionerSecretName,
Copy link
Member

Choose a reason for hiding this comment

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

@raaizik I think this was missed

@rewantsoni
Copy link
Member

LGTM

@raaizik raaizik changed the title Sends V*ReplicationClass to client Sends and labels V*ReplicationClass, V*SnapClass, StorageClass to client Nov 5, 2024
Comment on lines 860 to 842
Labels: getExternalResourceLabels("VolumeGroupReplicationClass", replicationEnabled, false, replicationID, storageID),
},
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
Labels: getExternalResourceLabels("VolumeGroupReplicationClass", replicationEnabled, false, replicationID, storageID),
},
Labels: getExternalResourceLabels("VolumeSnapshotClass", replicationEnabled, false, replicationID, storageID),
},

&pb.ExternalResource{
Name: "cephfs",
Kind: "VolumeGroupSnapshotClass",
Data: mustMarshal(map[string]string{
"csi.storage.k8s.io/group-snapshotter-secret-name": provisionerSecretName,
})},
}),
Labels: getExternalResourceLabels("VolumeGroupReplicationClass", replicationEnabled, false, replicationID, storageID),
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
Labels: getExternalResourceLabels("VolumeGroupReplicationClass", replicationEnabled, false, replicationID, storageID),
Labels: getExternalResourceLabels("VolumeGroupSnapshotClass", replicationEnabled, false, replicationID, storageID),

Comment on lines 776 to 798
&pb.ExternalResource{
Name: "ceph-rbd",
Kind: "VolumeGroupReplicationClass",
Data: mustMarshal(map[string]string{
"replication.storage.openshift.io/group-replication-secret-name": provisionerSecretName,
"mirroringMode": "snapshot",
}),
Labels: getExternalResourceLabels("VolumeGroupReplicationClass", mirroringEnabled, false, replicationID, storageID),
Annotations: map[string]string{
"replication.storage.openshift.io/is-default-class": "true",
},
},
&pb.ExternalResource{
Name: "ceph-rbd-flatten",
Kind: "VolumeGroupReplicationClass",
Data: mustMarshal(map[string]string{
"replication.storage.openshift.io/group-replication-secret-name": provisionerSecretName,
"mirroringMode": "snapshot",
"flattenMode": "force",
}),
Labels: getExternalResourceLabels("VolumeGroupReplicationClass", mirroringEnabled, true, replicationID, storageID),
Annotations: map[string]string{},
},
Copy link
Member

Choose a reason for hiding this comment

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

we dont have voluemegroupreplicationclass in 4.18 isnt it? can we remove this and add it later?

&pb.ExternalResource{
Name: "cephfs",
Kind: "VolumeGroupSnapshotClass",
Data: mustMarshal(map[string]string{
"csi.storage.k8s.io/group-snapshotter-secret-name": provisionerSecretName,
})},
}),
Labels: getExternalResourceLabels("VolumeGroupSnapshotClass", replicationEnabled, false, replicationID, storageID),
Copy link
Member

Choose a reason for hiding this comment

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

IMO we should use consts for all class kinds, we are passing it as string in multiple places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you mean replace it in all places not just the function call -- I did that at first, but @nb-ohad opposed to the idea

}
case "VolumeSnapshotClass", "VolumeGroupSnapshotClass":
if isMirroringReplicationEnabled {
labels["ramendr.openshift.io/storageID"] = storageID
Copy link
Member

Choose a reason for hiding this comment

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

can we have a const for the label keys?

- Sends two V*RCs (one for image flattening) for RDR
- Labels V*RepClass, V*SnapClass and StorageClass

Signed-off-by: raaizik <[email protected]>
@raaizik raaizik requested a review from Madhu-1 November 10, 2024 15:29
@raaizik raaizik changed the title Sends and labels V*ReplicationClass, V*SnapClass, StorageClass to client Sends and labels VSnapReplicationClass, V*SnapClass, StorageClass to client Nov 10, 2024
@raaizik raaizik changed the title Sends and labels VSnapReplicationClass, V*SnapClass, StorageClass to client Sends and labels V*ReplicationClass, V*SnapClass, StorageClass to client Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants