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

feat: refactor cmpd's role definition #8416

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Conversation

cjc7373
Copy link
Contributor

@cjc7373 cjc7373 commented Nov 6, 2024

fixes #8377

@github-actions github-actions bot added the size/XXL Denotes a PR that changes 1000+ lines. label Nov 6, 2024
@cjc7373 cjc7373 changed the title feat: refactor role feat: refactor cmpd's role definition Nov 6, 2024
Copy link

codecov bot commented Nov 7, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 51 lines in your changes missing coverage. Please review.

Project coverage is 61.15%. Comparing base (bc7dd2f) to head (12ffec8).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pkg/operations/switchover_util.go 0.00% 23 Missing ⚠️
controllers/apps/transformer_component_workload.go 43.75% 6 Missing and 3 partials ⚠️
pkg/controller/component/lifecycle/lfa_member.go 0.00% 8 Missing ⚠️
...controller/builder/builder_component_definition.go 0.00% 5 Missing ⚠️
apis/operations/v1alpha1/opsrequest_validation.go 0.00% 3 Missing ⚠️
pkg/operations/switchover.go 0.00% 2 Missing ⚠️
pkg/controller/component/its_convertor.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8416      +/-   ##
==========================================
- Coverage   61.22%   61.15%   -0.07%     
==========================================
  Files         351      351              
  Lines       41854    41828      -26     
==========================================
- Hits        25624    25581      -43     
- Misses      13906    13921      +15     
- Partials     2324     2326       +2     
Flag Coverage Δ
unittests 61.15% <40.00%> (-0.07%) ⬇️

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.

@cjc7373 cjc7373 marked this pull request as ready for review November 8, 2024 09:49
//
// +kubebuilder:default=0
// +optional
UpdatePriority int `json:"updatePriority"`
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe MaintenanceOrder

//
// +kubebuilder:default=false
// +optional
SwitchoverBeforeUpdate bool `json:"switchoverBeforeUpdate"`
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe SwitchoverBeforeMaintenance or NeedSwitchover

Copy link
Contributor

Choose a reason for hiding this comment

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

How about remove this option and decide within the switchover action whether a switchover is necessary based on the role of target pod?

//
// +kubebuilder:default=false
// +optional
ParticipatesInQuorum bool `json:"participatesInQuorum"`
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe simplify to InQuorum

controllers/apps/transformer_component_workload.go Outdated Show resolved Hide resolved
controllers/apps/transformer_component_workload.go Outdated Show resolved Hide resolved
@@ -232,7 +232,16 @@ func (r *RestoreManager) DoPostReady(comp *component.SynthesizedComponent,
backupObj *dpv1alpha1.Backup) error {
jobActionLabels := constant.GetCompLabels(r.Cluster.Name, comp.Name)
if len(comp.Roles) > 0 {
jobActionLabels[instanceset.AccessModeLabelKey] = string(appsv1alpha1.ReadWrite)
// HACK: assume the role with highest priority to be writable
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to let the data-protection define a policy to select target pods explicitly.


// getTargetRole returns the role on which the switchover is performed
// FIXME: the assumption that only one role supports switchover may change in the future
func getTargetRoleName(roles []appsv1.ReplicaRole) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to infer the target pods, just let the user specify the specific roles or pods.

return "", fmt.Errorf("more than one role defined as leader: %s,%s", targetRole, role.Name)
}
targetRole = role.Name
// HACK: assume the role with highest priority to be leader
Copy link
Contributor

Choose a reason for hiding this comment

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

All of the legacy codes can be removed.

@@ -291,6 +293,9 @@ type InstanceSetStatus struct {

// Indicates whether it is required for the InstanceSet to have at least one primary instance ready.
//
// Deprecated: since instanceset no longer checks a "primary" role when doing ready check, this
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the field directly.

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

Successfully merging this pull request may close these issues.

[Improvement] refactor cmpd's roles
3 participants