Skip to content

Commit 2270e45

Browse files
authored
Merge pull request #1826 from Altinity/0.25.4
0.25.4
2 parents 9d21e6f + 4e069d2 commit 2270e45

File tree

221 files changed

+13461
-2340
lines changed

Some content is hidden

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

221 files changed

+13461
-2340
lines changed

.github/workflows/build_branch.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ jobs:
2323
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
2424
run: |
2525
export CHO_RELEASE=$(cat release)
26+
export GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
2627
2728
echo "${DOCKER_PASS}" | docker login -u $DOCKER_USER --password-stdin docker.io
28-
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/operator/Dockerfile -t docker.io/${DOCKER_ORG}/clickhouse-operator:${CHO_RELEASE} --pull --push .
29-
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/metrics-exporter/Dockerfile -t docker.io/${DOCKER_ORG}/metrics-exporter:${CHO_RELEASE} --pull --push .
29+
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/operator/Dockerfile --build-arg GO_VERSION=${GO_VERSION} -t docker.io/${DOCKER_ORG}/clickhouse-operator:${CHO_RELEASE} --pull --push .
30+
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/metrics-exporter/Dockerfile --build-arg GO_VERSION=${GO_VERSION} -t docker.io/${DOCKER_ORG}/metrics-exporter:${CHO_RELEASE} --pull --push .

.github/workflows/build_master.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
2424
run: |
2525
export CHO_RELEASE=latest
26+
export GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
2627
2728
echo "${DOCKER_PASS}" | docker login -u $DOCKER_USER --password-stdin docker.io
28-
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/operator/Dockerfile -t docker.io/${DOCKER_ORG}/clickhouse-operator:${CHO_RELEASE} --pull --push .
29-
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/metrics-exporter/Dockerfile -t docker.io/${DOCKER_ORG}/metrics-exporter:${CHO_RELEASE} --pull --push .
30-
29+
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/operator/Dockerfile --build-arg GO_VERSION=${GO_VERSION} -t docker.io/${DOCKER_ORG}/clickhouse-operator:${CHO_RELEASE} --pull --push .
30+
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/metrics-exporter/Dockerfile --build-arg GO_VERSION=${GO_VERSION} -t docker.io/${DOCKER_ORG}/metrics-exporter:${CHO_RELEASE} --pull --push .

.github/workflows/release_chart.yaml

Lines changed: 110 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ jobs:
2828
- name: Package Chart
2929
run: cr package deploy/helm/clickhouse-operator
3030

31-
- name: Install Helm
32-
run: |
33-
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
34-
35-
- name: Login to GitHub Container Registry
36-
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
37-
3831
- name: Get Release Assets
3932
id: get_assets
4033
run: |
@@ -62,13 +55,38 @@ jobs:
6255
-H "Content-Type: application/gzip" \
6356
-T "${CHART_PATH}" \
6457
"https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${{ github.event.release.id }}/assets?name=$(basename ${CHART_PATH})"
65-
58+
- name: Validate Helm Repository Configuration
59+
run: |
60+
if [ -z "${{ secrets.HELM_GITHUB_TOKEN }}" ]; then
61+
echo "ERROR: HELM_GITHUB_TOKEN secret is not set or is empty"
62+
echo "Please add HELM_GITHUB_TOKEN to repository secrets with write access to the helm repository"
63+
exit 1
64+
fi
65+
66+
if [ -z "${{ vars.HELM_GITHUB_REPOSITORY }}" ]; then
67+
echo "ERROR: HELM_GITHUB_REPOSITORY variable is not set or is empty"
68+
echo "Please add HELM_GITHUB_REPOSITORY to repository variables (Settings -> Secrets and variables -> Actions -> Variables)"
69+
exit 1
70+
fi
71+
72+
echo "Configuration validated:"
73+
echo " HELM_GITHUB_REPOSITORY: ${{ vars.HELM_GITHUB_REPOSITORY }}"
74+
echo " HELM_GITHUB_TOKEN: [SET]"
75+
76+
- name: Upload Release Artifacts to Helm Repo
77+
run: |
78+
cr upload \
79+
--git-repo=${{ vars.HELM_GITHUB_REPOSITORY }} \
80+
--owner=${GITHUB_REPOSITORY_OWNER} \
81+
--release-name-template=${{ github.event.release.name }} \
82+
--token=${{ secrets.HELM_GITHUB_TOKEN }} \
83+
--package-path=.cr-release-packages \
84+
--skip-existing
6685
- name: Configure Git
6786
run: |
6887
git config user.name "$GITHUB_ACTOR"
6988
git config user.email "[email protected]"
70-
71-
- name: Release Chart
89+
- name: Release Chart to Operator Repo
7290
run: |
7391
git remote add httpsorigin "https://github.com/${GITHUB_REPOSITORY}.git"
7492
git fetch httpsorigin
@@ -80,8 +98,86 @@ jobs:
8098
--index-path=index.yaml \
8199
--remote=httpsorigin \
82100
--push
83-
84-
- name: Push Helm Chart to OCI Registry
101+
- name: Release Chart to Helm Repo
85102
run: |
86-
CHART_PATH=$(ls .cr-release-packages/altinity-clickhouse-operator-*.tgz)
87-
helm push "${CHART_PATH}" oci://ghcr.io/altinity/clickhouse-operator-helm-chart
103+
# Validate configuration before attempting to push
104+
if [ -z "${{ vars.HELM_GITHUB_REPOSITORY }}" ]; then
105+
echo "ERROR: HELM_GITHUB_REPOSITORY variable is not set or is empty"
106+
echo "This step requires HELM_GITHUB_REPOSITORY to be set in repository variables"
107+
echo "Go to: Settings -> Secrets and variables -> Actions -> Variables"
108+
exit 1
109+
fi
110+
111+
if [ -z "${{ secrets.HELM_GITHUB_TOKEN }}" ]; then
112+
echo "ERROR: HELM_GITHUB_TOKEN secret is not set or is empty"
113+
echo "This step requires HELM_GITHUB_TOKEN with write access to: ${GITHUB_REPOSITORY_OWNER}/${{ vars.HELM_GITHUB_REPOSITORY }}"
114+
echo "Go to: Settings -> Secrets and variables -> Actions -> Secrets"
115+
exit 1
116+
fi
117+
118+
echo "Attempting to push to helm repository: ${GITHUB_REPOSITORY_OWNER}/${{ vars.HELM_GITHUB_REPOSITORY }}"
119+
120+
# Test token authentication
121+
echo "Testing token authentication..."
122+
TOKEN_USER=$(curl -sS -H "Authorization: token ${{ secrets.HELM_GITHUB_TOKEN }}" https://api.github.com/user | jq -r '.login')
123+
echo "Token authenticated as user: ${TOKEN_USER}"
124+
125+
# Save current directory
126+
WORK_DIR=$(pwd)
127+
128+
# Create a temporary directory for helm repo operations
129+
TEMP_DIR=$(mktemp -d)
130+
cd "$TEMP_DIR"
131+
132+
# Clone the helm repository WITHOUT token in URL to avoid masking issues
133+
echo "Cloning helm repository to temporary directory..."
134+
git clone https://github.com/${GITHUB_REPOSITORY_OWNER}/${{ vars.HELM_GITHUB_REPOSITORY }}.git helm-repo || {
135+
echo "ERROR: Failed to clone helm repository"
136+
echo "Please verify:"
137+
echo " 1. Repository exists: ${GITHUB_REPOSITORY_OWNER}/${{ vars.HELM_GITHUB_REPOSITORY }}"
138+
exit 1
139+
}
140+
141+
cd helm-repo
142+
143+
# Configure git credentials for push
144+
git config user.email "[email protected]"
145+
git config user.name "$GITHUB_ACTOR"
146+
147+
# Set up authentication using git credential helper
148+
git config credential.helper "store --file=.git/credentials"
149+
echo "https://x-access-token:${{ secrets.HELM_GITHUB_TOKEN }}@github.com" > .git/credentials
150+
151+
# Now use cr index from within the helm repo to avoid history conflicts
152+
echo "Generating index.yaml within helm repository context..."
153+
154+
# Copy the package to a local directory within helm repo
155+
mkdir -p .cr-release-packages
156+
cp "$WORK_DIR"/.cr-release-packages/*.tgz .cr-release-packages/ || {
157+
echo "ERROR: No chart packages found in .cr-release-packages"
158+
exit 1
159+
}
160+
161+
# Generate index with cr (this will handle the gh-pages branch automatically)
162+
cr index \
163+
--git-repo=${{ vars.HELM_GITHUB_REPOSITORY }} \
164+
--owner=${GITHUB_REPOSITORY_OWNER} \
165+
--release-name-template=${{ github.event.release.name }} \
166+
--token=${{ secrets.HELM_GITHUB_TOKEN }} \
167+
--package-path=.cr-release-packages \
168+
--index-path=index.yaml \
169+
--push || {
170+
echo "ERROR: Failed to generate or push index to helm repository"
171+
echo "Debug: Current directory is $(pwd)"
172+
echo "Debug: Git remotes:"
173+
git remote -v
174+
echo "Debug: Git status:"
175+
git status
176+
exit 1
177+
}
178+
179+
echo "Successfully updated helm repository index"
180+
181+
# Cleanup
182+
cd /
183+
rm -rf "$TEMP_DIR"

.github/workflows/run_tests.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ jobs:
5555
run: |
5656
minikube status
5757
export CHO_RELEASE=$(cat release)
58+
export GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
5859
echo "current release=$CHO_RELEASE"
60+
echo "current go version=$GO_VERSION"
5961
60-
docker build -f dockerfile/operator/Dockerfile -t altinity/clickhouse-operator:${CHO_RELEASE} --pull .
61-
docker build -f dockerfile/metrics-exporter/Dockerfile -t altinity/metrics-exporter:${CHO_RELEASE} --pull .
62+
docker build -f dockerfile/operator/Dockerfile --build-arg GO_VERSION=${GO_VERSION} -t altinity/clickhouse-operator:${CHO_RELEASE} --pull .
63+
docker build -f dockerfile/metrics-exporter/Dockerfile --build-arg GO_VERSION=${GO_VERSION} -t altinity/metrics-exporter:${CHO_RELEASE} --pull .
6264
6365
docker image save altinity/clickhouse-operator:${CHO_RELEASE} -o operator.tar
64-
docker image save altinity/metrics-exporter:${CHO_RELEASE} -o metrics-exporter.tar
66+
docker image save altinity/metrics-exporter:${CHO_RELEASE} -o metrics-exporter.tar
6567
6668
minikube image load operator.tar
6769
minikube image load metrics-exporter.tar

cmd/operator/app/thread_chi.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ func initClickHouse(ctx context.Context) {
6363
log.V(1).F().Info("Config parsed:")
6464
log.Info("\n" + chop.Config().String(true))
6565

66+
// Log namespace deny list configuration
67+
if chop.Config().Watch.Namespaces.Exclude.Len() > 0 {
68+
log.Info("Namespace deny list configured: %v - these namespaces will NOT be reconciled", chop.Config().Watch.Namespaces.Exclude.Value())
69+
} else {
70+
log.V(1).Info("No namespace deny list configured - all watched namespaces will be reconciled")
71+
}
72+
6673
// Create Informers
6774
kubeInformerFactory := kubeinformers.NewSharedInformerFactoryWithOptions(
6875
kubeClient,

cmd/operator/app/thread_keeper.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ func keeperPredicate() predicate.Funcs {
9393
return false
9494
}
9595

96+
// Check if namespace should be watched (includes deny list check)
97+
if !chop.Config().IsNamespaceWatched(obj.Namespace) {
98+
logger.V(2).Info("chkInformer: skip event, namespace is not watched or is in deny list", "namespace", obj.Namespace)
99+
return false
100+
}
101+
96102
if obj.Spec.Suspend.Value() {
97103
return false
98104
}
@@ -107,6 +113,12 @@ func keeperPredicate() predicate.Funcs {
107113
return false
108114
}
109115

116+
// Check if namespace should be watched (includes deny list check)
117+
if !chop.Config().IsNamespaceWatched(obj.Namespace) {
118+
logger.V(2).Info("chkInformer: skip event, namespace is not watched or is in deny list", "namespace", obj.Namespace)
119+
return false
120+
}
121+
110122
if obj.Spec.Suspend.Value() {
111123
return false
112124
}

config/config-dev.yaml

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1+
# IMPORTANT
2+
# This file is auto-generated
3+
# Do not edit this file - all changes would be lost
4+
# Edit appropriate template in the following folder:
5+
# deploy/builder/templates-config
6+
# IMPORTANT
17
#
2-
#
3-
#
4-
#
5-
#
6-
#
7-
#
8-
#
9-
#
10-
#
11-
#
12-
#
13-
#
14-
#
8+
# Template parameters available:
9+
# WATCH_NAMESPACES=
10+
# CH_USERNAME_PLAIN=
11+
# CH_PASSWORD_PLAIN=
12+
# CH_CREDENTIALS_SECRET_NAMESPACE=
13+
# CH_CREDENTIALS_SECRET_NAME=clickhouse-operator
14+
# VERBOSITY=1
1515

1616
################################################
1717
##
@@ -23,8 +23,9 @@ watch:
2323
# Concurrently running operators should watch on different namespaces.
2424
# IMPORTANT
2525
# Regexp is applicable.
26-
#namespaces: ["dev", "test"]
27-
namespaces: [dev, test]
26+
namespaces:
27+
include: [dev, test]
28+
exclude: []
2829

2930
clickhouse:
3031
configuration:
@@ -276,8 +277,8 @@ template:
276277
chi:
277278
# CHI template updates handling policy
278279
# Possible policy values:
279-
# - ReadOnStart. Accept CHIT updates on the operators start only.
280-
# - ApplyOnNextReconcile. Accept CHIT updates at all time. Apply news CHITs on next regular reconcile of the CHI
280+
# - ReadOnStart. Accept CHIT updates on the operator's start only.
281+
# - ApplyOnNextReconcile. Accept CHIT updates at all time. Apply new CHITs on next regular reconcile of the CHI
281282
policy: ApplyOnNextReconcile
282283

283284
# Path to the folder where ClickHouseInstallation templates .yaml manifests are located.
@@ -288,7 +289,7 @@ template:
288289
# CHK template updates handling policy
289290
# Possible policy values:
290291
# - ReadOnStart. Accept CHIT updates on the operators start only.
291-
# - ApplyOnNextReconcile. Accept CHIT updates at all time. Apply news CHITs on next regular reconcile of the CHI
292+
# - ApplyOnNextReconcile. Accept CHIT updates at all time. Apply new CHITs on next regular reconcile of the CHI
292293
policy: ApplyOnNextReconcile
293294

294295
# Path to the folder where ClickHouseInstallation templates .yaml manifests are located.
@@ -315,9 +316,9 @@ reconcile:
315316
# 3. The first shard is always reconciled alone. Concurrency starts from the second shard and onward.
316317
# Thus limiting number of shards being reconciled (and thus having hosts down) in each CHI by both number and percentage
317318

318-
# Max number of concurrent shard reconciles within one CHI in progress
319+
# Max number of concurrent shard reconciles within one cluster in progress
319320
reconcileShardsThreadsNumber: 1
320-
# Max percentage of concurrent shard reconciles within one CHI in progress
321+
# Max percentage of concurrent shard reconciles within one cluster in progress
321322
reconcileShardsMaxConcurrencyPercent: 50
322323

323324
# Reconcile StatefulSet scenario
@@ -356,15 +357,31 @@ reconcile:
356357
# - to be excluded from a ClickHouse cluster
357358
# - to complete all running queries
358359
# - to be included into a ClickHouse cluster
359-
# respectfully before moving forward
360+
# respectfully before moving forward with host reconcile
360361
wait:
361362
exclude: true
362363
queries: true
363364
include: false
365+
# The operator during reconcile procedure should wait for replicas to catch-up
366+
# replication delay a.k.a replication lag for the following replicas
364367
replicas:
368+
# All replicas (new and known earlier) are explicitly requested to wait for replication to catch-up
365369
all: no
370+
# New replicas only are requested to wait for replication to catch-up
366371
new: yes
372+
# Replication catch-up is considered to be completed as soon as replication delay
373+
# a.k.a replication lag - calculated as "MAX(absolute_delay) FROM system.replicas"
374+
# is within this specified delay (in seconds)
367375
delay: 10
376+
probes:
377+
# Whether the operator during host launch procedure should wait for startup probe to succeed.
378+
# In case probe is unspecified wait is assumed to be completed successfully.
379+
# Default option value is to do not wait.
380+
startup: no
381+
# Whether the operator during host launch procedure should wait for readiness probe to succeed.
382+
# In case probe is unspecified wait is assumed to be completed successfully.
383+
# Default option value is to wait.
384+
readiness: yes
368385

369386
################################################
370387
##

config/config.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ watch:
2323
# Concurrently running operators should watch on different namespaces.
2424
# IMPORTANT
2525
# Regexp is applicable.
26-
#namespaces: ["dev", "test"]
2726
namespaces: []
2827

2928
clickhouse:
@@ -356,15 +355,31 @@ reconcile:
356355
# - to be excluded from a ClickHouse cluster
357356
# - to complete all running queries
358357
# - to be included into a ClickHouse cluster
359-
# respectfully before moving forward
358+
# respectfully before moving forward with host reconcile
360359
wait:
361360
exclude: true
362361
queries: true
363362
include: false
363+
# The operator during reconcile procedure should wait for replicas to catch-up
364+
# replication delay a.k.a replication lag for the following replicas
364365
replicas:
366+
# All replicas (new and known earlier) are explicitly requested to wait for replication to catch-up
365367
all: no
368+
# New replicas only are requested to wait for replication to catch-up
366369
new: yes
370+
# Replication catch-up is considered to be completed as soon as replication delay
371+
# a.k.a replication lag - calculated as "MAX(absolute_delay) FROM system.replicas"
372+
# is within this specified delay (in seconds)
367373
delay: 10
374+
probes:
375+
# Whether the operator during host launch procedure should wait for startup probe to succeed.
376+
# In case probe is unspecified wait is assumed to be completed successfully.
377+
# Default option value is to do not wait.
378+
startup: no
379+
# Whether the operator during host launch procedure should wait for readiness probe to succeed.
380+
# In case probe is unspecified wait is assumed to be completed successfully.
381+
# Default option value is to wait.
382+
readiness: yes
368383

369384
################################################
370385
##

0 commit comments

Comments
 (0)