Skip to content

Commit 4c2c781

Browse files
committed
fix(platform): gate the MetalLB driver on its deps
cozystack.metallb-iad hard-depends on cozystack.metallb and on cozystack.address-controller, and a driver Package rendered without both beside it never leaves DependenciesNotReady — the wedge the velero and bucket-application comments in system.yaml already record for default packages, reachable here through an opt-in one. MetalLB is absent in three ways: on isp-hosted, which never calls the common-packages helper; on a slim variant that did not opt into it; and wherever disabledPackages names it. The core is absent unless enabled. Rather than restate those rules for the driver, the driver is gated on each dependency's own include having rendered a Package, so they cannot drift when either's rules change. The class-agnostic core stays in the variant-agnostic body: it carries no MetalLB dependency and is usable with another driver. Assisted-by: LLM Signed-off-by: Timofei Larkin <[email protected]>
1 parent ce5b763 commit 4c2c781

3 files changed

Lines changed: 165 additions & 6 deletions

File tree

‎packages/core/platform/templates/_helpers.tpl‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,21 @@ cozystack-scheduler (emitted with its own variant in both branches)
224224
{{include "cozystack.platform.package.default" (list "cozystack.kubeovn-plunger" $root) }}
225225
{{- end }}
226226
{{include "cozystack.platform.package.full.default" (list "cozystack.cozy-proxy" $root) }}
227-
{{include "cozystack.platform.package.full.default" (list "cozystack.metallb" $root) }}
227+
{{- $metallb := include "cozystack.platform.package.full.default" (list "cozystack.metallb" $root) }}
228+
{{ $metallb }}
229+
{{- /* The MetalLB IP Allocation Driver hard-depends on cozystack.metallb and on
230+
cozystack.address-controller, and a Package for it without both beside
231+
it sits DependenciesNotReady for good. MetalLB is absent on isp-hosted
232+
(which never calls this helper), on a slim variant that did not opt
233+
into it, and wherever disabledPackages names it; the core is opt-in
234+
everywhere. So the driver is gated on each dependency's own include
235+
having rendered a Package rather than on a restatement of those rules.
236+
The core is rendered here only to be tested: bundles/system.yaml emits
237+
it. */ -}}
238+
{{- $addressController := include "cozystack.platform.package.optional.default" (list "cozystack.address-controller" $root) }}
239+
{{- if and (trim $metallb) (trim $addressController) }}
240+
{{include "cozystack.platform.package.optional.default" (list "cozystack.metallb-iad" $root) }}
241+
{{- end }}
228242
{{include "cozystack.platform.package.default" (list "cozystack.reloader" $root) }}
229243
{{include "cozystack.platform.package.default" (list "cozystack.linstor-scheduler" $root) }}
230244
{{include "cozystack.platform.package.default" (list "cozystack.snapshot-controller" $root) }}

‎packages/core/platform/templates/bundles/system.yaml‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,9 @@ variants and opt-in on the slim ones. */}}
387387
{{- end }}
388388
{{include "cozystack.platform.package.optional.default" (list "cozystack.hetzner-robotlb" $) }}
389389
{{include "cozystack.platform.package.optional.default" (list "cozystack.talos-log-collector" $) }}
390-
{{- /* IP addresses as a first-class resource: the class-agnostic core plus the
391-
MetalLB driver. Enable both together — the driver's PackageSource
392-
dependsOn the core (and cozystack.metallb, which the isp-hosted variant
393-
never emits), so enabling only the driver leaves it waiting forever. */}}
390+
{{- /* IP addresses as a first-class resource, the class-agnostic core. Its
391+
MetalLB driver is emitted from the common-packages helper instead, beside
392+
the cozystack.metallb it cannot run without; enable both together. */}}
394393
{{include "cozystack.platform.package.optional.default" (list "cozystack.address-controller" $) }}
395-
{{include "cozystack.platform.package.optional.default" (list "cozystack.metallb-iad" $) }}
396394

397395
{{- end }}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
suite: the MetalLB address driver is emitted only beside MetalLB and the address core
2+
templates:
3+
- templates/bundles/system.yaml
4+
release:
5+
name: cozystack
6+
namespace: cozy-system
7+
8+
# cozystack.metallb-iad hard-depends on cozystack.metallb and on
9+
# cozystack.address-controller. A driver Package emitted without both beside
10+
# it can never leave DependenciesNotReady. MetalLB is absent in three ways: on
11+
# isp-hosted, on a slim variant that did not opt into it, and wherever
12+
# disabledPackages names it; the core is absent unless it is enabled.
13+
tests:
14+
- it: emits the driver on isp-full when enabled
15+
set:
16+
bundles:
17+
system:
18+
enabled: true
19+
variant: isp-full
20+
enabledPackages:
21+
- cozystack.address-controller
22+
- cozystack.metallb-iad
23+
asserts:
24+
- containsDocument:
25+
apiVersion: cozystack.io/v1alpha1
26+
kind: Package
27+
name: cozystack.metallb-iad
28+
any: true
29+
- containsDocument:
30+
apiVersion: cozystack.io/v1alpha1
31+
kind: Package
32+
name: cozystack.metallb
33+
any: true
34+
35+
- it: withholds the driver on isp-hosted even when enabled
36+
set:
37+
bundles:
38+
system:
39+
enabled: true
40+
variant: isp-hosted
41+
enabledPackages:
42+
- cozystack.address-controller
43+
- cozystack.metallb-iad
44+
asserts:
45+
# any: true is REQUIRED inside the matcher for the negative to search the
46+
# whole document set; without it containsDocument matches nothing and
47+
# `not: true` passes vacuously.
48+
- containsDocument:
49+
apiVersion: cozystack.io/v1alpha1
50+
kind: Package
51+
name: cozystack.metallb-iad
52+
any: true
53+
not: true
54+
# The core carries no MetalLB dependency, so it is still available there.
55+
- containsDocument:
56+
apiVersion: cozystack.io/v1alpha1
57+
kind: Package
58+
name: cozystack.address-controller
59+
any: true
60+
61+
- it: withholds the driver on a slim variant that did not opt into MetalLB
62+
set:
63+
bundles:
64+
system:
65+
enabled: true
66+
variant: isp-slim
67+
enabledPackages:
68+
- cozystack.address-controller
69+
- cozystack.metallb-iad
70+
asserts:
71+
- containsDocument:
72+
apiVersion: cozystack.io/v1alpha1
73+
kind: Package
74+
name: cozystack.metallb-iad
75+
any: true
76+
not: true
77+
78+
- it: emits the driver on a slim variant that opted into MetalLB
79+
set:
80+
bundles:
81+
system:
82+
enabled: true
83+
variant: isp-slim
84+
enabledPackages:
85+
- cozystack.metallb
86+
- cozystack.address-controller
87+
- cozystack.metallb-iad
88+
asserts:
89+
- containsDocument:
90+
apiVersion: cozystack.io/v1alpha1
91+
kind: Package
92+
name: cozystack.metallb-iad
93+
any: true
94+
95+
- it: withholds the driver where disabledPackages removes MetalLB
96+
set:
97+
bundles:
98+
system:
99+
enabled: true
100+
variant: isp-full
101+
enabledPackages:
102+
- cozystack.address-controller
103+
- cozystack.metallb-iad
104+
disabledPackages:
105+
- cozystack.metallb
106+
asserts:
107+
- containsDocument:
108+
apiVersion: cozystack.io/v1alpha1
109+
kind: Package
110+
name: cozystack.metallb-iad
111+
any: true
112+
not: true
113+
114+
- it: withholds the driver when the address core is not enabled
115+
set:
116+
bundles:
117+
system:
118+
enabled: true
119+
variant: isp-full
120+
enabledPackages:
121+
- cozystack.metallb-iad
122+
asserts:
123+
- containsDocument:
124+
apiVersion: cozystack.io/v1alpha1
125+
kind: Package
126+
name: cozystack.metallb-iad
127+
any: true
128+
not: true
129+
130+
- it: withholds the driver where disabledPackages removes the address core
131+
set:
132+
bundles:
133+
system:
134+
enabled: true
135+
variant: isp-full
136+
enabledPackages:
137+
- cozystack.address-controller
138+
- cozystack.metallb-iad
139+
disabledPackages:
140+
- cozystack.address-controller
141+
asserts:
142+
- containsDocument:
143+
apiVersion: cozystack.io/v1alpha1
144+
kind: Package
145+
name: cozystack.metallb-iad
146+
any: true
147+
not: true

0 commit comments

Comments
 (0)