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

Rewrite workload control flow of BatchRelease controller #90

Merged
merged 1 commit into from
Dec 1, 2022

Conversation

veophi
Copy link
Member

@veophi veophi commented Sep 30, 2022

Signed-off-by: mingzhou.swx [email protected]

Ⅰ. Describe what this PR does

Rewrite workload control flow of BatchRelease controller

Improve unit test of BatchRelease controller

@codecov-commenter
Copy link

codecov-commenter commented Sep 30, 2022

Codecov Report

Merging #90 (cb20e8d) into master (0c54037) will increase coverage by 11.06%.
The diff coverage is 53.60%.

@@             Coverage Diff             @@
##           master      #90       +/-   ##
===========================================
+ Coverage   21.86%   32.93%   +11.06%     
===========================================
  Files          38       38               
  Lines        4120     3486      -634     
===========================================
+ Hits          901     1148      +247     
+ Misses       3056     2133      -923     
- Partials      163      205       +42     
Flag Coverage Δ
unittests 32.93% <53.60%> (+11.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/controller/batchrelease/batchrelease_util.go 34.21% <0.00%> (+29.29%) ⬆️
pkg/controller/batchrelease/labelpatch/patcher.go 0.00% <0.00%> (ø)
pkg/controller/rollout/canary.go 0.00% <0.00%> (ø)
pkg/controller/rollout/progressing.go 11.02% <ø> (ø)
pkg/util/controller_finder.go 0.00% <0.00%> (ø)
pkg/util/workloads_utils.go 20.30% <0.00%> (-5.18%) ⬇️
...g/controller/batchrelease/batchrelease_executor.go 46.45% <33.33%> (ø)
...chrelease/control/canarystyle/deployment/stable.go 35.48% <35.48%> (ø)
pkg/controller/batchrelease/batchrelease_status.go 60.86% <50.00%> (+60.86%) ⬆️
...release/control/partitionstyle/cloneset/control.go 60.41% <60.41%> (ø)
... and 12 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

pkg/controller/batchrelease/batchrelease_controller.go Outdated Show resolved Hide resolved
@@ -65,7 +66,7 @@ func (r *Executor) syncStatusBeforeExecuting(release *v1alpha1.BatchRelease, new
// handle the case that release plan is changed during progressing
reason = "PlanChanged"
message = "release plan is changed, then recalculate status"
signalRecalculate(release, newStatus)
utils.SignalRecalculate(release, newStatus)

case isPlanUnhealthy(release):
Copy link
Member

Choose a reason for hiding this comment

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

What means is unhealthy? What scenarios can lead to unhealthy and how to get back to normal?

Copy link
Member Author

Choose a reason for hiding this comment

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

What means is unhealthy?

  1. currentStepIndex > len(steps).

In this scene, we will try to restart from beginning.

pkg/controller/batchrelease/batchrelease_plan_executor.go Outdated Show resolved Hide resolved
pkg/controller/batchrelease/batchrelease_plan_executor.go Outdated Show resolved Hide resolved
klog.InfoS("using statefulset-like batch release controller for this batch release", "workload name", targetKey.Name, "namespace", targetKey.Namespace)
return workloads.NewUnifiedWorkloadRolloutControlPlane(workloads.NewStatefulSetLikeController, r.client, r.recorder, release, newStatus, targetKey, gvk), nil
return batchstyle.NewControlPlane(statefulset.NewController, r.client, r.recorder, release, newStatus, targetKey, gvk), nil
}

func (r *Executor) moveToNextBatch(release *v1alpha1.BatchRelease, status *v1alpha1.BatchReleaseStatus) bool {
Copy link
Member

Choose a reason for hiding this comment

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

To simplify the logic, i think when batchPartition is nil, do not execute any batch.

@@ -124,38 +123,38 @@ func (r *Executor) executeBatchReleasePlan(release *v1alpha1.BatchRelease, newSt
switch {
Copy link
Member

Choose a reason for hiding this comment

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

When progressDone is true, i think it do not come into Finalizing, but rather just to Completed. Finalizing State feel like it can be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Finalizing state cannot be skipped.
Finalizing state will delete some resources/annotations and restore some configuration for workloads.

pkg/util/workloads_utils.go Outdated Show resolved Hide resolved
pkg/util/expectation/resource_expectations.go Outdated Show resolved Hide resolved
pkg/controller/batchrelease/utils/utils.go Outdated Show resolved Hide resolved
pkg/controller/batchrelease/control/interface.go Outdated Show resolved Hide resolved
pkg/controller/batchrelease/labelpatch/patcher.go Outdated Show resolved Hide resolved
pkg/util/expectation/resource_expectations.go Outdated Show resolved Hide resolved
pkg/util/workloads_utils.go Outdated Show resolved Hide resolved
pkg/controller/batchrelease/control/util.go Show resolved Hide resolved
@veophi veophi force-pushed the rewrite-2 branch 2 times, most recently from 20c7728 to 3411a4d Compare November 30, 2022 05:58
@veophi veophi force-pushed the rewrite-2 branch 10 times, most recently from aec049b to 2dbe53d Compare December 1, 2022 04:02
@@ -48,6 +48,7 @@ type BatchReleaseSpec struct {
// default is false
// +optional
Paused bool `json:"paused,omitempty"`
Cancel bool `json:"cancel,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Please add comments for Cancel.

pkg/controller/rollout/batchrelease/inner_batchrelease.go Outdated Show resolved Hide resolved
@veophi veophi force-pushed the rewrite-2 branch 2 times, most recently from 63ef2df to b1be12f Compare December 1, 2022 04:59
Copy link
Member

@zmberg zmberg left a comment

Choose a reason for hiding this comment

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

/lgtm

Signed-off-by: mingzhou.swx <[email protected]>
Copy link
Member

@furykerry furykerry left a comment

Choose a reason for hiding this comment

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

/lgtm

@furykerry
Copy link
Member

/approve

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: furykerry

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

@kruise-bot kruise-bot merged commit c0b1fea into openkruise:master Dec 1, 2022
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.

5 participants