Skip to content

Commit 6a708a1

Browse files
authored
Merge pull request #1623 from Altinity/0.24.3
0.24.3
2 parents 329b25f + c7e1315 commit 6a708a1

File tree

117 files changed

+2660
-1162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+2660
-1162
lines changed

.github/workflows/release_chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
jq -r ".[] | select(.name == \"$ASSET_NAME\") | .id")
3939
4040
echo "Asset ID is $ASSET_ID"
41-
echo "::set-output name=asset_id::$ASSET_ID"
41+
echo "asset_id=$ASSET_ID" >> $GITHUB_OUTPUT
4242
4343
- name: Delete Existing Release Artifacts
4444
if: steps.get_assets.outputs.asset_id != ''

cmd/operator/app/thread_keeper.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ import (
1010
clientGoScheme "k8s.io/client-go/kubernetes/scheme"
1111
ctrl "sigs.k8s.io/controller-runtime"
1212
ctrlRuntime "sigs.k8s.io/controller-runtime"
13+
"sigs.k8s.io/controller-runtime/pkg/builder"
1314
"sigs.k8s.io/controller-runtime/pkg/cache"
15+
"sigs.k8s.io/controller-runtime/pkg/event"
1416
"sigs.k8s.io/controller-runtime/pkg/log/zap"
17+
"sigs.k8s.io/controller-runtime/pkg/predicate"
1518

1619
// ctrl "sigs.k8s.io/controller-runtime/pkg/controller"
1720

@@ -56,7 +59,7 @@ func initKeeper(ctx context.Context) error {
5659

5760
err = ctrlRuntime.
5861
NewControllerManagedBy(manager).
59-
For(&api.ClickHouseKeeperInstallation{}).
62+
For(&api.ClickHouseKeeperInstallation{}, builder.WithPredicates(keeperPredicate())).
6063
Owns(&apps.StatefulSet{}).
6164
Complete(
6265
&controller.Controller{
@@ -81,3 +84,36 @@ func runKeeper(ctx context.Context) error {
8184
// Run successful
8285
return nil
8386
}
87+
88+
func keeperPredicate() predicate.Funcs {
89+
return predicate.Funcs{
90+
CreateFunc: func(e event.CreateEvent) bool {
91+
obj, ok := e.Object.(*api.ClickHouseKeeperInstallation)
92+
if !ok {
93+
return false
94+
}
95+
96+
if obj.Spec.Suspend.Value() {
97+
return false
98+
}
99+
return true
100+
},
101+
DeleteFunc: func(e event.DeleteEvent) bool {
102+
return true
103+
},
104+
UpdateFunc: func(e event.UpdateEvent) bool {
105+
obj, ok := e.ObjectNew.(*api.ClickHouseKeeperInstallation)
106+
if !ok {
107+
return false
108+
}
109+
110+
if obj.Spec.Suspend.Value() {
111+
return false
112+
}
113+
return true
114+
},
115+
GenericFunc: func(e event.GenericEvent) bool {
116+
return true
117+
},
118+
}
119+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
package app
2+
3+
import (
4+
"testing"
5+
6+
"github.com/altinity/clickhouse-operator/pkg/apis/common/types"
7+
"sigs.k8s.io/controller-runtime/pkg/event"
8+
9+
api "github.com/altinity/clickhouse-operator/pkg/apis/clickhouse-keeper.altinity.com/v1"
10+
)
11+
12+
func Test_keeperPredicateCreate(t *testing.T) {
13+
tests := []struct {
14+
name string
15+
want bool
16+
evt event.CreateEvent
17+
}{
18+
{
19+
name: "skips create when suspended",
20+
want: false,
21+
evt: event.CreateEvent{
22+
Object: &api.ClickHouseKeeperInstallation{
23+
Spec: api.ChkSpec{
24+
Suspend: types.NewStringBool(true),
25+
},
26+
},
27+
},
28+
},
29+
{
30+
name: "queues create when not suspended",
31+
want: true,
32+
evt: event.CreateEvent{
33+
Object: &api.ClickHouseKeeperInstallation{
34+
Spec: api.ChkSpec{
35+
Suspend: types.NewStringBool(false),
36+
},
37+
},
38+
},
39+
},
40+
}
41+
for _, tt := range tests {
42+
t.Run(tt.name, func(t *testing.T) {
43+
predicate := keeperPredicate()
44+
if got := predicate.Create(tt.evt); tt.want != got {
45+
t.Errorf("keeperPredicate.Create() = %v, want %v", got, tt.want)
46+
}
47+
})
48+
}
49+
}
50+
51+
func Test_keeperPredicateUpdate(t *testing.T) {
52+
tests := []struct {
53+
name string
54+
want bool
55+
evt event.UpdateEvent
56+
}{
57+
{
58+
name: "skips update when suspended",
59+
want: false,
60+
evt: event.UpdateEvent{
61+
ObjectNew: &api.ClickHouseKeeperInstallation{
62+
Spec: api.ChkSpec{
63+
Suspend: types.NewStringBool(true),
64+
},
65+
},
66+
},
67+
},
68+
{
69+
name: "queues update when not suspended",
70+
want: true,
71+
evt: event.UpdateEvent{
72+
ObjectNew: &api.ClickHouseKeeperInstallation{
73+
Spec: api.ChkSpec{
74+
Suspend: types.NewStringBool(false),
75+
},
76+
},
77+
},
78+
},
79+
}
80+
for _, tt := range tests {
81+
t.Run(tt.name, func(t *testing.T) {
82+
predicate := keeperPredicate()
83+
if got := predicate.Update(tt.evt); tt.want != got {
84+
t.Errorf("keeperPredicate.Update() = %v, want %v", got, tt.want)
85+
}
86+
})
87+
}
88+
}
89+
90+
func Test_keeperPredicateDelete(t *testing.T) {
91+
tests := []struct {
92+
name string
93+
want bool
94+
evt event.DeleteEvent
95+
}{
96+
{
97+
name: "deletes even when suspended",
98+
want: true,
99+
evt: event.DeleteEvent{
100+
Object: &api.ClickHouseKeeperInstallation{
101+
Spec: api.ChkSpec{
102+
Suspend: types.NewStringBool(true),
103+
},
104+
},
105+
},
106+
},
107+
}
108+
for _, tt := range tests {
109+
t.Run(tt.name, func(t *testing.T) {
110+
predicate := keeperPredicate()
111+
if got := predicate.Delete(tt.evt); tt.want != got {
112+
t.Errorf("keeperPredicate.Delete() = %v, want %v", got, tt.want)
113+
}
114+
})
115+
}
116+
}

deploy/builder/templates-install-bundle/clickhouse-operator-install-yaml-template-01-section-crd-01-chi-chit.yaml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@ spec:
5353
type: string
5454
description: Resource status
5555
jsonPath: .status.status
56-
- name: hosts-unchanged
56+
- name: hosts-completed
5757
type: integer
58-
description: Unchanged hosts count
59-
priority: 1 # show in wide view
60-
jsonPath: .status.hostsUnchanged
58+
description: Completed hosts count
59+
jsonPath: .status.hostsCompleted
6160
- name: hosts-updated
6261
type: integer
6362
description: Updated hosts count
@@ -68,20 +67,11 @@ spec:
6867
description: Added hosts count
6968
priority: 1 # show in wide view
7069
jsonPath: .status.hostsAdded
71-
- name: hosts-completed
72-
type: integer
73-
description: Completed hosts count
74-
jsonPath: .status.hostsCompleted
7570
- name: hosts-deleted
7671
type: integer
7772
description: Hosts deleted count
7873
priority: 1 # show in wide view
7974
jsonPath: .status.hostsDeleted
80-
- name: hosts-delete
81-
type: integer
82-
description: Hosts to be deleted count
83-
priority: 1 # show in wide view
84-
jsonPath: .status.hostsDelete
8575
- name: endpoint
8676
type: string
8777
description: Client access endpoint
@@ -92,6 +82,11 @@ spec:
9282
description: Age of the resource
9383
# Displayed in all priorities
9484
jsonPath: .metadata.creationTimestamp
85+
- name: suspend
86+
type: string
87+
description: Suspend reconciliation
88+
# Displayed in all priorities
89+
jsonPath: .spec.suspend
9590
subresources:
9691
status: {}
9792
schema:
@@ -308,6 +303,13 @@ spec:
308303
enum:
309304
- ""
310305
- "RollingUpdate"
306+
suspend:
307+
<<: *TypeStringBool
308+
description: |
309+
Suspend reconciliation of resources managed by a ClickHouse Installation.
310+
Works as the following:
311+
- When `suspend` is `true` operator stops reconciling all resources.
312+
- When `suspend` is `false` or not set, operator reconciles all resources.
311313
troubleshoot:
312314
<<: *TypeStringBool
313315
description: |

deploy/builder/templates-install-bundle/clickhouse-operator-install-yaml-template-01-section-crd-03-chk.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ spec:
8888
description: Age of the resource
8989
# Displayed in all priorities
9090
jsonPath: .metadata.creationTimestamp
91+
- name: suspend
92+
type: string
93+
description: Suspend reconciliation
94+
# Displayed in all priorities
95+
jsonPath: .spec.suspend
9196
subresources:
9297
status: {}
9398
schema:
@@ -296,6 +301,13 @@ spec:
296301
- "disabled"
297302
- "Enabled"
298303
- "enabled"
304+
suspend:
305+
<<: *TypeStringBool
306+
description: |
307+
Suspend reconciliation of resources managed by a ClickHouse Keeper.
308+
Works as the following:
309+
- When `suspend` is `true` operator stops reconciling all keeper resources.
310+
- When `suspend` is `false` or not set, operator reconciles all keeper resources.
299311
namespaceDomainPattern:
300312
type: string
301313
description: |

deploy/grafana/grafana-with-grafana-operator/grafana-dashboard-operator-cr-template.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ spec:
1414
# TODO remove this plugin definition after resolve https://github.com/integr8ly/grafana-operator/issues/155
1515
plugins:
1616
- name: "vertamedia-clickhouse-datasource"
17-
version: "2.5.4"
17+
version: "3.3.1"
1818
- name: "grafana-piechart-panel"
19-
version: "1.6.2"
19+
version: "1.6.4"

deploy/grafana/grafana-with-grafana-operator/grafana-dashboard-queries-cr-template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ spec:
1313
datasourceName: "$GRAFANA_PROMETHEUS_DATASOURCE_NAME"
1414
plugins:
1515
- name: "vertamedia-clickhouse-datasource"
16-
version: "2.5.4"
16+
version: "3.3.1"

deploy/helm/clickhouse-operator/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ description: |-
1313
kubectl apply -f https://github.com/Altinity/clickhouse-operator/raw/master/deploy/helm/clickhouse-operator/crds/CustomResourceDefinition-clickhousekeeperinstallations.clickhouse-keeper.altinity.com.yaml
1414
```
1515
type: application
16-
version: 0.24.2
17-
appVersion: 0.24.2
16+
version: 0.24.3
17+
appVersion: 0.24.3
1818
home: https://github.com/Altinity/clickhouse-operator
1919
icon: https://logosandtypes.com/wp-content/uploads/2020/12/altinity.svg
2020
maintainers:

deploy/helm/clickhouse-operator/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# altinity-clickhouse-operator
22

3-
![Version: 0.24.2](https://img.shields.io/badge/Version-0.24.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.24.2](https://img.shields.io/badge/AppVersion-0.24.2-informational?style=flat-square)
3+
![Version: 0.24.3](https://img.shields.io/badge/Version-0.24.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.24.3](https://img.shields.io/badge/AppVersion-0.24.3-informational?style=flat-square)
44

55
Helm chart to deploy [altinity-clickhouse-operator](https://github.com/Altinity/clickhouse-operator).
66

deploy/helm/clickhouse-operator/crds/CustomResourceDefinition-clickhouseinstallations.clickhouse.altinity.com.yaml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
# SINGULAR=clickhouseinstallation
55
# PLURAL=clickhouseinstallations
66
# SHORT=chi
7-
# OPERATOR_VERSION=0.24.2
7+
# OPERATOR_VERSION=0.24.3
88
#
99
apiVersion: apiextensions.k8s.io/v1
1010
kind: CustomResourceDefinition
1111
metadata:
1212
name: clickhouseinstallations.clickhouse.altinity.com
1313
labels:
14-
clickhouse.altinity.com/chop: 0.24.2
14+
clickhouse.altinity.com/chop: 0.24.3
1515
spec:
1616
group: clickhouse.altinity.com
1717
scope: Namespaced
@@ -53,11 +53,10 @@ spec:
5353
type: string
5454
description: Resource status
5555
jsonPath: .status.status
56-
- name: hosts-unchanged
56+
- name: hosts-completed
5757
type: integer
58-
description: Unchanged hosts count
59-
priority: 1 # show in wide view
60-
jsonPath: .status.hostsUnchanged
58+
description: Completed hosts count
59+
jsonPath: .status.hostsCompleted
6160
- name: hosts-updated
6261
type: integer
6362
description: Updated hosts count
@@ -68,20 +67,11 @@ spec:
6867
description: Added hosts count
6968
priority: 1 # show in wide view
7069
jsonPath: .status.hostsAdded
71-
- name: hosts-completed
72-
type: integer
73-
description: Completed hosts count
74-
jsonPath: .status.hostsCompleted
7570
- name: hosts-deleted
7671
type: integer
7772
description: Hosts deleted count
7873
priority: 1 # show in wide view
7974
jsonPath: .status.hostsDeleted
80-
- name: hosts-delete
81-
type: integer
82-
description: Hosts to be deleted count
83-
priority: 1 # show in wide view
84-
jsonPath: .status.hostsDelete
8575
- name: endpoint
8676
type: string
8777
description: Client access endpoint
@@ -92,6 +82,11 @@ spec:
9282
description: Age of the resource
9383
# Displayed in all priorities
9484
jsonPath: .metadata.creationTimestamp
85+
- name: suspend
86+
type: string
87+
description: Suspend reconciliation
88+
# Displayed in all priorities
89+
jsonPath: .spec.suspend
9590
subresources:
9691
status: {}
9792
schema:
@@ -308,6 +303,13 @@ spec:
308303
enum:
309304
- ""
310305
- "RollingUpdate"
306+
suspend:
307+
!!merge <<: *TypeStringBool
308+
description: |
309+
Suspend reconciliation of resources managed by a ClickHouse Installation.
310+
Works as the following:
311+
- When `suspend` is `true` operator stops reconciling all resources.
312+
- When `suspend` is `false` or not set, operator reconciles all resources.
311313
troubleshoot:
312314
!!merge <<: *TypeStringBool
313315
description: |

0 commit comments

Comments
 (0)