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: graceful group member change #12

Merged
merged 16 commits into from
Dec 10, 2024
40 changes: 36 additions & 4 deletions api/v1/cachegroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,32 @@ import (
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

type CacheDirType string

var (
CacheDirTypeHostPath CacheDirType = "HostPath"
CacheDirTypePVC CacheDirType = "PVC"
)

type CacheDir struct {
// +kubebuilder:validation:Enum=HostPath;PVC
Type CacheDirType `json:"type,omitempty"`
// required for HostPath type
// +optional
Path string `json:"path,omitempty"`
// required for PVC type
// +optional
Name string `json:"name,omitempty"`
}

// CacheGroupWorkerTemplate defines cache group worker template
type CacheGroupWorkerTemplate struct {
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
ServiceAccountName string `json:"serviceAccountName,omitempty"`
HostNetwork *bool `json:"hostNetwork,omitempty"`
SchedulerName string `json:"schedulerName,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
CacheDirs []CacheDir `json:"cacheDirs,omitempty"`

// Container image.
// More info: https://kubernetes.io/docs/concepts/containers/images
Expand Down Expand Up @@ -121,6 +140,14 @@ type CacheGroupSpec struct {
CleanCache bool `json:"cleanCache,omitempty"`
CacheGroup string `json:"cacheGroup,omitempty"`
Worker CacheGroupWorkerSpec `json:"worker,omitempty"`
// Duration for new node to join cluster with group-backup option
// Default is 10 minutes
// +optional
BackupDuration *metav1.Duration `json:"backupDuration,omitempty"`
// Maximum time to wait for data migration when deleting
// Default is 1 hour
// +optional
WaitingDeletedMaxDuration *metav1.Duration `json:"waitingDeletedMaxDuration,omitempty"`
}

type CacheGroupPhase string
Expand All @@ -145,17 +172,22 @@ type CacheGroupStatus struct {
Phase CacheGroupPhase `json:"phase,omitempty"`
Conditions []CacheGroupCondition `json:"conditions,omitempty"`

ReadyWorker int32 `json:"readyWorker,omitempty"`
ExpectWorker int32 `json:"expectWorker,omitempty"`
ReadyStr string `json:"readyStr,omitempty"`
CacheGroup string `json:"cacheGroup,omitempty"`
FileSystem string `json:"fileSystem,omitempty"`
ReadyWorker int32 `json:"readyWorker,omitempty"`
BackUpWorker int32 `json:"backUpWorker,omitempty"`
WaitingDeletedWorker int32 `json:"waitingDeletedWorker,omitempty"`
ExpectWorker int32 `json:"expectWorker,omitempty"`
ReadyStr string `json:"readyStr,omitempty"`
CacheGroup string `json:"cacheGroup,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=cg
// +kubebuilder:printcolumn:name="Cache Group",type="string",JSONPath=".status.cacheGroup"
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"
// +kubebuilder:printcolumn:name="Back up",type="string",JSONPath=".status.backUpWorker"
// +kubebuilder:printcolumn:name="Waiting Deleted",type="string",JSONPath=".status.WaitingDeletedWorker"
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.readyStr"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// CacheGroup is the Schema for the cachegroups API
Expand Down
31 changes: 31 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions config/crd/bases/juicefs.io_cachegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ spec:
- jsonPath: .status.phase
name: Phase
type: string
- jsonPath: .status.backUpWorker
name: Back up
type: string
- jsonPath: .status.WaitingDeletedWorker
name: Waiting Deleted
type: string
- jsonPath: .status.readyStr
name: Ready
type: string
Expand All @@ -41,6 +47,8 @@ spec:
type: object
spec:
properties:
backupDuration:
type: string
cacheGroup:
type: string
cleanCache:
Expand Down Expand Up @@ -72,11 +80,27 @@ spec:
type:
type: string
type: object
waitingDeletedMaxDuration:
type: string
worker:
properties:
overwrite:
items:
properties:
cacheDirs:
items:
properties:
name:
type: string
path:
type: string
type:
enum:
- HostPath
- PVC
type: string
type: object
type: array
dnsPolicy:
type: string
env:
Expand Down Expand Up @@ -1471,6 +1495,20 @@ spec:
type: array
template:
properties:
cacheDirs:
items:
properties:
name:
type: string
path:
type: string
type:
enum:
- HostPath
- PVC
type: string
type: object
type: array
dnsPolicy:
type: string
env:
Expand Down Expand Up @@ -2862,6 +2900,9 @@ spec:
type: object
status:
properties:
backUpWorker:
format: int32
type: integer
cacheGroup:
type: string
conditions:
Expand All @@ -2883,13 +2924,18 @@ spec:
expectWorker:
format: int32
type: integer
fileSystem:
type: string
phase:
type: string
readyStr:
type: string
readyWorker:
format: int32
type: integer
waitingDeletedWorker:
format: int32
type: integer
type: object
type: object
served: true
Expand Down
46 changes: 46 additions & 0 deletions dist/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ spec:
- jsonPath: .status.phase
name: Phase
type: string
- jsonPath: .status.backUpWorker
name: Back up
type: string
- jsonPath: .status.WaitingDeletedWorker
name: Waiting Deleted
type: string
- jsonPath: .status.readyStr
name: Ready
type: string
Expand All @@ -40,6 +46,8 @@ spec:
type: object
spec:
properties:
backupDuration:
type: string
cacheGroup:
type: string
cleanCache:
Expand Down Expand Up @@ -71,11 +79,27 @@ spec:
type:
type: string
type: object
waitingDeletedMaxDuration:
type: string
worker:
properties:
overwrite:
items:
properties:
cacheDirs:
items:
properties:
name:
type: string
path:
type: string
type:
enum:
- HostPath
- PVC
type: string
type: object
type: array
dnsPolicy:
type: string
env:
Expand Down Expand Up @@ -1470,6 +1494,20 @@ spec:
type: array
template:
properties:
cacheDirs:
items:
properties:
name:
type: string
path:
type: string
type:
enum:
- HostPath
- PVC
type: string
type: object
type: array
dnsPolicy:
type: string
env:
Expand Down Expand Up @@ -2861,6 +2899,9 @@ spec:
type: object
status:
properties:
backUpWorker:
format: int32
type: integer
cacheGroup:
type: string
conditions:
Expand All @@ -2882,13 +2923,18 @@ spec:
expectWorker:
format: int32
type: integer
fileSystem:
type: string
phase:
type: string
readyStr:
type: string
readyWorker:
format: int32
type: integer
waitingDeletedWorker:
format: int32
type: integer
type: object
type: object
served: true
Expand Down
Loading
Loading