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

[Improvement] refactor cmpd's roles #8377

Open
cjc7373 opened this issue Oct 31, 2024 · 0 comments · May be fixed by #8416
Open

[Improvement] refactor cmpd's roles #8377

cjc7373 opened this issue Oct 31, 2024 · 0 comments · May be fixed by #8416
Assignees
Labels
kind/enhancement New feature or request

Comments

@cjc7373
Copy link
Contributor

cjc7373 commented Oct 31, 2024

Currently, KB assumes a special role "leader", inferred from a role that has serviceable and writable equals true. This "leader" role does not seem to be proper in some cases:

  • When updating pods with memberUpdateStrategy equals to bestEffortParallel, we need to determine quorum to make service available. Currently quorum is deduced by the votable role. However, there can be roles that are votable but do not participate in quorum.
  • When determining if a component is available, currently we check if there's a leader. That's not always the case, e.g. when a component is read-only and no leader is required.
  • When doing upgrade or sacle in, currenly we check if there's leader pod that needs switchover. That's also not always true because other roles may need switchover too.

As per suggested in #7757, I'll refactor a role to include the following fields:

// UpdatePriority determines the order in which pods with different roles are updated.
// Pods are sorted by this priority (higher numbers = higher priority) and updated accordingly.
// Roles with the highest priority will be updated last.
//
// For example:
// - Leader role may have priority 2 (updated last)
// - Follower role may have priority 1 (updated before leader)
// - Learner role may have priority 0 (updated first)
//
// This field is immutable once set.
//
// +kubebuilder:default=0
// +optional
UpdatePriority int `json:"updatePriority"`

// ParticipatesInQuorum indicates if pods with this role are counted when determining quorum.
// This affects update strategies that need to maintain quorum for availability.
//
// For example, in a 5-pod component where:
// - 2 learner pods (participatesInQuorum=false)
// - 2 follower pods (participatesInQuorum=true)
// - 1 leader pod (participatesInQuorum=true)
// The quorum size would be 3 (based on the 3 participating pods), allowing parallel updates
// of 2 learners and 1 follower while maintaining quorum.
//
// This field is immutable once set.
//
// +kubebuilder:default=false
// +optional
ParticipatesInQuorum bool `json:"participatesInQuorum"`

// SwitchoverBeforeUpdate indicates if a role switchover operation should be performed before
// updating or scaling in pods with this role. This is typically used for leader roles to
// ensure minimal disruption during updates.
//
// This field is immutable once set.
//
// +kubebuilder:default=false
// +optional
SwitchoverBeforeUpdate bool `json:"switchoverBeforeUpdate"`

Update: Required field is deleted since the availability of a component will be determined in the Available probe.

@cjc7373 cjc7373 added the kind/enhancement New feature or request label Oct 31, 2024
@cjc7373 cjc7373 self-assigned this Oct 31, 2024
@cjc7373 cjc7373 linked a pull request Nov 6, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant