Skip to content

Commit b9c7761

Browse files
chore: Bump helm chart versions ahead of 26.7 (#424)
* fix(yaml): Quote/comment templating syntax The update script (.scripts/update_helm_charts.py) skipped these files * chore(script): Formatting * fix(script): Handle empty appVersion * fix(script): Don't strip leading indentation This was matching on vector-aggregator: ```yaml version: "2" ``` * chore(script): mention "appVersion" before the app version * chore(helm): Bump versions * fix(script): Combine helm repo add with update This had a side-effect: When the `repo.url` is updated (eg: https://grafana.github.io/helm-charts -> https://grafana-community.github.io/helm-charts), but the user has a named repo with the old url (because the `repo.name` wasn't updated), this caused chart downgrades. Now we do an add and force update (once), along with a repo URL check and bail out with this message: ``` ⚠️ Error processing ./stacks/observability/grafana.yaml: You have a local repo named grafana pointing to https://grafana.github.io/helm-charts, but the stack/demo wants https://grafana-community.github.io/helm-charts Either delete or update your local repo URL, or update the stack/demo repo name so it doesn't conflict ``` * fix(script): Ignore bumping templated versions * chore(helm): Update grafana repo name * Apply suggestions from code review Co-authored-by: Techassi <git@techassi.dev> * chore(script): Dedent and """ * chore(script): Skip Vector bumps These are currently tied to the vector version shipped with products via docker-images. Hopefully we can move to OTLP for the vector sidecar -> vector-aggregator. * revert(helm): Go back to vector 0.55.0 * revert(helm): Last minute ArgoCD bump * chore(helm): Update loki and tempo They have new helm-chart repos. * chore(script): Improve script output --------- Co-authored-by: Techassi <git@techassi.dev>
1 parent 9331550 commit b9c7761

31 files changed

Lines changed: 187 additions & 134 deletions

.scripts/update_helm_charts.py

Lines changed: 73 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,31 @@
44
import subprocess
55
import yaml
66
from typing import Tuple, Set
7+
from textwrap import dedent
8+
79

810
def run_helm_repo_add(repo_name: str, repo_url: str) -> None:
9-
try:
10-
subprocess.run(["helm", "repo", "add", repo_name, repo_url], check=True)
11-
except subprocess.CalledProcessError as e:
12-
if "already exists" in e.stderr.decode() if e.stderr else str(e):
13-
pass # Ignore "already exists" error
14-
else:
15-
raise
11+
result = subprocess.run(
12+
["helm", "repo", "add", repo_name, repo_url, "--force-update"],
13+
capture_output=True,
14+
check=True,
15+
)
16+
if result.returncode == 0:
17+
print(f"✅ Added/Updated {repo_name} ({repo_url})")
18+
else:
19+
print(
20+
f"⚠️ There was a problem Adding/Updating {repo_name} ({repo_url}): {result.stderr}"
21+
)
1622

1723

18-
def run_helm_repo_update(repo_name: str) -> None:
19-
subprocess.run(["helm", "repo", "update", repo_name], check=True)
24+
def local_repo_list():
25+
result = subprocess.run(
26+
["helm", "repo", "list", "-o", "yaml"],
27+
capture_output=True,
28+
text=True,
29+
check=True,
30+
)
31+
return yaml.safe_load(result.stdout)
2032

2133

2234
def get_chart_and_app_version(repo_name: str, chart_name: str) -> Tuple[str, str]:
@@ -25,14 +37,17 @@ def get_chart_and_app_version(repo_name: str, chart_name: str) -> Tuple[str, str
2537
["helm", "show", "chart", full_chart],
2638
capture_output=True,
2739
text=True,
28-
check=True
40+
check=True,
2941
)
3042
chart_yaml = yaml.safe_load(result.stdout)
31-
return chart_yaml["version"], chart_yaml["appVersion"]
43+
# Some charts don't have an appVersion and as such we fallback to a default
44+
# value to not cause lookup errors.
45+
return chart_yaml["version"], chart_yaml.setdefault("appVersion", "Not present")
3246

3347

3448
def process_yaml_files(top_dir: str) -> None:
3549
seen_repos: Set[str] = set()
50+
local_repos = local_repo_list()
3651

3752
for root, _, files in os.walk(top_dir):
3853
for file in files:
@@ -72,19 +87,47 @@ def process_yaml_files(top_dir: str) -> None:
7287
if not repo_name or not repo_url:
7388
continue
7489

90+
# At this point, it appears to be a Helm Chart manifest.
91+
92+
# Skip Vector, as we currently keep it tied to the version that the product sidecars use.abs
93+
# Looking forward to swapping the transport with OTLP.
94+
if chart_name == "vector":
95+
raise Exception(
96+
"Skipping vector. Ensure it is at the same version as the product sidecars"
97+
)
98+
continue
99+
100+
chart_version = first_doc["version"]
101+
# Skip chart versions which seem to be templated.
102+
if chart_version.startswith("{{"):
103+
continue
104+
105+
local_repo = next(
106+
(repo for repo in local_repos if repo["name"] == repo_name), None
107+
)
108+
if local_repo is not None:
109+
local_repo_url = local_repo["url"]
110+
if local_repo_url != repo_url:
111+
raise Exception(
112+
dedent(f"""
113+
You have a local repo named {repo_name} pointing to {local_repo_url}, but the stack/demo wants {repo_url}
114+
Either delete or update your local repo URL, or update the stack/demo repo name so it doesn't conflict
115+
""")
116+
)
117+
75118
if repo_name not in seen_repos:
76119
run_helm_repo_add(repo_name, repo_url)
77120
seen_repos.add(repo_name)
78121

79-
run_helm_repo_update(repo_name)
80-
81122
# print(f"📦 Updating {filepath} -> {repo_name}/{chart_name}")
82-
new_chart_version, new_app_version = get_chart_and_app_version(repo_name, chart_name)
123+
new_chart_version, new_app_version = get_chart_and_app_version(
124+
repo_name, chart_name
125+
)
83126

84127
updated_lines = []
85128
for line in raw_lines:
86-
if line.strip().startswith("version:"):
87-
new_line = f'version: {new_chart_version} # {new_app_version}\n'
129+
if line.startswith("version:"):
130+
new_line = f"version: {new_chart_version} # appVersion: {new_app_version}\n"
88131
updated_lines.append(new_line)
89132
else:
90133
updated_lines.append(line)
@@ -95,13 +138,22 @@ def process_yaml_files(top_dir: str) -> None:
95138
print(f"✅ Updated {filepath}")
96139

97140
except Exception as e:
141+
# If debugging, you can get the exception line number like this:
142+
# _, _, tb = os.sys.exc_info()
143+
# lineno = tb.tb_lineno
98144
print(f"⚠️ Error processing {filepath}: {e}")
99145

146+
100147
if __name__ == "__main__":
101-
print('⚠️⚠️⚠️ This script is best-effort! Always check the result using "git diff"! ⚠️⚠️⚠️')
102-
print('Notably, it skips invalid YAMLs, which can be the case because we sometimes use templating syntax, even for helm-chart definitions')
103-
print('Please judge on the skipped files if they contain a helm-chart and should be manually bumped')
104-
print('The script can be improved to handle such files in the future')
105-
print()
148+
print(
149+
dedent("""
150+
⚠️⚠️⚠️ This script is best-effort! Always check the result using "git diff"! ⚠️⚠️⚠️
151+
Notably, it skips invalid YAMLs, which can be the case because we sometimes use templating syntax, even for helm-chart definitions.
152+
In those cases, use quotes around templated values, or otherwise comments for templated blocks.
153+
154+
Please judge on the skipped files if they contain a helm-chart and should be manually bumped.
155+
The script can be improved to handle such files in the future.
156+
""")
157+
)
106158

107159
process_yaml_files(".")

demos/argo-cd-git-ops/manifests/airflow-postgres/sealed-airflow-postgres-credentials.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ spec:
1818
namespace: stackable-airflow
1919
labels:
2020
stackable.tech/vendor: Stackable
21-
stackable.tech/demo: {{ DEMO }}
21+
stackable.tech/demo: "{{ DEMO }}"
2222
type: Opaque

demos/argo-cd-git-ops/manifests/airflow/airflow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
name: airflow
66
labels:
77
stackable.tech/vendor: Stackable
8-
stackable.tech/demo: {{ DEMO }}
8+
stackable.tech/demo: "{{ DEMO }}"
99
spec:
1010
image:
1111
productVersion: 3.2.2

demos/argo-cd-git-ops/manifests/airflow/sealed-airflow-credentials.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ spec:
2323
namespace: stackable-airflow
2424
labels:
2525
stackable.tech/vendor: Stackable
26-
stackable.tech/demo: {{ DEMO }}
26+
stackable.tech/demo: "{{ DEMO }}"
2727
type: Opaque

demos/argo-cd-git-ops/manifests/airflow/sealed-airflow-minio-connection.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ spec:
1515
namespace: stackable-airflow
1616
labels:
1717
stackable.tech/vendor: Stackable
18-
stackable.tech/demo: {{ DEMO }}
18+
stackable.tech/demo: "{{ DEMO }}"
1919
type: Opaque

demos/argo-cd-git-ops/manifests/minio/sealed-minio-credentials.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ spec:
1616
namespace: minio
1717
labels:
1818
stackable.tech/vendor: Stackable
19-
stackable.tech/demo: {{ DEMO }}
19+
stackable.tech/demo: "{{ DEMO }}"
2020
type: Opaque

stacks/_templates/argo-cd.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ name: argo-cd
44
repo:
55
name: argo-cd
66
url: https://argoproj.github.io/argo-helm
7-
version: 9.4.10 # v3.3.3
7+
version: 10.1.3 # appVersion: v3.4.5
88
options:
99
global:
1010
additionalLabels:
1111
stackable.tech/vendor: Stackable
12-
stackable.tech/stack: {{ STACK }}
12+
stackable.tech/stack: "{{ STACK }}"
1313
# The following is a Jinja2 template directive, not a regular comment.
1414
# The `#` prefix is required to prevent YAML parsing errors, but Jinja2 still processes it.
1515
# {% if DEMO is defined %}
16-
stackable.tech/demo: {{ DEMO }}
16+
stackable.tech/demo: "{{ DEMO }}"
1717
# {% endif %}
1818
configs:
1919
secret:

stacks/_templates/minio-distributed-small-tls/values.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
additionalLabels:
33
stackable.tech/vendor: Stackable
4-
stackable.tech/stack: {{ STACK }}
4+
stackable.tech/stack: "{{ STACK }}"
55
# The following is a Jinja2 template directive, not a regular comment.
66
# The `#` prefix is required to prevent YAML parsing errors, but Jinja2 still processes it.
77
# {% if DEMO is defined %}
8-
stackable.tech/demo: {{ DEMO }}
8+
stackable.tech/demo: "{{ DEMO }}"
99
# {% endif %}
1010
podLabels:
1111
stackable.tech/vendor: Stackable
12-
stackable.tech/stack: {{ STACK }}
12+
stackable.tech/stack: "{{ STACK }}"
1313
# The following is a Jinja2 template directive, not a regular comment.
1414
# The `#` prefix is required to prevent YAML parsing errors, but Jinja2 still processes it.
1515
# {% if DEMO is defined %}
16-
stackable.tech/demo: {{ DEMO }}
16+
stackable.tech/demo: "{{ DEMO }}"
1717
# {% endif %}
1818
rootUser: admin
1919
rootPassword: adminadmin

stacks/_templates/minio-distributed-tls/values.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
additionalLabels:
33
stackable.tech/vendor: Stackable
4-
stackable.tech/stack: {{ STACK }}
4+
stackable.tech/stack: "{{ STACK }}"
55
# The following is a Jinja2 template directive, not a regular comment.
66
# The `#` prefix is required to prevent YAML parsing errors, but Jinja2 still processes it.
77
# {% if DEMO is defined %}
8-
stackable.tech/demo: {{ DEMO }}
8+
stackable.tech/demo: "{{ DEMO }}"
99
# {% endif %}
1010
podLabels:
1111
stackable.tech/vendor: Stackable
12-
stackable.tech/stack: {{ STACK }}
12+
stackable.tech/stack: "{{ STACK }}"
1313
# The following is a Jinja2 template directive, not a regular comment.
1414
# The `#` prefix is required to prevent YAML parsing errors, but Jinja2 still processes it.
1515
# {% if DEMO is defined %}
16-
stackable.tech/demo: {{ DEMO }}
16+
stackable.tech/demo: "{{ DEMO }}"
1717
# {% endif %}
1818
rootUser: admin
1919
rootPassword: adminadmin

stacks/_templates/minio.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ name: minio
44
repo:
55
name: minio
66
url: https://charts.min.io/
7-
version: 5.4.0 # RELEASE.2024-12-18T13-15-44Z
7+
version: 5.4.0 # appVersion: RELEASE.2024-12-18T13-15-44Z
88
options:
99
additionalLabels:
1010
stackable.tech/vendor: Stackable
11-
stackable.tech/stack: {{ STACK }}
11+
stackable.tech/stack: "{{ STACK }}"
1212
# The following is a Jinja2 template directive, not a regular comment.
1313
# The `#` prefix is required to prevent YAML parsing errors, but Jinja2 still processes it.
1414
# {% if DEMO is defined %}
15-
stackable.tech/demo: {{ DEMO }}
15+
stackable.tech/demo: "{{ DEMO }}"
1616
# {% endif %}
1717
podLabels:
1818
stackable.tech/vendor: Stackable
19-
stackable.tech/stack: {{ STACK }}
19+
stackable.tech/stack: "{{ STACK }}"
2020
# The following is a Jinja2 template directive, not a regular comment.
2121
# The `#` prefix is required to prevent YAML parsing errors, but Jinja2 still processes it.
2222
# {% if DEMO is defined %}
23-
stackable.tech/demo: {{ DEMO }}
23+
stackable.tech/demo: "{{ DEMO }}"
2424
# {% endif %}
2525
rootUser: admin
26-
rootPassword: {{ minioAdminPassword }}
26+
rootPassword: "{{ minioAdminPassword }}"
2727
mode: standalone
2828
persistence:
2929
size: 10Gi

0 commit comments

Comments
 (0)