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

🐛 fix feature gate merges in ConvertToFeatureGateAPI #446

Conversation

TylerGillson
Copy link
Contributor

Summary

Prior to this PR, ConvertToFeatureGateAPI was incorrectly merging feature gates specified via the --feature-gates command line flag with the default feature flag sets.

  • When users specifically enable a feature that's enabled by default, the feature is dropped
  • When users enable a feature gate that that's disabled by default, all enabled-by-default features are dropped

The unit tests added in this PR fail against main as follows:

Running tool: /opt/homebrew/bin/go test -timeout 30s -run ^TestConvertToFeatureGateAPI$ open-cluster-management.io/clusteradm/pkg/genericclioptions -v

=== RUN   TestConvertToFeatureGateAPI
=== RUN   TestConvertToFeatureGateAPI/disable_default_feature_gate
    /Users/tylergillson/spectrocloud/repos/oss/ocm/clusteradm/pkg/genericclioptions/feature_gates_test.go:89: expected [], got [{AddonManagement Disable}]
=== RUN   TestConvertToFeatureGateAPI/enable_default_feature_gate
    /Users/tylergillson/spectrocloud/repos/oss/ocm/clusteradm/pkg/genericclioptions/feature_gates_test.go:89: expected [{AddonManagement Enable}], got []
=== RUN   TestConvertToFeatureGateAPI/enable_non-default_feature_gate
=== RUN   TestConvertToFeatureGateAPI/enable_non-default_feature_gate,_ensure_default_feature_gates_remain_enabled
    /Users/tylergillson/spectrocloud/repos/oss/ocm/clusteradm/pkg/genericclioptions/feature_gates_test.go:89: expected [{AddonManagement Enable} {ClusterClaim Enable} {MultipleHubs Enable}], got [{MultipleHubs Enable}]
--- FAIL: TestConvertToFeatureGateAPI (0.00s)
    --- FAIL: TestConvertToFeatureGateAPI/disable_default_feature_gate (0.00s)
    --- FAIL: TestConvertToFeatureGateAPI/enable_default_feature_gate (0.00s)
    --- PASS: TestConvertToFeatureGateAPI/enable_non-default_feature_gate (0.00s)
    --- FAIL: TestConvertToFeatureGateAPI/enable_non-default_feature_gate,_ensure_default_feature_gates_remain_enabled (0.00s)
FAIL
FAIL	open-cluster-management.io/clusteradm/pkg/genericclioptions	0.730s

Now all flags are enabled, whether user-specified or enabled-by-default. Any disabled flags are simply not specified.

However, the original intention of the ConvertToFeatureGateAPI was unclear. Perhaps users should have to manually specify all desired flags instead of merging the two sets?

Related issue(s)

Fixes #

@openshift-ci openshift-ci bot requested review from itdove and ycyaoxdu June 29, 2024 18:33
Copy link
Member

@mikeshng mikeshng left a comment

Choose a reason for hiding this comment

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

/lgtm

Thank you for your fix and detailed PR explannation.
Your fixes makes sense to me.

/assign @qiujian16

Copy link
Member

@qiujian16 qiujian16 left a comment

Choose a reason for hiding this comment

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

/approve

@openshift-ci openshift-ci bot added the approved label Jul 3, 2024
@qiujian16
Copy link
Member

Perhaps users should have to manually specify all desired flags instead of merging the two sets?

The original idea is to let user set additional feature gate in addition to default ones.

@openshift-ci openshift-ci bot removed the lgtm label Jul 3, 2024
@TylerGillson TylerGillson requested a review from qiujian16 July 3, 2024 14:17
@TylerGillson TylerGillson force-pushed the fix/feature-gate-conversion branch from ff00aa1 to 75245d1 Compare July 3, 2024 14:38
Copy link
Member

@mikeshng mikeshng 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 Jul 3, 2024
Copy link

openshift-ci bot commented Jul 3, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mikeshng, qiujian16, TylerGillson

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

@openshift-merge-bot openshift-merge-bot bot merged commit 76e9b28 into open-cluster-management-io:main Jul 4, 2024
8 checks passed
@TylerGillson TylerGillson deleted the fix/feature-gate-conversion branch July 4, 2024 13:52
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.

3 participants