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

maintenance: remove hardcoded crd constants in restoreCrd #354

Merged
merged 1 commit into from
Feb 17, 2025

Conversation

OdedViner
Copy link
Contributor

@OdedViner OdedViner commented Jan 30, 2025

Refactored the RestoreCrd function to accept groupName and
versionResource as parameters instead of relying on the hardcoded
constants crds.CephRookIoGroup and crds.CephRookResourcesVersion.
This improves flexibility and allows the function to handle
different CRDs dynamically.

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Reviewed the developer guide on Submitting a Pull Request
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.

Copy link
Member

@travisn travisn left a comment

Choose a reason for hiding this comment

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

In the kubectl-rook-ceph repo we will only want to include upstream Rook resources. Instead, I would suggest that this ResourceCrd() method could accept arguments for a resource group name. In this repo the command will only set the ceph.rook.io group, while external repos that are extending this code could pass a different group name.

@OdedViner OdedViner force-pushed the add_ocs_crs branch 3 times, most recently from 72aafbd to 1b30ff8 Compare February 2, 2025 10:31
@@ -31,6 +31,6 @@ var RestoreCmd = &cobra.Command{
verifyOperatorPodIsRunning(cmd.Context(), clientSets)
},
Run: func(cmd *cobra.Command, args []string) {
restore.RestoreCrd(cmd.Context(), clientSets, operatorNamespace, cephClusterNamespace, args)
restore.RestoreCrd(cmd.Context(), clientSets, operatorNamespace, cephClusterNamespace, nil, nil, args)
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
restore.RestoreCrd(cmd.Context(), clientSets, operatorNamespace, cephClusterNamespace, nil, nil, args)
restore.RestoreCrd(cmd.Context(), clientSets, operatorNamespace, cephClusterNamespace, crds.CephRookIoGroup, crds.CephRookResourcesVersion, args)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -32,7 +32,8 @@ import (
"k8s.io/apimachinery/pkg/types"
)

func RestoreCrd(ctx context.Context, k8sclientset *k8sutil.Clientsets, operatorNamespace, clusterNamespace string, args []string) {
func RestoreCrd(ctx context.Context, k8sclientset *k8sutil.Clientsets, operatorNamespace, clusterNamespace string,
groupNameOptional, versionResourceOptional *string, args []string) {
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 just require these names, it seems simpler this way.

Suggested change
groupNameOptional, versionResourceOptional *string, args []string) {
groupName, versionResource string, args []string) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

crdList, err := k8sclientset.ListResourcesDynamically(ctx, crds.CephRookIoGroup, crds.CephRookResourcesVersion, crd, clusterNamespace)
var groupName, versionResource string
// Set default values for groupName and versionResource
if groupNameOptional == nil || versionResourceOptional == nil {
Copy link
Member

Choose a reason for hiding this comment

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

No need for these checks if we just require them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

@subhamkrai subhamkrai left a comment

Choose a reason for hiding this comment

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

Also, fix the CI issues

@OdedViner OdedViner force-pushed the add_ocs_crs branch 2 times, most recently from 01d0437 to 3648b9a Compare February 6, 2025 14:37
@OdedViner OdedViner changed the title WIP: Enhance RestoreCrd to Support OCS CRs Alongside Rook CRs restore: remove hardcoded crd constants in restoreCrd Feb 6, 2025
@OdedViner OdedViner changed the title restore: remove hardcoded crd constants in restoreCrd maintenance: remove hardcoded crd constants in restoreCrd Feb 6, 2025
Copy link
Member

@travisn travisn left a comment

Choose a reason for hiding this comment

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

Still a CI issue, but not sure it's related or intermittent. When you push this small fix, let's see if it passes

@@ -32,7 +32,8 @@ import (
"k8s.io/apimachinery/pkg/types"
)

func RestoreCrd(ctx context.Context, k8sclientset *k8sutil.Clientsets, operatorNamespace, clusterNamespace string, args []string) {
func RestoreCrd(ctx context.Context, k8sclientset *k8sutil.Clientsets, operatorNamespace, clusterNamespace string,
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
func RestoreCrd(ctx context.Context, k8sclientset *k8sutil.Clientsets, operatorNamespace, clusterNamespace string,
func RestoreCrd(ctx context.Context, k8sclientset *k8sutil.Clientsets, operatorNamespace, clusterNamespace,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Refactored the RestoreCrd function to accept groupName and
versionResource as parameters instead of relying on the hardcoded
constants crds.CephRookIoGroup and crds.CephRookResourcesVersion.
This improves flexibility and allows the function to handle
different CRDs dynamically.

Signed-off-by: Oded Viner <[email protected]>
@subhamkrai subhamkrai requested a review from travisn February 10, 2025 09:58
@travisn travisn merged commit 0743f00 into rook:master Feb 17, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants