-
Notifications
You must be signed in to change notification settings - Fork 184
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
base: main
Are you sure you want to change the base?
Changes from all commits
c3962bf
9981d3f
3ddc10e
caf994f
cf64001
f94842c
16567e0
2a2966d
4285d88
589adca
027c6d9
40a77d5
bca059b
7ad342b
90b8f22
6fc8514
6439d9d
d8e34de
60456ae
9dadfa8
2e630a9
88cec5a
b0e9c70
12ffec8
9a6c1b9
aa3010a
198ac42
2fe6d1f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
Copyright (C) 2022-2024 ApeCloud Co., Ltd | ||
|
||
This file is part of KubeBlocks project | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
|
||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
// Package v1 contains API Schema definitions for the base v1 API group | ||
// +kubebuilder:object:generate=true | ||
// +groupName=base.kubeblocks.io | ||
package v1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects | ||
GroupVersion = schema.GroupVersion{Group: "base.kubeblocks.io", Version: "v1"} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
Copyright (C) 2022-2024 ApeCloud Co., Ltd | ||
|
||
This file is part of KubeBlocks project | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
|
||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package v1 | ||
|
||
// ReplicaRole represents a role that can be assigned to a component instance, defining its behavior and responsibilities. | ||
type ReplicaRole struct { | ||
// Name defines the role's unique identifier. This value is used to set the "apps.kubeblocks.io/role" label | ||
// on the corresponding object to identify its role. | ||
// | ||
// For example, common role names include: | ||
// - "leader": The primary/master instance that handles write operations | ||
// - "follower": Secondary/replica instances that replicate data from the leader | ||
// - "learner": Read-only instances that don't participate in elections | ||
// | ||
// This field is immutable once set. | ||
// | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=32 | ||
// +kubebuilder:validation:Pattern=`^.*[^\s]+.*$` | ||
Name string `json:"name"` | ||
|
||
// 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. | ||
// The default priority is 0. | ||
// | ||
// 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. Roles participate | ||
// in quorum should have higher update priority than roles do not participate in quorum. | ||
// The default value is false. | ||
// | ||
// 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"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe simplify to |
||
|
||
// 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. | ||
// The default value is false. | ||
// | ||
// This field is immutable once set. | ||
// | ||
// +kubebuilder:default=false | ||
// +optional | ||
SwitchoverBeforeUpdate bool `json:"switchoverBeforeUpdate"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What you mean is to use lifecycleaction's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If so, then this part of code can be removed. And there's only one place that needs role definition: instanceset controller uses roles to determine pod update sequence. |
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe
MaintenanceOrder