fix(linstor): keep scheduler and GUI off a stale endpoint on a switch

Under backend blockstor linstor-scheduler and linstor-gui read the API
endpoint from the LinstorCluster the linstor release renders. The
backend reaches both charts in one platform render, and dependsOn holds
them back only while the linstor release is not Ready, so on a switch
they can upgrade before the linstor release has written
externalController. They then fell back to the values, linstor-controller,
a Service piraeus-operator removes in external mode, and nothing rendered
them again: the scheduler stayed pointed at a deleted controller.

Fail the render instead while the LinstorCluster names no external
controller. The platform's HelmReleases use the RetryOnFailure strategy,
and a failed render stores no release, so helm-controller retries after
the retry interval without counting a failure until the linstor release
has written the endpoint. Under backend linstor nothing changes.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
This commit is contained in:
Andrei Kvapil committed 2026-11-29 13:45:13 +01:00
1 parent eed86349a8
commit 71ab260239
7 files changed
+49 -37

No files matched your search

+1 -1
View File
@@ -60,6 +60,6 @@ then open <http://localhost:3373>.
| Name | Description | Value |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------- |
| `linstor.backend` | Storage backend the platform runs, `linstor` or `blockstor`. Under `blockstor` the endpoint and client Secret are read from the LinstorCluster the `linstor` package renders, and the two values below apply only while it runs an in-cluster controller. | `linstor` |
| `linstor.backend` | Storage backend the platform runs, `linstor` or `blockstor`. Under `blockstor` the endpoint and client Secret are read from the LinstorCluster the `linstor` package renders, the render fails until that object names an external controller, and the two values below apply only under `linstor`. | `linstor` |
| `linstor.endpoint` | In-cluster URL of the LINSTOR controller REST API (HTTPS, mTLS) | `https://linstor-controller.cozy-linstor.svc:3371` |
| `linstor.clientSecret` | Kubernetes Secret with `tls.crt`, `tls.key`, `ca.crt` used as the mTLS client certificate against the LINSTOR controller. Created by the `linstor` package. | `linstor-client-tls` |
@@ -25,10 +25,14 @@ which name the in-cluster controller and the Secret piraeus-operator issues
for it. Under backend blockstor the linstor package decides: it renders the
LinstorCluster that points piraeus-operator, and through it linstor-csi, at
the API, so this chart reads the same two fields and follows wherever they
point. A LinstorCluster still running an in-cluster controller leaves the
values in effect. The package depends on cozystack.linstor, so the
LinstorCluster exists before this chart renders; a render that finds none, or
more than one, fails rather than guess.
point. The package depends on cozystack.linstor, so the LinstorCluster
exists before this chart renders; a render that finds none, or more than one,
fails rather than guess. One without externalController fails as well: on a
backend switch this release can upgrade before the linstor release has
rewritten the LinstorCluster, and falling back to the values would leave the
GUI on linstor-controller, which piraeus-operator removes, with nothing to
render it again. Failing keeps the HelmRelease retrying until the endpoint is
there.
*/}}
{{- define "linstor-gui.apiClient" -}}
{{- $backend := .Values.linstor.backend | default "linstor" -}}
@@ -43,10 +47,11 @@ more than one, fails rather than guess.
{{- fail (printf "linstor.backend is blockstor, so the LINSTOR API endpoint is read from the LinstorCluster the linstor package renders, but the cluster has %d LinstorClusters" (len $clusters)) -}}
{{- end -}}
{{- $spec := (index $clusters 0).spec | default dict -}}
{{- with dig "externalController" "url" "" $spec -}}
{{- $endpoint = . -}}
{{- $clientSecret = dig "apiTLS" "clientSecretName" "linstor-client-tls" $spec -}}
{{- $endpoint = dig "externalController" "url" "" $spec -}}
{{- if not $endpoint -}}
{{- fail "linstor.backend is blockstor, but the LinstorCluster has no spec.externalController.url yet: the linstor release has not switched it to blockstor-apiserver. This release is retried until it has" -}}
{{- end -}}
{{- $clientSecret = dig "apiTLS" "clientSecretName" "linstor-client-tls" $spec -}}
{{- end -}}
endpoint: {{ $endpoint | quote }}
clientSecret: {{ $clientSecret | quote }}
@@ -83,9 +83,10 @@ tests:
secretName: linstor-client-tls
defaultMode: 0444
# While a LinstorCluster still runs its own controller under blockstor,
# that controller is the API linstor-csi uses, so this chart stays on it.
- it: keeps the values while the LinstorCluster runs an in-cluster controller
# On a backend switch this release can upgrade before the linstor release
# has written externalController. Falling back to the values would leave
# the GUI on linstor-controller for good; failing has Flux retry it.
- it: refuses blockstor while the LinstorCluster has no external controller yet
set:
linstor.backend: blockstor
kubernetesProvider:
@@ -95,11 +96,10 @@ tests:
apiVersion: piraeus.io/v1
metadata: {name: linstorcluster}
spec: {}
template: templates/configmap-nginx.yaml
template: templates/deployment.yaml
asserts:
- matchRegex:
path: data["nginx.conf"]
pattern: "proxy_pass https://linstor-controller.cozy-linstor.svc:3371;"
- failedTemplate:
errorPattern: "linstor.backend is blockstor, but the LinstorCluster has no spec.externalController.url yet"
- it: refuses blockstor when no LinstorCluster tells it where the API is
set:
+1 -1
View File
@@ -12,7 +12,7 @@ image:
## @param replicas Number of linstor-gui replicas
replicas: 1
## @section LINSTOR controller connection
## @param linstor.backend Storage backend the platform runs, `linstor` or `blockstor`. Under `blockstor` the endpoint and client Secret are read from the LinstorCluster the `linstor` package renders, and the two values below apply only while it runs an in-cluster controller.
## @param linstor.backend Storage backend the platform runs, `linstor` or `blockstor`. Under `blockstor` the endpoint and client Secret are read from the LinstorCluster the `linstor` package renders, the render fails until that object names an external controller, and the two values below apply only under `linstor`.
## @param linstor.endpoint In-cluster URL of the LINSTOR controller REST API (HTTPS, mTLS)
## @param linstor.clientSecret Kubernetes Secret with `tls.crt`, `tls.key`, `ca.crt` used as the mTLS client certificate against the LINSTOR controller. Created by the `linstor` package.
linstor:
@@ -8,11 +8,20 @@ Under backend linstor it returns nothing: the values name the in-cluster
controller and the Secret piraeus-operator issues for it. Under backend
blockstor the linstor package decides: it renders the LinstorCluster that
points piraeus-operator, and through it linstor-csi, at the API, so the
scheduler reads the same two fields and follows wherever they point. A
LinstorCluster still running an in-cluster controller leaves the values in
effect. The package depends on cozystack.linstor, so the LinstorCluster
exists before this chart renders; a render that finds none, or more than
one, fails rather than guess.
scheduler reads the same two fields and follows wherever they point. The
package depends on cozystack.linstor, so the LinstorCluster exists before
this chart renders; a render that finds none, or more than one, fails rather
than guess.
A LinstorCluster without externalController fails the render too. The
backend reaches this chart and the linstor chart in the same platform
render, and dependsOn holds this release back only while the linstor release
is not Ready, so on a switch it can upgrade first, against the LinstorCluster
the linstor release has not rewritten yet. Falling back to the values there
would leave the scheduler on linstor-controller, a Service piraeus-operator
removes once it sees externalController, and nothing would render this
release again. Failing keeps the HelmRelease retrying until the linstor
release has written the endpoint.
*/}}
{{- define "linstor-scheduler.cozystack.apiClient" -}}
{{- $backend := .Values.linstor.backend | default "linstor" -}}
@@ -25,9 +34,11 @@ one, fails rather than guess.
{{- fail (printf "linstor-scheduler.linstor.backend is blockstor, so the LINSTOR API endpoint is read from the LinstorCluster the linstor package renders, but the cluster has %d LinstorClusters" (len $clusters)) -}}
{{- end -}}
{{- $spec := (index $clusters 0).spec | default dict -}}
{{- with dig "externalController" "url" "" $spec }}
endpoint: {{ . | quote }}
{{- $endpoint := dig "externalController" "url" "" $spec -}}
{{- if not $endpoint -}}
{{- fail "linstor-scheduler.linstor.backend is blockstor, but the LinstorCluster has no spec.externalController.url yet: the linstor release has not switched it to blockstor-apiserver. This release is retried until it has" -}}
{{- end }}
endpoint: {{ $endpoint | quote }}
clientSecret: {{ dig "apiTLS" "clientSecretName" "linstor-client-tls" $spec | quote }}
{{- end -}}
{{- end -}}
{{- end }}
@@ -74,9 +74,10 @@ tests:
path: metadata.annotations["secret.reloader.stakater.com/reload"]
value: linstor-client-tls
# While a LinstorCluster still runs its own controller under blockstor,
# that controller is the API linstor-csi uses, so the scheduler stays on it.
- it: keeps the values while the LinstorCluster runs an in-cluster controller
# On a backend switch this release can upgrade before the linstor release
# has written externalController. Falling back to the values would leave
# the scheduler on linstor-controller for good; failing has Flux retry it.
- it: refuses blockstor while the LinstorCluster has no external controller yet
set:
linstor-scheduler.linstor.backend: blockstor
kubernetesProvider:
@@ -87,14 +88,8 @@ tests:
metadata: {name: linstorcluster}
spec: {}
asserts:
- contains:
path: spec.template.spec.containers[1].env
content:
name: LS_CONTROLLERS
value: https://linstor-controller.cozy-linstor.svc:3371
- equal:
path: metadata.annotations["secret.reloader.stakater.com/reload"]
value: linstor-client-tls
- failedTemplate:
errorPattern: "backend is blockstor, but the LinstorCluster has no spec.externalController.url yet"
- it: refuses blockstor when no LinstorCluster tells it where the API is
set:
@@ -11,8 +11,9 @@ linstor-scheduler:
linstor:
# The storage backend the platform runs, linstor or blockstor. Under
# blockstor the endpoint and client Secret come from the LinstorCluster
# the linstor package renders (templates/_helpers.tpl), and the two
# values below apply only while it runs an in-cluster controller.
# the linstor package renders (templates/_helpers.tpl), the render
# fails until that object names an external controller, and the two
# values below apply only under linstor.
backend: linstor
endpoint: "https://linstor-controller.cozy-linstor.svc:3371"
clientSecret: "linstor-client-tls"