Skip to content

Commit e5e17c8

Browse files
committed
fix: avoid t8s HelmRelease name colliding with run_plugin's cluster_id
run_plugin.py sets config['name'] to the cluster_id for every plugin kind, so PluginT8s's use of the same key for the VAP/RBAC-mandated HelmRelease name never fell back to its default. Renamed to 'hrName' to avoid the collision. Signed-off-by: Chris Werner Rau <cwrau@cwrau.info>
1 parent 514377b commit e5e17c8

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

Tests/kaas/plugin/plugin_t8s.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ class PluginT8s(KubernetesClusterPlugin):
2929
via a Flux HelmRelease.
3030
3131
Creates a HelmRelease on mgmt-bfe2-prod and waits for the resulting cluster's
32-
kubeconfig to appear in the secret '<name>-kubeconfig'.
32+
kubeconfig to appear in the secret '<hrName>-kubeconfig'.
33+
34+
Note: `config['name']` is set by run_plugin.py to the cluster_id (e.g. 'teuto-1.36')
35+
for all plugins; that is unrelated to the HelmRelease name below, which is why this
36+
plugin uses the distinct key `hrName` instead of reusing `name`.
3337
3438
Expected config keys:
3539
kubernetesVersion: '1.35' (major.minor)
@@ -38,8 +42,8 @@ class PluginT8s(KubernetesClusterPlugin):
3842
kubeconfig: t8s-kubeconfig.yaml (management cluster kubeconfig template)
3943
secrets:
4044
token: '{{ clouds_conf.teuto_mgmt_token }}'
41-
name: 'scs-kaas-certification' (optional, defaults to 'scs-kaas-certification';
42-
the kubeconfig secret name is derived as '<name>-kubeconfig')
45+
hrName: 'scs-kaas-certification' (optional, defaults to 'scs-kaas-certification';
46+
the kubeconfig secret name is derived as '<hrName>-kubeconfig')
4347
cloud: 'bfe2-prod' (optional, defaults to 'bfe2-prod')
4448
controlPlaneHosted: true (optional, defaults to true)
4549
nodePools: (optional, defaults to a single 'pool-0')
@@ -62,7 +66,7 @@ def __init__(self, config: dict[str, Any], basepath: str = ".", cwd: str = ".")
6266
# and cannot be changed without updating both the VAP and the RBAC. They are instance
6367
# (rather than module-level) attributes because, in principle, different certification
6468
# targets could be configured with different values here.
65-
self.hr_name = config.get("name", "scs-kaas-certification")
69+
self.hr_name = config.get("hrName", "scs-kaas-certification")
6670
self.hr_namespace = "scs-kaas-certification"
6771
self.hr_kubeconfig_secret = f"{self.hr_name}-kubeconfig"
6872
self.hr_chart_ref: dict[str, str] = {

Tests/kaas/plugin/test_plugin_t8s.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,22 @@ def test_hr_name_defaults(plugin):
175175

176176

177177
def test_hr_name_from_config(tmp_path):
178-
plugin = _make_plugin(tmp_path, name="other-target")
178+
plugin = _make_plugin(tmp_path, hrName="other-target")
179179
assert plugin.hr_name == "other-target"
180180
assert plugin.hr_kubeconfig_secret == "other-target-kubeconfig"
181181

182182
hr = plugin._build_helmrelease()
183183
assert hr["metadata"]["name"] == "other-target"
184184

185185

186+
def test_hr_name_ignores_run_plugin_name(tmp_path):
187+
# run_plugin.py does config.setdefault('name', cluster_id) for every plugin kind;
188+
# that generic identifier must not leak into the (differently-keyed) HR name.
189+
plugin = _make_plugin(tmp_path, name="teuto-1.36")
190+
assert plugin.hr_name == "scs-kaas-certification"
191+
assert plugin.hr_kubeconfig_secret == "scs-kaas-certification-kubeconfig"
192+
193+
186194
# --- version parsing ---
187195

188196
@pytest.mark.parametrize("version,version_patch,expected", [

0 commit comments

Comments
 (0)