karmada icon indicating copy to clipboard operation
karmada copied to clipboard

Refactor the func and event of taint cluster

Open Poor12 opened this issue 2 years ago • 1 comments

Signed-off-by: Poor12 [email protected]

What type of PR is this? /kind cleanup

What this PR does / why we need it: Refactor:

  1. Now the former UpdateClusterControllerTaint is an unclear naming. Changed to UpdateClusterTaints.
  2. UpdateClusterControllerTaint do two things. The first is generate the updated taints based on the taintsAdd and taintsRemove. The Second is update the cluster taints which is generated above. Splitting functions makes responsibilities more single.
  3. updateClusterTaints should be a method of the cluster-controller by its responsibility. This is also good for joining events.
  4. RemoveTargetClusterFailed is triggered by updating the termating taint failure. It should be merged into TaintClusterFailed.
Events:
  Type    Reason               Age   From                Message
  ----    ------               ----  ----                -------
  Normal  TaintClusterSucceed  34s   cluster-controller  Taint cluster succeed: cluster now has taints([{cluster.karmada.io/not-ready  NoSchedule 2022-11-03 11:54:48.035154046 +0000 UTC m=+117.616029025}]).
  Normal  TaintClusterSucceed  34s   cluster-controller  Taint cluster succeed: cluster now has taints([]).

Which issue(s) this PR fixes: Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

`Instrumentation`: Introduced the `TaintClusterSucceed` event to `Cluster` object and merged `TaintClusterByConditionFailed` and `RemoveTargetClusterFailed` to `TaintClusterFailed`.

Poor12 avatar Nov 03 '22 12:11 Poor12

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: To complete the pull request process, please assign kevin-wangzefeng after the PR has been reviewed. You can assign the PR to them by writing /assign @kevin-wangzefeng in a comment when ready.

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 /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

karmada-bot avatar Nov 03 '22 12:11 karmada-bot

@jwcesign please take a look.

RainbowMango avatar Nov 26 '22 10:11 RainbowMango

/lgtm

jwcesign avatar Nov 29 '22 07:11 jwcesign

cc @RainbowMango

jwcesign avatar Dec 01 '22 01:12 jwcesign

/cc @RainbowMango

Poor12 avatar Dec 20 '22 11:12 Poor12

Hi @Poor12 Sorry for letting this sit, do you think this is still needed? If yes, could you please solve the conflicts, I can take a look this week.

RainbowMango avatar Jul 27 '23 02:07 RainbowMango

Thanks. I have solved the conflicts.

Poor12 avatar Jul 27 '23 02:07 Poor12

/hold The unit test is failing.

RainbowMango avatar Jul 28 '23 11:07 RainbowMango

=== RUN   TestSetCurrentClusterTaints
=== RUN   TestSetCurrentClusterTaints/ready_condition_from_true_to_false
=== RUN   TestSetCurrentClusterTaints/ready_condition_from_true_to_unknown
=== RUN   TestSetCurrentClusterTaints/ready_condition_from_false_to_unknown
=== RUN   TestSetCurrentClusterTaints/ready_condition_from_false_to_true
=== RUN   TestSetCurrentClusterTaints/ready_condition_from_unknown_to_true
=== RUN   TestSetCurrentClusterTaints/ready_condition_from_unknown_to_false
=== RUN   TestSetCurrentClusterTaints/clusterTaintsToAdd_is_nil_and_clusterTaintsToRemove_is_nil
    taint_test.go:115: Cluster gotTaints = [], want [{cluster.karmada.io/unreachable  NoExecute <nil>}]
--- FAIL: TestSetCurrentClusterTaints (0.00s)
    --- PASS: TestSetCurrentClusterTaints/ready_condition_from_true_to_false (0.00s)
    --- PASS: TestSetCurrentClusterTaints/ready_condition_from_true_to_unknown (0.00s)
    --- PASS: TestSetCurrentClusterTaints/ready_condition_from_false_to_unknown (0.00s)
    --- PASS: TestSetCurrentClusterTaints/ready_condition_from_false_to_true (0.00s)
    --- PASS: TestSetCurrentClusterTaints/ready_condition_from_unknown_to_true (0.00s)
    --- PASS: TestSetCurrentClusterTaints/ready_condition_from_unknown_to_false (0.00s)
    --- FAIL: TestSetCurrentClusterTaints/clusterTaintsToAdd_is_nil_and_clusterTaintsToRemove_is_nil (0.00s)

RainbowMango avatar Jul 28 '23 11:07 RainbowMango

/cc @XiShanYongYe-Chang for e2e.

Poor12 avatar Jul 31 '23 12:07 Poor12

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

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

karmada-bot avatar Aug 03 '23 02:08 karmada-bot

/hold cancel

RainbowMango avatar Aug 03 '23 02:08 RainbowMango