-
Notifications
You must be signed in to change notification settings - Fork 917
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
Restrict the cluster sync mode for the unjoin and unregister command #6081
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
Signed-off-by: zhzhuang-zju <[email protected]>
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #6081 +/- ##
==========================================
- Coverage 48.35% 48.31% -0.05%
==========================================
Files 666 666
Lines 54874 54903 +29
==========================================
- Hits 26535 26527 -8
- Misses 26615 26645 +30
- Partials 1724 1731 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
No data was changed or removed before this log, right? |
Yes, I put the validations ahead of the |
/retest |
func GetClusterSyncMode(controlPlaneKarmadaClient karmadaclientset.Interface, clusterName string) (clusterv1alpha1.ClusterSyncMode, error) { | ||
target, err := controlPlaneKarmadaClient.ClusterV1alpha1().Clusters().Get(context.TODO(), clusterName, metav1.GetOptions{}) | ||
if apierrors.IsNotFound(err) { | ||
return clusterv1alpha1.Push, fmt.Errorf("no cluster object %s found in karmada control Plane", clusterName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better for sycnmode to return an empty string when the returned err is not null?
The first is that it's easier to read and understand, and the second is that the handler of the mode function is improperly handled.
@@ -95,6 +96,19 @@ func DeleteClusterObject(controlPlaneKubeClient kubeclient.Interface, controlPla | |||
return err | |||
} | |||
|
|||
// GetClusterSyncMode return the sync mode of the member cluster. | |||
func GetClusterSyncMode(controlPlaneKarmadaClient karmadaclientset.Interface, clusterName string) (clusterv1alpha1.ClusterSyncMode, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, this function doesn't feel very necessary, and inconvenient to test
@@ -118,7 +118,7 @@ func TestRunUnJoinCluster(t *testing.T) { | |||
clusterConfig: &rest.Config{}, | |||
karmadaClient: fakekarmadaclient.NewSimpleClientset(), | |||
prep: func(_ kubeclient.Interface, _ kubeclient.Interface, karmadaClient karmadaclientset.Interface, _ *CommandUnjoinOption) error { | |||
karmadaClient.(*fakekarmadaclient.Clientset).Fake.PrependReactor("delete", "clusters", func(coretesting.Action) (bool, runtime.Object, error) { | |||
karmadaClient.(*fakekarmadaclient.Clientset).Fake.PrependReactor("get", "clusters", func(coretesting.Action) (bool, runtime.Object, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is delete changed to get because a query is added?
What type of PR is this?
/kind feature
What this PR does / why we need it:
Restrict the cluster sync mode for the unjoin and unregister command.
Which issue(s) this PR fixes:
Fixes #801
Special notes for your reviewer:
Does this PR introduce a user-facing change?: