Skip to content

Commit

Permalink
Merge pull request #1623 from Altinity/0.24.3
Browse files Browse the repository at this point in the history
0.24.3
  • Loading branch information
sunsingerus authored Jan 27, 2025
2 parents 329b25f + c7e1315 commit 6a708a1
Show file tree
Hide file tree
Showing 117 changed files with 2,660 additions and 1,162 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release_chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
jq -r ".[] | select(.name == \"$ASSET_NAME\") | .id")
echo "Asset ID is $ASSET_ID"
echo "::set-output name=asset_id::$ASSET_ID"
echo "asset_id=$ASSET_ID" >> $GITHUB_OUTPUT
- name: Delete Existing Release Artifacts
if: steps.get_assets.outputs.asset_id != ''
Expand Down
38 changes: 37 additions & 1 deletion cmd/operator/app/thread_keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import (
clientGoScheme "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
ctrlRuntime "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/predicate"

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

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

err = ctrlRuntime.
NewControllerManagedBy(manager).
For(&api.ClickHouseKeeperInstallation{}).
For(&api.ClickHouseKeeperInstallation{}, builder.WithPredicates(keeperPredicate())).
Owns(&apps.StatefulSet{}).
Complete(
&controller.Controller{
Expand All @@ -81,3 +84,36 @@ func runKeeper(ctx context.Context) error {
// Run successful
return nil
}

func keeperPredicate() predicate.Funcs {
return predicate.Funcs{
CreateFunc: func(e event.CreateEvent) bool {
obj, ok := e.Object.(*api.ClickHouseKeeperInstallation)
if !ok {
return false
}

if obj.Spec.Suspend.Value() {
return false
}
return true
},
DeleteFunc: func(e event.DeleteEvent) bool {
return true
},
UpdateFunc: func(e event.UpdateEvent) bool {
obj, ok := e.ObjectNew.(*api.ClickHouseKeeperInstallation)
if !ok {
return false
}

if obj.Spec.Suspend.Value() {
return false
}
return true
},
GenericFunc: func(e event.GenericEvent) bool {
return true
},
}
}
116 changes: 116 additions & 0 deletions cmd/operator/app/thread_keeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package app

import (
"testing"

"github.com/altinity/clickhouse-operator/pkg/apis/common/types"
"sigs.k8s.io/controller-runtime/pkg/event"

api "github.com/altinity/clickhouse-operator/pkg/apis/clickhouse-keeper.altinity.com/v1"
)

func Test_keeperPredicateCreate(t *testing.T) {
tests := []struct {
name string
want bool
evt event.CreateEvent
}{
{
name: "skips create when suspended",
want: false,
evt: event.CreateEvent{
Object: &api.ClickHouseKeeperInstallation{
Spec: api.ChkSpec{
Suspend: types.NewStringBool(true),
},
},
},
},
{
name: "queues create when not suspended",
want: true,
evt: event.CreateEvent{
Object: &api.ClickHouseKeeperInstallation{
Spec: api.ChkSpec{
Suspend: types.NewStringBool(false),
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
predicate := keeperPredicate()
if got := predicate.Create(tt.evt); tt.want != got {
t.Errorf("keeperPredicate.Create() = %v, want %v", got, tt.want)
}
})
}
}

func Test_keeperPredicateUpdate(t *testing.T) {
tests := []struct {
name string
want bool
evt event.UpdateEvent
}{
{
name: "skips update when suspended",
want: false,
evt: event.UpdateEvent{
ObjectNew: &api.ClickHouseKeeperInstallation{
Spec: api.ChkSpec{
Suspend: types.NewStringBool(true),
},
},
},
},
{
name: "queues update when not suspended",
want: true,
evt: event.UpdateEvent{
ObjectNew: &api.ClickHouseKeeperInstallation{
Spec: api.ChkSpec{
Suspend: types.NewStringBool(false),
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
predicate := keeperPredicate()
if got := predicate.Update(tt.evt); tt.want != got {
t.Errorf("keeperPredicate.Update() = %v, want %v", got, tt.want)
}
})
}
}

func Test_keeperPredicateDelete(t *testing.T) {
tests := []struct {
name string
want bool
evt event.DeleteEvent
}{
{
name: "deletes even when suspended",
want: true,
evt: event.DeleteEvent{
Object: &api.ClickHouseKeeperInstallation{
Spec: api.ChkSpec{
Suspend: types.NewStringBool(true),
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
predicate := keeperPredicate()
if got := predicate.Delete(tt.evt); tt.want != got {
t.Errorf("keeperPredicate.Delete() = %v, want %v", got, tt.want)
}
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ spec:
type: string
description: Resource status
jsonPath: .status.status
- name: hosts-unchanged
- name: hosts-completed
type: integer
description: Unchanged hosts count
priority: 1 # show in wide view
jsonPath: .status.hostsUnchanged
description: Completed hosts count
jsonPath: .status.hostsCompleted
- name: hosts-updated
type: integer
description: Updated hosts count
Expand All @@ -68,20 +67,11 @@ spec:
description: Added hosts count
priority: 1 # show in wide view
jsonPath: .status.hostsAdded
- name: hosts-completed
type: integer
description: Completed hosts count
jsonPath: .status.hostsCompleted
- name: hosts-deleted
type: integer
description: Hosts deleted count
priority: 1 # show in wide view
jsonPath: .status.hostsDeleted
- name: hosts-delete
type: integer
description: Hosts to be deleted count
priority: 1 # show in wide view
jsonPath: .status.hostsDelete
- name: endpoint
type: string
description: Client access endpoint
Expand All @@ -92,6 +82,11 @@ spec:
description: Age of the resource
# Displayed in all priorities
jsonPath: .metadata.creationTimestamp
- name: suspend
type: string
description: Suspend reconciliation
# Displayed in all priorities
jsonPath: .spec.suspend
subresources:
status: {}
schema:
Expand Down Expand Up @@ -308,6 +303,13 @@ spec:
enum:
- ""
- "RollingUpdate"
suspend:
<<: *TypeStringBool
description: |
Suspend reconciliation of resources managed by a ClickHouse Installation.
Works as the following:
- When `suspend` is `true` operator stops reconciling all resources.
- When `suspend` is `false` or not set, operator reconciles all resources.
troubleshoot:
<<: *TypeStringBool
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ spec:
description: Age of the resource
# Displayed in all priorities
jsonPath: .metadata.creationTimestamp
- name: suspend
type: string
description: Suspend reconciliation
# Displayed in all priorities
jsonPath: .spec.suspend
subresources:
status: {}
schema:
Expand Down Expand Up @@ -296,6 +301,13 @@ spec:
- "disabled"
- "Enabled"
- "enabled"
suspend:
<<: *TypeStringBool
description: |
Suspend reconciliation of resources managed by a ClickHouse Keeper.
Works as the following:
- When `suspend` is `true` operator stops reconciling all keeper resources.
- When `suspend` is `false` or not set, operator reconciles all keeper resources.
namespaceDomainPattern:
type: string
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ spec:
# TODO remove this plugin definition after resolve https://github.com/integr8ly/grafana-operator/issues/155
plugins:
- name: "vertamedia-clickhouse-datasource"
version: "2.5.4"
version: "3.3.1"
- name: "grafana-piechart-panel"
version: "1.6.2"
version: "1.6.4"
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ spec:
datasourceName: "$GRAFANA_PROMETHEUS_DATASOURCE_NAME"
plugins:
- name: "vertamedia-clickhouse-datasource"
version: "2.5.4"
version: "3.3.1"
4 changes: 2 additions & 2 deletions deploy/helm/clickhouse-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ description: |-
kubectl apply -f https://github.com/Altinity/clickhouse-operator/raw/master/deploy/helm/clickhouse-operator/crds/CustomResourceDefinition-clickhousekeeperinstallations.clickhouse-keeper.altinity.com.yaml
```
type: application
version: 0.24.2
appVersion: 0.24.2
version: 0.24.3
appVersion: 0.24.3
home: https://github.com/Altinity/clickhouse-operator
icon: https://logosandtypes.com/wp-content/uploads/2020/12/altinity.svg
maintainers:
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/clickhouse-operator/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# altinity-clickhouse-operator

![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)
![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)

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# SINGULAR=clickhouseinstallation
# PLURAL=clickhouseinstallations
# SHORT=chi
# OPERATOR_VERSION=0.24.2
# OPERATOR_VERSION=0.24.3
#
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: clickhouseinstallations.clickhouse.altinity.com
labels:
clickhouse.altinity.com/chop: 0.24.2
clickhouse.altinity.com/chop: 0.24.3
spec:
group: clickhouse.altinity.com
scope: Namespaced
Expand Down Expand Up @@ -53,11 +53,10 @@ spec:
type: string
description: Resource status
jsonPath: .status.status
- name: hosts-unchanged
- name: hosts-completed
type: integer
description: Unchanged hosts count
priority: 1 # show in wide view
jsonPath: .status.hostsUnchanged
description: Completed hosts count
jsonPath: .status.hostsCompleted
- name: hosts-updated
type: integer
description: Updated hosts count
Expand All @@ -68,20 +67,11 @@ spec:
description: Added hosts count
priority: 1 # show in wide view
jsonPath: .status.hostsAdded
- name: hosts-completed
type: integer
description: Completed hosts count
jsonPath: .status.hostsCompleted
- name: hosts-deleted
type: integer
description: Hosts deleted count
priority: 1 # show in wide view
jsonPath: .status.hostsDeleted
- name: hosts-delete
type: integer
description: Hosts to be deleted count
priority: 1 # show in wide view
jsonPath: .status.hostsDelete
- name: endpoint
type: string
description: Client access endpoint
Expand All @@ -92,6 +82,11 @@ spec:
description: Age of the resource
# Displayed in all priorities
jsonPath: .metadata.creationTimestamp
- name: suspend
type: string
description: Suspend reconciliation
# Displayed in all priorities
jsonPath: .spec.suspend
subresources:
status: {}
schema:
Expand Down Expand Up @@ -308,6 +303,13 @@ spec:
enum:
- ""
- "RollingUpdate"
suspend:
!!merge <<: *TypeStringBool
description: |
Suspend reconciliation of resources managed by a ClickHouse Installation.
Works as the following:
- When `suspend` is `true` operator stops reconciling all resources.
- When `suspend` is `false` or not set, operator reconciles all resources.
troubleshoot:
!!merge <<: *TypeStringBool
description: |
Expand Down
Loading

0 comments on commit 6a708a1

Please sign in to comment.