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

chore: switchover before updating or deleting pods #8731

Merged
merged 4 commits into from
Jan 8, 2025

Conversation

leon-inf
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the size/L Denotes a PR that changes 100-499 lines. label Dec 31, 2024
@leon-inf leon-inf force-pushed the support/switchover-before-update-pods branch from 79187b1 to f197612 Compare December 31, 2024 06:10
@github-actions github-actions bot added size/XXL Denotes a PR that changes 1000+ lines. and removed size/L Denotes a PR that changes 100-499 lines. labels Dec 31, 2024
@leon-inf leon-inf force-pushed the support/switchover-before-update-pods branch 4 times, most recently from a19a220 to 95b1c59 Compare December 31, 2024 08:57
Copy link

codecov bot commented Dec 31, 2024

Codecov Report

Attention: Patch coverage is 24.54212% with 206 lines in your changes missing coverage. Please review.

Project coverage is 61.34%. Comparing base (ed79737) to head (452645d).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
pkg/controller/component/its_convertor.go 0.00% 46 Missing ⚠️
pkg/controller/instanceset/reconciler_update.go 10.63% 41 Missing and 1 partial ⚠️
pkg/controllerutil/workload_utils.go 0.00% 37 Missing ⚠️
pkg/controllerutil/volume_util.go 0.00% 24 Missing ⚠️
pkg/controller/builder/builder_instance_set.go 0.00% 17 Missing ⚠️
pkg/controller/lifecycle/kbagent.go 42.85% 16 Missing ⚠️
pkg/controller/factory/builder.go 64.70% 4 Missing and 2 partials ⚠️
pkg/controller/lifecycle/lfa_component.go 60.00% 3 Missing and 1 partial ⚠️
pkg/controller/lifecycle/lfa_member.go 0.00% 4 Missing ⚠️
controllers/apps/transformer_component_workload.go 66.66% 3 Missing ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8731      +/-   ##
==========================================
+ Coverage   60.80%   61.34%   +0.53%     
==========================================
  Files         377      378       +1     
  Lines       45615    46649    +1034     
==========================================
+ Hits        27738    28616     +878     
- Misses      15255    15373     +118     
- Partials     2622     2660      +38     
Flag Coverage Δ
unittests 61.34% <24.54%> (+0.53%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leon-inf leon-inf force-pushed the support/switchover-before-update-pods branch from 95b1c59 to cd659d6 Compare January 2, 2025 02:24
@leon-inf leon-inf marked this pull request as ready for review January 2, 2025 02:26
@leon-inf leon-inf requested review from free6om, a team and Y-Rookie as code owners January 2, 2025 02:26
@shanshanying shanshanying added this to the Release 1.0.0 milestone Jan 3, 2025
@cjc7373
Copy link
Contributor

cjc7373 commented Jan 3, 2025

If switchover action will be called in its controller, then IMO there's no need to call it in component controller.

trySwitchover := func(lfa lifecycle.Lifecycle, pod *corev1.Pod) error {
err := lfa.Switchover(r.reqCtx.Ctx, r.cli, nil, "")
if err != nil {
if errors.Is(err, lifecycle.ErrActionNotDefined) {
return nil
}
return err
}
r.reqCtx.Log.Info("successfully call switchover action for pod", "pod", pod.Name)
return nil
}

@apecloud-bot apecloud-bot added the approved PR Approved Test label Jan 7, 2025
// Defines the procedure for a controlled transition of a role to a new replica.
//
// +optional
Switchover *kbappsv1.Action `json:"switchover,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mark the original SwitchoverAction field as deprecated? Or remove it directly (as it's not implemented yet), currently these two fields appear confusing.

}
return m
}()
lfa, err := lifecycle.New(its.Namespace, its.Name, its.Name, lifecycleActions, templateVars, pod)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the second parameter of lifecycle.New be clusterName?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@apecloud-bot apecloud-bot removed the approved PR Approved Test label Jan 8, 2025
@leon-inf
Copy link
Contributor Author

leon-inf commented Jan 8, 2025

If switchover action will be called in its controller, then IMO there's no need to call it in component controller.

trySwitchover := func(lfa lifecycle.Lifecycle, pod *corev1.Pod) error {
err := lfa.Switchover(r.reqCtx.Ctx, r.cli, nil, "")
if err != nil {
if errors.Is(err, lifecycle.ErrActionNotDefined) {
return nil
}
return err
}
r.reqCtx.Log.Info("successfully call switchover action for pod", "pod", pod.Name)
return nil
}

The its controller cannot handle scale-in/out changes currently.

@leon-inf
Copy link
Contributor Author

leon-inf commented Jan 8, 2025

/approve

@apecloud-bot apecloud-bot added the approved PR Approved Test label Jan 8, 2025
@leon-inf leon-inf merged commit fd21c31 into main Jan 8, 2025
36 checks passed
@leon-inf leon-inf deleted the support/switchover-before-update-pods branch January 8, 2025 03:02
@leon-inf
Copy link
Contributor Author

leon-inf commented Jan 8, 2025

/cherry-pick release-1.0-beta

@apecloud-bot
Copy link
Collaborator

🤖 says: Error cherry-picking.

Auto-merging apis/apps/v1/zz_generated.deepcopy.go
Auto-merging apis/workloads/v1/instanceset_types.go
Auto-merging config/crd/bases/operations.kubeblocks.io_opsrequests.yaml
Auto-merging config/crd/bases/workloads.kubeblocks.io_instancesets.yaml
Auto-merging controllers/apps/transformer_component_workload.go
Auto-merging deploy/helm/crds/operations.kubeblocks.io_opsrequests.yaml
Auto-merging deploy/helm/crds/workloads.kubeblocks.io_instancesets.yaml
Auto-merging docs/developer_docs/api-reference/cluster.md
Auto-merging pkg/controller/instanceset/instance_util.go
Auto-merging pkg/controller/instanceset/reconciler_update.go
Auto-merging pkg/controller/lifecycle/kbagent.go
CONFLICT (content): Merge conflict in pkg/controller/lifecycle/kbagent.go
Auto-merging pkg/controller/lifecycle/lfa_member.go
CONFLICT (content): Merge conflict in pkg/controller/lifecycle/lfa_member.go
Auto-merging pkg/operations/switchover.go
CONFLICT (content): Merge conflict in pkg/operations/switchover.go
error: could not apply fd21c31... chore: switchover before updating or deleting pods (#8731)
hint: After resolving the conflicts, mark them with
hint: "git add/rm ", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config advice.mergeConflict false"

@apecloud-bot
Copy link
Collaborator

🤖 says: ‼️ cherry pick action failed.
See: https://github.com/apecloud/kubeblocks/actions/runs/12663267985

@leon-inf
Copy link
Contributor Author

leon-inf commented Jan 8, 2025

/cherry-pick release-1.0-beta

@apecloud-bot
Copy link
Collaborator

🤖 says: cherry pick action finished successfully 🎉!
See: https://github.com/apecloud/kubeblocks/actions/runs/12665426874

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved PR Approved Test size/XXL Denotes a PR that changes 1000+ lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants