Skip to content

Commit 6f4f79c

Browse files
Add server version in the Status. Add warnings on replica version divergence. (#116)
1 parent 3e02d53 commit 6f4f79c

26 files changed

Lines changed: 480 additions & 13 deletions

api/v1alpha1/clickhousecluster_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ type ClickHouseClusterStatus struct {
182182
// ObservedGeneration indicates latest generation observed by controller.
183183
// +operator-sdk:csv:customresourcedefinitions:type=status
184184
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
185+
// Version indicates the version reported by the container image.
186+
// +optional
187+
// +operator-sdk:csv:customresourcedefinitions:type=status
188+
Version string `json:"version,omitempty"`
185189
}
186190

187191
// ClickHouseCluster is the Schema for the `clickhouseclusters` API.
@@ -192,6 +196,7 @@ type ClickHouseClusterStatus struct {
192196
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message"
193197
// +kubebuilder:printcolumn:name="ReadyReplicas",type="number",JSONPath=".status.readyReplicas"
194198
// +kubebuilder:printcolumn:name="Replicas",type="number",JSONPath=".spec.replicas"
199+
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".status.version"
195200
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
196201
// +operator-sdk:csv:customresourcedefinitions:displayName="ClickHouse Cluster"
197202
// +operator-sdk:csv:customresourcedefinitions:resources={{Pod,v1}}

api/v1alpha1/conditions.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ const (
3838
ConditionTypeConfigurationInSync ConditionType = "ConfigurationInSync"
3939
ConditionReasonConfigurationChanged ConditionReason = "ConfigurationChanged"
4040

41+
// ConditionTypeVersionInSync indicates that all replicas report the same version as the image.
42+
ConditionTypeVersionInSync ConditionType = "VersionInSync"
43+
ConditionReasonVersionMatch ConditionReason = "VersionMatch"
44+
ConditionReasonVersionMismatch ConditionReason = "VersionMismatch"
45+
ConditionReasonVersionPending ConditionReason = "VersionPending"
46+
ConditionReasonVersionProbeFailed ConditionReason = "VersionProbeFailed"
47+
4148
// ConditionTypeReady indicates that cluster is ready to serve client requests.
4249
ConditionTypeReady ConditionType = "Ready"
4350
ClickHouseConditionAllShardsReady ConditionReason = "AllShardsReady"
@@ -83,6 +90,7 @@ var (
8390
ConditionTypeHealthy,
8491
ConditionTypeClusterSizeAligned,
8592
ConditionTypeConfigurationInSync,
93+
ConditionTypeVersionInSync,
8694
ConditionTypeReady,
8795
ClickHouseConditionTypeSchemaInSync,
8896
}
@@ -95,6 +103,7 @@ var (
95103
ConditionTypeHealthy,
96104
ConditionTypeClusterSizeAligned,
97105
ConditionTypeConfigurationInSync,
106+
ConditionTypeVersionInSync,
98107
ConditionTypeReady,
99108
KeeperConditionTypeScaleAllowed,
100109
}

api/v1alpha1/events.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ const (
2525
EventReasonClusterNotReady EventReason = "ClusterNotReady"
2626
)
2727

28+
// Event reasons for version checks.
29+
const (
30+
EventReasonVersionDiverge EventReason = "VersionDiverge"
31+
EventReasonVersionProbeFailed EventReason = "VersionProbeFailed"
32+
)
33+
2834
// EventAction represents the action associated with an event.
2935
type EventAction = string
3036

@@ -33,4 +39,5 @@ const (
3339
EventActionScaling EventAction = "Scaling"
3440
EventActionBecameReady EventAction = "BecameReady"
3541
EventActionBecameNotReady EventAction = "BecameNotReady"
42+
EventActionVersionCheck EventAction = "VersionCheck"
3643
)

api/v1alpha1/keepercluster_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ type KeeperClusterStatus struct {
147147
// ObservedGeneration indicates latest generation observed by controller.
148148
// +operator-sdk:csv:customresourcedefinitions:type=status
149149
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
150+
// Version indicates the version reported by the container image.
151+
// +optional
152+
// +operator-sdk:csv:customresourcedefinitions:type=status
153+
Version string `json:"version,omitempty"`
150154
}
151155

152156
// KeeperCluster is the Schema for the `keeperclusters` API.
@@ -157,6 +161,7 @@ type KeeperClusterStatus struct {
157161
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message"
158162
// +kubebuilder:printcolumn:name="ReadyReplicas",type="number",JSONPath=".status.readyReplicas"
159163
// +kubebuilder:printcolumn:name="Replicas",type="number",JSONPath=".spec.replicas"
164+
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".status.version"
160165
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
161166
// +operator-sdk:csv:customresourcedefinitions:resources={{Pod,v1}}
162167
// +operator-sdk:csv:customresourcedefinitions:resources={{PersistentVolumeClaim,v1}}

config/crd/bases/clickhouse.com_clickhouseclusters.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ spec:
3030
- jsonPath: .spec.replicas
3131
name: Replicas
3232
type: number
33+
- jsonPath: .status.version
34+
name: Version
35+
type: string
3336
- jsonPath: .metadata.creationTimestamp
3437
name: Age
3538
type: date
@@ -4451,6 +4454,10 @@ spec:
44514454
description: UpdateRevision indicates latest requested ClickHouseCluster
44524455
spec revision.
44534456
type: string
4457+
version:
4458+
description: Version indicates the version reported by the container
4459+
image.
4460+
type: string
44544461
type: object
44554462
type: object
44564463
served: true

config/crd/bases/clickhouse.com_keeperclusters.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ spec:
3030
- jsonPath: .spec.replicas
3131
name: Replicas
3232
type: number
33+
- jsonPath: .status.version
34+
name: Version
35+
type: string
3336
- jsonPath: .metadata.creationTimestamp
3437
name: Age
3538
type: date
@@ -4384,6 +4387,10 @@ spec:
43844387
description: CurrentRevision indicates latest requested KeeperCluster
43854388
spec revision.
43864389
type: string
4390+
version:
4391+
description: Version indicates the version reported by the container
4392+
image.
4393+
type: string
43874394
type: object
43884395
type: object
43894396
served: true

config/rbac/role.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ rules:
3636
- statefulsets/status
3737
verbs:
3838
- get
39+
- apiGroups:
40+
- batch
41+
resources:
42+
- jobs
43+
verbs:
44+
- create
45+
- delete
46+
- get
47+
- list
48+
- watch
3949
- apiGroups:
4050
- clickhouse.com
4151
resources:

dist/chart/templates/crd/clickhouseclusters.clickhouse.com.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ spec:
3333
- jsonPath: .spec.replicas
3434
name: Replicas
3535
type: number
36+
- jsonPath: .status.version
37+
name: Version
38+
type: string
3639
- jsonPath: .metadata.creationTimestamp
3740
name: Age
3841
type: date
@@ -4254,6 +4257,9 @@ spec:
42544257
updateRevision:
42554258
description: UpdateRevision indicates latest requested ClickHouseCluster spec revision.
42564259
type: string
4260+
version:
4261+
description: Version indicates the version reported by the container image.
4262+
type: string
42574263
type: object
42584264
type: object
42594265
served: true

dist/chart/templates/crd/keeperclusters.clickhouse.com.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ spec:
3333
- jsonPath: .spec.replicas
3434
name: Replicas
3535
type: number
36+
- jsonPath: .status.version
37+
name: Version
38+
type: string
3639
- jsonPath: .metadata.creationTimestamp
3740
name: Age
3841
type: date
@@ -4195,6 +4198,9 @@ spec:
41954198
updateRevision:
41964199
description: CurrentRevision indicates latest requested KeeperCluster spec revision.
41974200
type: string
4201+
version:
4202+
description: Version indicates the version reported by the container image.
4203+
type: string
41984204
type: object
41994205
type: object
42004206
served: true

dist/chart/templates/rbac/manager-role.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ rules:
3535
- statefulsets/status
3636
verbs:
3737
- get
38+
- apiGroups:
39+
- batch
40+
resources:
41+
- jobs
42+
verbs:
43+
- create
44+
- delete
45+
- get
46+
- list
47+
- watch
3848
- apiGroups:
3949
- clickhouse.com
4050
resources:

0 commit comments

Comments
 (0)