diff --git a/hack/promote-retag.sh b/hack/promote-retag.sh index 16a212bce..c90376e40 100755 --- a/hack/promote-retag.sh +++ b/hack/promote-retag.sh @@ -150,6 +150,8 @@ for raw in $(collect_refs); do # ghcr.io/cozystack — see those packages' values.yaml) # - ghcr.io/cozystack/ingress-nginx-with-protobuf-exporter/*, which is a # cozystack-org repo but sits outside $REGISTRY's path + # - ghcr.io/cozystack/blockstor-*, released from the blockstor repository + # under its own version (see packages/system/linstor/values.yaml) # - non-ref scalars, e.g. a "--migrate-image=..." arg string # Note kilo, kube-ovn and keycloak-operator are NOT in that list: all three # are built and pushed to $REGISTRY, and are selected by shapes 3 and 4. An diff --git a/packages/core/platform/templates/_helpers.tpl b/packages/core/platform/templates/_helpers.tpl index 03ca23fb4..289cfbccb 100644 --- a/packages/core/platform/templates/_helpers.tpl +++ b/packages/core/platform/templates/_helpers.tpl @@ -11,6 +11,9 @@ {{- if eq $name "cozystack.networking" -}} {{- include "cozystack.platform.networking.variantGuard" (list $root $variant) -}} {{- end }} +{{- if eq $name "cozystack.linstor" -}} +{{- include "cozystack.platform.storage.backendGuard" $root -}} +{{- end }} --- apiVersion: cozystack.io/v1alpha1 kind: Package @@ -50,6 +53,31 @@ Call as (list $ ). {{- end -}} {{- end }} +{{/* +Refuses to change the storage backend of a live cozystack.linstor Package. +The two backends keep their state in different places, so a switch leaves +linstor-csi talking to a control plane that knows none of the existing +volumes, and blockstor-satellite's startup cleanup downs the DRBD resources it +does not consider healthy, whoever owns them. A live Package without a backend +value runs linstor, the chart default. As with the networking guard, the +acknowledgement names the target, and the guard is inert where lookup returns +nothing: helm template, client-side dry-run, first install. +*/}} +{{- define "cozystack.platform.storage.backendGuard" -}} +{{- $live := lookup "cozystack.io/v1alpha1" "Package" "" "cozystack.linstor" -}} +{{- if $live -}} +{{- $liveBackend := dig "spec" "components" "linstor" "values" "backend" "linstor" $live | toString -}} +{{- $backend := include "cozystack.platform.storage.backend" . -}} +{{- $ack := "" -}} +{{- if kindIs "map" .Values.storage -}} +{{- $ack = dig "acknowledgeBackendChange" "" .Values.storage | toString -}} +{{- end -}} +{{- if and (ne $liveBackend $backend) (ne $ack $backend) -}} +{{- fail (printf "the live cozystack.linstor Package runs the %q storage backend and this render would switch it to %q. The volumes this cluster already has are known only to the current backend: after the switch the CSI driver cannot attach, resize, snapshot or delete them. Restore storage.backend: %q, or, if the cluster holds no volumes, set storage.acknowledgeBackendChange: %q to confirm this exact switch." $liveBackend $backend $liveBackend $backend) -}} +{{- end -}} +{{- end -}} +{{- end }} + {{- define "cozystack.platform.package.default" -}} {{- $name := index . 0 -}} {{- $root := index . 1 -}} @@ -239,7 +267,21 @@ cozystack-scheduler (emitted with its own variant in both branches) {{include "cozystack.platform.package.optional.default" (list "cozystack.metallb-iad" $root) }} {{- end }} {{include "cozystack.platform.package.default" (list "cozystack.reloader" $root) }} +{{- /* linstor-scheduler and linstor-gui, the LINSTOR API consumers outside + the linstor package, are told only the backend. Under blockstor each + reads where the API is, and with which client certificate, from the + LinstorCluster the linstor package renders, the object that points + linstor-csi there too, so the names of blockstor's Service and Secret + stay in that package alone. Under linstor they get nothing and keep + their own defaults, linstor-controller and linstor-client-tls. The + backend is passed rather than left to the lookup alone so that a + switch changes their values and Helm renders them again. */ -}} +{{- if eq (include "cozystack.platform.storage.backend" $root) "blockstor" }} +{{- $schedulerComponents := dict "linstor-scheduler" (dict "values" (dict "linstor-scheduler" (dict "linstor" (dict "backend" "blockstor")))) -}} +{{include "cozystack.platform.package" (list "cozystack.linstor-scheduler" "default" $root $schedulerComponents) }} +{{- else }} {{include "cozystack.platform.package.default" (list "cozystack.linstor-scheduler" $root) }} +{{- end }} {{include "cozystack.platform.package.default" (list "cozystack.snapshot-controller" $root) }} {{- /* securitygroup-controller maintains membership labels for CiliumNetworkPolicy-backed SecurityGroups, so it only makes sense where Cilium runs. Keeping it here with the @@ -254,6 +296,33 @@ cozystack-scheduler (emitted with its own variant in both branches) {{- end }} {{- end }} +{{- /* +Resolve the storage backend for the linstor package. + +Defaults to `linstor`, which is what every existing cluster runs, and only +when the key is absent. `blockstor` is experimental and must be asked for +explicitly. Any value present but not one of the two strings fails the render, +empty ones included: `default` would map "", false or 0 to linstor, and on a +blockstor cluster that switches the control plane back. A null is the one +spelling the template cannot see, because Helm removes a key set to null +before rendering, so it reads as absent. +*/ -}} +{{- define "cozystack.platform.storage.backend" -}} +{{- $backend := "linstor" -}} +{{- if hasKey .Values "storage" -}} +{{- if not (kindIs "map" .Values.storage) -}} +{{- fail (printf "storage must be a map with a backend key, got %v" .Values.storage) -}} +{{- end -}} +{{- if hasKey .Values.storage "backend" -}} +{{- $backend = .Values.storage.backend -}} +{{- end -}} +{{- end -}} +{{- if not (and (kindIs "string" $backend) (has $backend (list "linstor" "blockstor"))) -}} +{{- fail (printf "storage.backend must be \"linstor\" or \"blockstor\", got %#v" $backend) -}} +{{- end -}} +{{- $backend -}} +{{- end -}} + {{/* The block Cilium takes its own addresses from on the kube-ovn variants, the last /21 of the pod CIDR, which kube-ovn is told to exclude. Called with the diff --git a/packages/core/platform/templates/bundles/system.yaml b/packages/core/platform/templates/bundles/system.yaml index f747210cc..8636368da 100644 --- a/packages/core/platform/templates/bundles/system.yaml +++ b/packages/core/platform/templates/bundles/system.yaml @@ -137,7 +137,12 @@ {{- $multusComponents := dict "multus" (dict "values" (include "cozystack.platform.multus.values" (list $ true) | fromYaml)) -}} {{include "cozystack.platform.package.full" (list "cozystack.multus" "default" $ $multusComponents) }} {{- end }} +{{- if eq (include "cozystack.platform.storage.backend" $) "blockstor" }} +{{- $linstorComponents := dict "linstor" (dict "values" (dict "backend" "blockstor")) -}} +{{include "cozystack.platform.package" (list "cozystack.linstor" "default" $ $linstorComponents) }} +{{- else }} {{include "cozystack.platform.package.default" (list "cozystack.linstor" $) }} +{{- end }} {{include "cozystack.platform.package" (list "cozystack.cozystack-scheduler" "linstor" $) }} {{- end }} @@ -230,7 +235,11 @@ {{- $multusComponents := dict "multus" (dict "values" (include "cozystack.platform.multus.values" (list $ true) | fromYaml)) -}} {{include "cozystack.platform.package.full" (list "cozystack.multus" "default" $ $multusComponents) }} {{- /* Pass talos.enabled: false to linstor for generic Linux */ -}} -{{- $linstorComponents := dict "linstor" (dict "values" (dict "talos" (dict "enabled" false))) -}} +{{- $linstorValues := dict "talos" (dict "enabled" false) -}} +{{- if eq (include "cozystack.platform.storage.backend" $) "blockstor" -}} +{{- $_ := set $linstorValues "backend" "blockstor" -}} +{{- end -}} +{{- $linstorComponents := dict "linstor" (dict "values" $linstorValues) -}} {{include "cozystack.platform.package" (list "cozystack.linstor" "default" $ $linstorComponents) }} {{include "cozystack.platform.package" (list "cozystack.cozystack-scheduler" "linstor" $) }} {{- end }} @@ -516,7 +525,14 @@ variants and opt-in on the slim ones. */}} {{include "cozystack.platform.package.optional.default" (list "cozystack.kuberture" $) }} {{include "cozystack.platform.package.optional.default" (list "cozystack.keda" $) }} {{include "cozystack.platform.package.optional.default" (list "cozystack.external-secrets-operator" $) }} +{{- /* Told only the backend, as linstor-scheduler is in the common-packages + helper: the linstor package's LinstorCluster says where the API is. */ -}} +{{- if eq (include "cozystack.platform.storage.backend" $) "blockstor" }} +{{- $guiComponents := dict "linstor-gui" (dict "values" (dict "linstor" (dict "backend" "blockstor"))) -}} +{{include "cozystack.platform.package.optional.default" (list "cozystack.linstor-gui" $ $guiComponents) }} +{{- else }} {{include "cozystack.platform.package.optional.default" (list "cozystack.linstor-gui" $) }} +{{- end }} {{- if has "cozystack.bootbox" (default (list) .Values.bundles.enabledPackages) }} {{include "cozystack.platform.package.default" (list "cozystack.bootbox-application" $) }} {{include "cozystack.platform.package.default" (list "cozystack.bootbox" $) }} diff --git a/packages/core/platform/tests/bundles_storage_backend_guard_test.yaml b/packages/core/platform/tests/bundles_storage_backend_guard_test.yaml new file mode 100644 index 000000000..77c17d3b0 --- /dev/null +++ b/packages/core/platform/tests/bundles_storage_backend_guard_test.yaml @@ -0,0 +1,98 @@ +suite: storage backend change guard (lookup of the live cozystack.linstor Package) + +# The backends keep their state apart, so switching one under a cluster that +# already has volumes strands them. The guard reads the live Package and is +# inert where lookup returns nothing (helm template, dry-run, fresh install). +templates: + - templates/bundles/system.yaml +release: + name: cozystack + namespace: cozy-system +set: + bundles: + system: + enabled: true + variant: isp-full +tests: + - it: refuses linstor -> blockstor on a live LINSTOR cluster and names the acknowledge value + set: + storage: + backend: blockstor + kubernetesProvider: + scheme: &scheme + "cozystack.io/v1alpha1/Package": + gvr: {group: "cozystack.io", version: "v1alpha1", resource: "packages"} + namespaced: false + objects: &liveLinstor + - kind: Package + apiVersion: cozystack.io/v1alpha1 + metadata: {name: cozystack.linstor} + spec: {variant: default} + asserts: + - failedTemplate: + errorPattern: 'runs the "linstor" storage backend and this render would switch it to "blockstor".*storage.acknowledgeBackendChange: "blockstor"' + + - it: refuses blockstor -> linstor on a live blockstor cluster + kubernetesProvider: + scheme: *scheme + objects: + - kind: Package + apiVersion: cozystack.io/v1alpha1 + metadata: {name: cozystack.linstor} + spec: + variant: default + components: + linstor: + values: {backend: blockstor} + asserts: + - failedTemplate: + errorPattern: 'runs the "blockstor" storage backend and this render would switch it to "linstor"' + + - it: renders the switch once it is acknowledged + set: + storage: + backend: blockstor + acknowledgeBackendChange: blockstor + kubernetesProvider: + scheme: *scheme + objects: *liveLinstor + asserts: + - equal: + path: spec.components.linstor.values.backend + value: blockstor + documentSelector: + path: metadata.name + value: cozystack.linstor + + # An acknowledgement left set from an earlier switch does not cover the + # opposite one. + - it: does not take an acknowledgement for another target + set: + storage: + backend: blockstor + acknowledgeBackendChange: linstor + kubernetesProvider: + scheme: *scheme + objects: *liveLinstor + asserts: + - failedTemplate: + errorPattern: 'would switch it to "blockstor"' + + - it: renders an unchanged backend on a live cluster + kubernetesProvider: + scheme: *scheme + objects: *liveLinstor + asserts: + - notFailedTemplate: {} + + - it: renders blockstor on a fresh install + set: + storage: + backend: blockstor + asserts: + - equal: + path: spec.components.linstor.values.backend + value: blockstor + documentSelector: + path: metadata.name + value: cozystack.linstor diff --git a/packages/core/platform/tests/bundles_storage_backend_test.yaml b/packages/core/platform/tests/bundles_storage_backend_test.yaml new file mode 100644 index 000000000..325a10c59 --- /dev/null +++ b/packages/core/platform/tests/bundles_storage_backend_test.yaml @@ -0,0 +1,210 @@ +suite: storage backend selection reaches the linstor package +templates: + - templates/bundles/system.yaml +release: + name: cozystack + namespace: cozy-system + +# The operator picks the storage control plane at install time. The choice has +# to arrive at the linstor package as a value, because that package renders one +# backend or the other from it — a choice that stayed in the platform chart +# would be inert. LINSTOR is the default: every existing cluster runs it, and a +# silent flip would swap the storage control plane under live data. +tests: + # The default leaves the linstor Package exactly as it was before the choice + # existed: no components, so the chart default (linstor) applies and an + # upgrade does not roll a new revision of the release for nothing. + - it: defaults to the linstor backend without restating it + set: + bundles: + system: + enabled: true + variant: isp-full + asserts: + - notExists: + path: spec.components + documentSelector: + path: metadata.name + value: cozystack.linstor + + - it: states nothing but the talos override on the generic variant by default + set: + bundles: + system: + enabled: true + variant: isp-full-generic + asserts: + - equal: + path: spec.components.linstor.values + value: + talos: + enabled: false + documentSelector: + path: metadata.name + value: cozystack.linstor + + - it: passes blockstor through when the operator asks for it + set: + storage: + backend: blockstor + bundles: + system: + enabled: true + variant: isp-full + asserts: + - equal: + path: spec.components.linstor.values.backend + value: blockstor + documentSelector: + path: metadata.name + value: cozystack.linstor + + - it: keeps the generic variant's talos override alongside the backend + set: + storage: + backend: blockstor + bundles: + system: + enabled: true + variant: isp-full-generic + asserts: + - equal: + path: spec.components.linstor.values.backend + value: blockstor + documentSelector: + path: metadata.name + value: cozystack.linstor + - equal: + path: spec.components.linstor.values.talos.enabled + value: false + documentSelector: + path: metadata.name + value: cozystack.linstor + + # A typo must not quietly deploy the wrong storage control plane. + - it: fails the render on an unrecognised backend + set: + storage: + backend: blockstore + bundles: + system: + enabled: true + variant: isp-full + asserts: + - failedTemplate: + errorMessage: 'storage.backend must be "linstor" or "blockstor", got "blockstore"' + + # Under linstor the API consumers keep their chart defaults, which name the + # objects piraeus-operator creates. Under blockstor they are told only the + # backend: where the API is comes from the LinstorCluster the linstor package + # renders, so the platform names neither blockstor's Service nor its Secret. + - it: leaves the linstor-scheduler on its defaults under linstor + set: + bundles: + system: + enabled: true + variant: isp-full + asserts: + - notExists: + path: spec.components + documentSelector: + path: metadata.name + value: cozystack.linstor-scheduler + + - it: tells the linstor-scheduler only the backend under blockstor + set: + storage: + backend: blockstor + bundles: + system: + enabled: true + variant: isp-full + asserts: + - equal: + path: spec.components.linstor-scheduler.values.linstor-scheduler.linstor + value: + backend: blockstor + documentSelector: + path: metadata.name + value: cozystack.linstor-scheduler + + - it: tells linstor-gui only the backend under blockstor + set: + storage: + backend: blockstor + bundles: + system: + enabled: true + variant: isp-full + enabledPackages: [cozystack.linstor-gui] + asserts: + - equal: + path: spec.components.linstor-gui.values.linstor + value: + backend: blockstor + documentSelector: + path: metadata.name + value: cozystack.linstor-gui + + - it: leaves linstor-gui on its defaults under linstor + set: + bundles: + system: + enabled: true + variant: isp-full + enabledPackages: [cozystack.linstor-gui] + asserts: + - notExists: + path: spec.components + documentSelector: + path: metadata.name + value: cozystack.linstor-gui + + # An empty value is not "unset". `default` would have read each of these as + # linstor, and on a blockstor cluster that is a switch of control plane. + - it: fails the render on an empty backend + set: + storage: + backend: "" + bundles: + system: + enabled: true + variant: isp-full + asserts: + - failedTemplate: + errorMessage: 'storage.backend must be "linstor" or "blockstor", got ""' + + - it: fails the render on a false backend + set: + storage: + backend: false + bundles: + system: + enabled: true + variant: isp-full + asserts: + - failedTemplate: + errorMessage: 'storage.backend must be "linstor" or "blockstor", got false' + + - it: fails the render on a numeric backend + set: + storage: + backend: 0 + bundles: + system: + enabled: true + variant: isp-full + asserts: + - failedTemplate: + errorMessage: 'storage.backend must be "linstor" or "blockstor", got 0' + + - it: fails the render on a storage key that is not a map + set: + storage: blockstor + bundles: + system: + enabled: true + variant: isp-full + asserts: + - failedTemplate: + errorMessage: 'storage must be a map with a backend key, got blockstor' diff --git a/packages/core/platform/values.yaml b/packages/core/platform/values.yaml index 4b7ae0e50..aa496eaf6 100644 --- a/packages/core/platform/values.yaml +++ b/packages/core/platform/values.yaml @@ -108,6 +108,24 @@ migrations: # Reset it to false once the upgrade is through, or the next platform upgrade # that adds an etcd migration will skip its snapshot too. etcdAdoptSkipBackup: false +# Which storage control plane the cluster runs. +# +# linstor — the default, and what every existing cluster runs. +# blockstor — EXPERIMENTAL, for new clusters only. A +# LINSTOR-API-compatible control plane serving the same +# CSI driver and StorageClasses. Do not switch a cluster +# that already holds LINSTOR volumes: the pinned blockstor +# release cannot adopt them safely, and nothing converts +# LINSTOR's database into blockstor's. +# +# Anything else fails the render rather than defaulting, so a typo +# cannot quietly deploy the wrong storage control plane. Changing the +# backend of a running cluster fails the render too; on a cluster that +# holds no volumes yet, set storage.acknowledgeBackendChange to the new +# backend to confirm the switch. +storage: + backend: linstor + # Bundle deployment configuration bundles: system: diff --git a/packages/system/linstor-gui/README.md b/packages/system/linstor-gui/README.md index 8f8053ab5..8f13f02e7 100644 --- a/packages/system/linstor-gui/README.md +++ b/packages/system/linstor-gui/README.md @@ -60,5 +60,6 @@ then open . | 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.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` | diff --git a/packages/system/linstor-gui/templates/_helpers.tpl b/packages/system/linstor-gui/templates/_helpers.tpl index 6cad99ee8..cfdc2b4bd 100644 --- a/packages/system/linstor-gui/templates/_helpers.tpl +++ b/packages/system/linstor-gui/templates/_helpers.tpl @@ -15,3 +15,39 @@ Selector labels app.kubernetes.io/name: linstor-gui app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} + +{{/* +Where the LINSTOR API is and which client certificate it takes, as YAML with +endpoint and clientSecret keys. + +Under backend linstor that is linstor.endpoint and linstor.clientSecret, +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. +*/}} +{{- define "linstor-gui.apiClient" -}} +{{- $backend := .Values.linstor.backend | default "linstor" -}} +{{- if not (has $backend (list "linstor" "blockstor")) -}} +{{- fail (printf "linstor.backend must be \"linstor\" or \"blockstor\", got %#v" $backend) -}} +{{- end -}} +{{- $endpoint := .Values.linstor.endpoint -}} +{{- $clientSecret := .Values.linstor.clientSecret -}} +{{- if eq $backend "blockstor" -}} +{{- $clusters := (lookup "piraeus.io/v1" "LinstorCluster" "" "").items | default list -}} +{{- if ne (len $clusters) 1 -}} +{{- 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 -}} +{{- end -}} +{{- end -}} +endpoint: {{ $endpoint | quote }} +clientSecret: {{ $clientSecret | quote }} +{{- end }} diff --git a/packages/system/linstor-gui/templates/configmap-nginx.yaml b/packages/system/linstor-gui/templates/configmap-nginx.yaml index 86acd0f7a..58a6cfae0 100644 --- a/packages/system/linstor-gui/templates/configmap-nginx.yaml +++ b/packages/system/linstor-gui/templates/configmap-nginx.yaml @@ -3,10 +3,11 @@ Parse the LINSTOR endpoint so nginx can set `proxy_ssl_name` correctly. The endpoint must be an https:// URL — http:// would downgrade the mTLS-protected controller path. */}} -{{- if not (hasPrefix "https://" .Values.linstor.endpoint) -}} +{{- $api := include "linstor-gui.apiClient" . | fromYaml -}} +{{- if not (hasPrefix "https://" $api.endpoint) -}} {{- fail "linstor.endpoint must start with https:// to enforce mTLS to the LINSTOR controller" -}} {{- end -}} -{{- $endpoint := trimPrefix "https://" .Values.linstor.endpoint -}} +{{- $endpoint := trimPrefix "https://" $api.endpoint -}} {{- $endpointHost := (splitList ":" $endpoint) | first -}} apiVersion: v1 kind: ConfigMap @@ -89,16 +90,16 @@ data: if ($request_method !~ ^(GET|HEAD)$) { return 403 '{"ret_code":-1,"message":"linstor-gui in-app authentication is disabled by cozystack: authentication is enforced at the Ingress via Keycloak."}'; } - proxy_pass {{ .Values.linstor.endpoint }}; + proxy_pass {{ $api.endpoint }}; } # Proxy LINSTOR REST API over mTLS to the controller location /v1 { - proxy_pass {{ .Values.linstor.endpoint }}; + proxy_pass {{ $api.endpoint }}; } location /metrics { - proxy_pass {{ .Values.linstor.endpoint }}; + proxy_pass {{ $api.endpoint }}; } location = /healthz { diff --git a/packages/system/linstor-gui/templates/deployment.yaml b/packages/system/linstor-gui/templates/deployment.yaml index 92e2f7a66..2bc6a5c56 100644 --- a/packages/system/linstor-gui/templates/deployment.yaml +++ b/packages/system/linstor-gui/templates/deployment.yaml @@ -90,7 +90,7 @@ spec: name: linstor-gui-nginx - name: linstor-client-tls secret: - secretName: {{ .Values.linstor.clientSecret }} + secretName: {{ (include "linstor-gui.apiClient" . | fromYaml).clientSecret }} # 0444 so nginx (UID 101) can read the mTLS client keypair; # the secret volume is pod-local, not a broader disclosure. defaultMode: 0444 diff --git a/packages/system/linstor-gui/tests/api_client_test.yaml b/packages/system/linstor-gui/tests/api_client_test.yaml new file mode 100644 index 000000000..44b674449 --- /dev/null +++ b/packages/system/linstor-gui/tests/api_client_test.yaml @@ -0,0 +1,118 @@ +suite: the LINSTOR API endpoint follows the backend + +# Under blockstor the linstor package, not this chart or the platform, knows +# where the API is: it writes the URL and the client Secret into the +# LinstorCluster that points linstor-csi there. These cases feed that object +# through lookup. +templates: + - templates/configmap-nginx.yaml + - templates/deployment.yaml +release: + name: linstor-gui + namespace: cozy-linstor +tests: + - it: stays on the in-cluster controller under linstor + asserts: + - template: templates/configmap-nginx.yaml + matchRegex: + path: data["nginx.conf"] + pattern: "proxy_pass https://linstor-controller.cozy-linstor.svc:3371;" + - template: templates/deployment.yaml + contains: + path: spec.template.spec.volumes + content: + name: linstor-client-tls + secret: + secretName: linstor-client-tls + defaultMode: 0444 + + - it: follows the external controller of the LinstorCluster under blockstor + set: + linstor.backend: blockstor + kubernetesProvider: + scheme: &scheme + "piraeus.io/v1/LinstorCluster": + gvr: {group: "piraeus.io", version: "v1", resource: "linstorclusters"} + namespaced: false + objects: + - kind: LinstorCluster + apiVersion: piraeus.io/v1 + metadata: {name: linstorcluster} + spec: + externalController: + url: https://api.example.svc:3371 + apiTLS: + clientSecretName: example-client-tls + asserts: + - template: templates/configmap-nginx.yaml + matchRegex: + path: data["nginx.conf"] + pattern: "proxy_pass https://api.example.svc:3371;" + - template: templates/configmap-nginx.yaml + matchRegex: + path: data["nginx.conf"] + pattern: "proxy_ssl_name api.example.svc;" + - template: templates/deployment.yaml + contains: + path: spec.template.spec.volumes + content: + name: linstor-client-tls + secret: + secretName: example-client-tls + defaultMode: 0444 + + - it: takes piraeus's default client Secret when the LinstorCluster names none + set: + linstor.backend: blockstor + kubernetesProvider: + scheme: *scheme + objects: + - kind: LinstorCluster + apiVersion: piraeus.io/v1 + metadata: {name: linstorcluster} + spec: + externalController: + url: https://api.example.svc:3371 + template: templates/deployment.yaml + asserts: + - contains: + path: spec.template.spec.volumes + content: + name: linstor-client-tls + secret: + 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 + set: + linstor.backend: blockstor + kubernetesProvider: + scheme: *scheme + objects: + - kind: LinstorCluster + apiVersion: piraeus.io/v1 + metadata: {name: linstorcluster} + spec: {} + template: templates/configmap-nginx.yaml + asserts: + - matchRegex: + path: data["nginx.conf"] + pattern: "proxy_pass https://linstor-controller.cozy-linstor.svc:3371;" + + - it: refuses blockstor when no LinstorCluster tells it where the API is + set: + linstor.backend: blockstor + template: templates/deployment.yaml + asserts: + - failedTemplate: + errorPattern: "linstor.backend is blockstor.*the cluster has 0 LinstorClusters" + + - it: refuses an unknown backend + set: + linstor.backend: blockstore + template: templates/deployment.yaml + asserts: + - failedTemplate: + errorMessage: 'linstor.backend must be "linstor" or "blockstor", got "blockstore"' diff --git a/packages/system/linstor-gui/values.yaml b/packages/system/linstor-gui/values.yaml index f35ddb8b3..48414c905 100644 --- a/packages/system/linstor-gui/values.yaml +++ b/packages/system/linstor-gui/values.yaml @@ -12,8 +12,10 @@ 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.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: + backend: "linstor" endpoint: "https://linstor-controller.cozy-linstor.svc:3371" clientSecret: "linstor-client-tls" diff --git a/packages/system/linstor-scheduler/Makefile b/packages/system/linstor-scheduler/Makefile index 5961a1da9..e02f0f8d6 100644 --- a/packages/system/linstor-scheduler/Makefile +++ b/packages/system/linstor-scheduler/Makefile @@ -16,3 +16,4 @@ update: # tests/ are the source of truth (same policy as packages/system/coredns). rm -rf charts/linstor-scheduler/tests patch --no-backup-if-mismatch -p4 < patches/cozystack-scheduler-deployment.patch + patch --no-backup-if-mismatch -p4 < patches/cozystack-api-client.patch diff --git a/packages/system/linstor-scheduler/charts/linstor-scheduler/templates/_helpers.tpl b/packages/system/linstor-scheduler/charts/linstor-scheduler/templates/_helpers.tpl index fd0487759..f13267bcd 100644 --- a/packages/system/linstor-scheduler/charts/linstor-scheduler/templates/_helpers.tpl +++ b/packages/system/linstor-scheduler/charts/linstor-scheduler/templates/_helpers.tpl @@ -133,7 +133,10 @@ Strips distribution suffixes like +k3s1, +rke2r1 from version string. Find the linstor client secret containing TLS certificates */}} {{- define "linstor-scheduler.linstorClientSecretName" -}} -{{- if .Values.linstor.clientSecret }} +{{- $cozystack := include "linstor-scheduler.cozystack.apiClient" . | fromYaml }} +{{- if $cozystack.clientSecret }} +{{- $cozystack.clientSecret }} +{{- else if .Values.linstor.clientSecret }} {{- .Values.linstor.clientSecret }} {{- else if .Capabilities.APIVersions.Has "piraeus.linbit.com/v1/LinstorController" }} {{- $crs := (lookup "piraeus.linbit.com/v1" "LinstorController" .Release.Namespace "").items }} @@ -189,7 +192,10 @@ Find the linstor URL by operator resources Find the linstor URL either by override or cluster resources */}} {{- define "linstor-scheduler.linstorEndpoint" -}} -{{- if .Values.linstor.endpoint }} +{{- $cozystack := include "linstor-scheduler.cozystack.apiClient" . | fromYaml }} +{{- if $cozystack.endpoint }} +{{- $cozystack.endpoint }} +{{- else if .Values.linstor.endpoint }} {{- .Values.linstor.endpoint }} {{- else }} {{- $piraeus := include "linstor-scheduler.linstorEndpointFromCRD" . }} diff --git a/packages/system/linstor-scheduler/patches/cozystack-api-client.patch b/packages/system/linstor-scheduler/patches/cozystack-api-client.patch new file mode 100644 index 000000000..478b9e619 --- /dev/null +++ b/packages/system/linstor-scheduler/patches/cozystack-api-client.patch @@ -0,0 +1,37 @@ +# Let the cozystack wrapper decide where the LINSTOR API is before the +# chart's own linstor.endpoint and linstor.clientSecret values do. +# +# Under the blockstor storage backend the API is wherever the linstor +# package points piraeus-operator, so the wrapper's +# templates/_helpers.tpl reads that from the LinstorCluster and both +# helpers below prefer its answer. It answers nothing under the linstor +# backend, which leaves the upstream order as it is. +# +# Chart source: https://piraeus.io/helm-charts (linstor-scheduler 0.3.1) +diff --git a/packages/system/linstor-scheduler/charts/linstor-scheduler/templates/_helpers.tpl b/packages/system/linstor-scheduler/charts/linstor-scheduler/templates/_helpers.tpl +--- a/packages/system/linstor-scheduler/charts/linstor-scheduler/templates/_helpers.tpl ++++ b/packages/system/linstor-scheduler/charts/linstor-scheduler/templates/_helpers.tpl +@@ -133,7 +133,10 @@ Strips distribution suffixes like +k3s1, +rke2r1 from version string. + Find the linstor client secret containing TLS certificates + */}} + {{- define "linstor-scheduler.linstorClientSecretName" -}} +-{{- if .Values.linstor.clientSecret }} ++{{- $cozystack := include "linstor-scheduler.cozystack.apiClient" . | fromYaml }} ++{{- if $cozystack.clientSecret }} ++{{- $cozystack.clientSecret }} ++{{- else if .Values.linstor.clientSecret }} + {{- .Values.linstor.clientSecret }} + {{- else if .Capabilities.APIVersions.Has "piraeus.linbit.com/v1/LinstorController" }} + {{- $crs := (lookup "piraeus.linbit.com/v1" "LinstorController" .Release.Namespace "").items }} +@@ -189,7 +192,10 @@ Find the linstor URL by operator resources + Find the linstor URL either by override or cluster resources + */}} + {{- define "linstor-scheduler.linstorEndpoint" -}} +-{{- if .Values.linstor.endpoint }} ++{{- $cozystack := include "linstor-scheduler.cozystack.apiClient" . | fromYaml }} ++{{- if $cozystack.endpoint }} ++{{- $cozystack.endpoint }} ++{{- else if .Values.linstor.endpoint }} + {{- .Values.linstor.endpoint }} + {{- else }} + {{- $piraeus := include "linstor-scheduler.linstorEndpointFromCRD" . }} diff --git a/packages/system/linstor-scheduler/templates/_helpers.tpl b/packages/system/linstor-scheduler/templates/_helpers.tpl new file mode 100644 index 000000000..a15579251 --- /dev/null +++ b/packages/system/linstor-scheduler/templates/_helpers.tpl @@ -0,0 +1,33 @@ +{{/* +Where the LINSTOR API is and which client certificate it takes, as YAML with +endpoint and clientSecret keys, or nothing to leave the subchart on +linstor.endpoint and linstor.clientSecret. Called from the subchart's own +helpers (patches/cozystack-api-client.patch), so `.` is the subchart context. + +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. +*/}} +{{- define "linstor-scheduler.cozystack.apiClient" -}} +{{- $backend := .Values.linstor.backend | default "linstor" -}} +{{- if not (has $backend (list "linstor" "blockstor")) -}} +{{- fail (printf "linstor-scheduler.linstor.backend must be \"linstor\" or \"blockstor\", got %#v" $backend) -}} +{{- end -}} +{{- if eq $backend "blockstor" -}} +{{- $clusters := (lookup "piraeus.io/v1" "LinstorCluster" "" "").items | default list -}} +{{- if ne (len $clusters) 1 -}} +{{- 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 }} +clientSecret: {{ dig "apiTLS" "clientSecretName" "linstor-client-tls" $spec | quote }} +{{- end -}} +{{- end -}} +{{- end }} diff --git a/packages/system/linstor-scheduler/tests/api_client_test.yaml b/packages/system/linstor-scheduler/tests/api_client_test.yaml new file mode 100644 index 000000000..f0f2ad77c --- /dev/null +++ b/packages/system/linstor-scheduler/tests/api_client_test.yaml @@ -0,0 +1,111 @@ +suite: the LINSTOR API endpoint follows the backend + +# Under blockstor the linstor package, not this chart or the platform, knows +# where the API is: it writes the URL and the client Secret into the +# LinstorCluster that points linstor-csi there. These cases feed that object +# through lookup. +templates: + - charts/linstor-scheduler/templates/deployment.yaml +release: + name: linstor-scheduler + namespace: cozy-linstor +tests: + - it: stays on the in-cluster controller under linstor + 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 + + - it: follows the external controller of the LinstorCluster under blockstor + set: + linstor-scheduler.linstor.backend: blockstor + kubernetesProvider: + scheme: &scheme + "piraeus.io/v1/LinstorCluster": + gvr: {group: "piraeus.io", version: "v1", resource: "linstorclusters"} + namespaced: false + objects: + - kind: LinstorCluster + apiVersion: piraeus.io/v1 + metadata: {name: linstorcluster} + spec: + externalController: + url: https://api.example.svc:3371 + apiTLS: + clientSecretName: example-client-tls + asserts: + - contains: + path: spec.template.spec.containers[1].env + content: + name: LS_CONTROLLERS + value: https://api.example.svc:3371 + - contains: + path: spec.template.spec.containers[1].env + content: + name: LS_ROOT_CA + valueFrom: + secretKeyRef: + name: example-client-tls + key: ca.crt + - equal: + path: metadata.annotations["secret.reloader.stakater.com/reload"] + value: example-client-tls + + - it: takes piraeus's default client Secret when the LinstorCluster names none + set: + linstor-scheduler.linstor.backend: blockstor + linstor-scheduler.linstor.clientSecret: other-client-tls + kubernetesProvider: + scheme: *scheme + objects: + - kind: LinstorCluster + apiVersion: piraeus.io/v1 + metadata: {name: linstorcluster} + spec: + externalController: + url: https://api.example.svc:3371 + asserts: + - equal: + 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 + set: + linstor-scheduler.linstor.backend: blockstor + kubernetesProvider: + scheme: *scheme + objects: + - kind: LinstorCluster + apiVersion: piraeus.io/v1 + 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 + + - it: refuses blockstor when no LinstorCluster tells it where the API is + set: + linstor-scheduler.linstor.backend: blockstor + asserts: + - failedTemplate: + errorPattern: "backend is blockstor.*the cluster has 0 LinstorClusters" + + - it: refuses an unknown backend + set: + linstor-scheduler.linstor.backend: blockstore + asserts: + - failedTemplate: + errorMessage: 'linstor-scheduler.linstor.backend must be "linstor" or "blockstor", got "blockstore"' diff --git a/packages/system/linstor-scheduler/values.yaml b/packages/system/linstor-scheduler/values.yaml index e181fc8f2..854ae5940 100644 --- a/packages/system/linstor-scheduler/values.yaml +++ b/packages/system/linstor-scheduler/values.yaml @@ -9,6 +9,11 @@ linstor-scheduler: # node: this buys drain safety, not node-failure HA. replicaCount: 2 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. + backend: linstor endpoint: "https://linstor-controller.cozy-linstor.svc:3371" clientSecret: "linstor-client-tls" admission: diff --git a/packages/system/linstor/Makefile b/packages/system/linstor/Makefile index e58fc8578..bbc9f6da1 100644 --- a/packages/system/linstor/Makefile +++ b/packages/system/linstor/Makefile @@ -10,6 +10,21 @@ LINSTOR_VERSION ?= 1.35.3 # has to be re-checked against the new one. LINSTOR_CSI_VERSION ?= v1.13.2 +# blockstor's CRDs are copied unmodified from the release its images are pinned +# to, so the schema and the binaries that read it always come from one tag. +# Bump the three blockstor image tags in values.yaml first, then run this. +BLOCKSTOR_VERSION ?= $(shell yq e '.blockstorController.image.tag' values.yaml | cut -d@ -f1) + +update-blockstor-crds: + tmpdir=$$(mktemp -d) && \ + { curl --fail --silent --show-error --location -o "$$tmpdir/source.tar.gz" \ + "https://github.com/cozystack/blockstor/archive/refs/tags/v$(BLOCKSTOR_VERSION).tar.gz" && \ + mkdir "$$tmpdir/src" && tar -xzf "$$tmpdir/source.tar.gz" --strip-components=1 -C "$$tmpdir/src" && \ + ls "$$tmpdir"/src/config/crd/bases/blockstor.cozystack.io_*.yaml >/dev/null || { rm -rf "$$tmpdir"; exit 1; }; } && \ + rm -f definitions/blockstor.cozystack.io_*.yaml && \ + cp "$$tmpdir"/src/config/crd/bases/blockstor.cozystack.io_*.yaml definitions/ && \ + rm -rf "$$tmpdir" + test: helm unittest . python3 -m unittest discover -s tests -p 'test_*.py' -v diff --git a/packages/system/linstor/definitions/blockstor.cozystack.io_controllerconfigs.yaml b/packages/system/linstor/definitions/blockstor.cozystack.io_controllerconfigs.yaml new file mode 100644 index 000000000..93fdf34c5 --- /dev/null +++ b/packages/system/linstor/definitions/blockstor.cozystack.io_controllerconfigs.yaml @@ -0,0 +1,337 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.20.1 + name: controllerconfigs.blockstor.cozystack.io +spec: + group: blockstor.cozystack.io + names: + kind: ControllerConfig + listKind: ControllerConfigList + plural: controllerconfigs + singular: controllerconfig + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: |- + ControllerConfig is the cluster-wide singleton config for the + blockstor controller. Exactly one instance with name=`default` + is recognised; any other instance is ignored. Phase 10.4. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: spec defines the desired state of ControllerConfig + properties: + drbdOptions: + description: |- + drbdOptions is the cluster-wide DRBD configuration. Acts as + the controller-scope input to the typed hierarchy resolver + (`pkg/drbd.ResolveDRBDOptions`). + properties: + disk: + description: |- + disk configures the `disk { ... }` section (on-io-error, + activity-log size, resync hints). + properties: + alExtents: + description: |- + alExtents is the activity-log size (in extents). Larger values + reduce metadata write amplification at the cost of longer + resync windows. + format: int32 + type: integer + onIoError: + description: |- + onIOError is the action when the local backing device returns + an I/O error. `detach` is the production-safe default — the + satellite drops the local replica to Diskless and consumers + keep going via the network path. + enum: + - detach + - pass-on + - call-local-io-error + type: string + type: object + handlers: + additionalProperties: + type: string + description: |- + handlers maps event names to script paths (e.g. fence-peer, + before-resync-target). Free-form for now; the rendered .res + emits one line per pair under `handlers { }`. + type: object + net: + description: |- + net configures the `net { ... }` section of the rendered .res + file (replication protocol, secret, dual-primary, after-sb). + properties: + afterSb0Pri: + description: |- + afterSb0Pri is the recovery action when DRBD detects split- + brain and both sides were Secondary at the time. + enum: + - disconnect + - discard-younger-primary + - discard-older-primary + - discard-zero-changes + - discard-least-changes + - discard-local + - discard-remote + type: string + afterSb1Pri: + description: afterSb1Pri is the recovery action when one side + was Primary. + enum: + - disconnect + - consensus + - violently-as0p + - discard-secondary + - call-pri-lost-after-sb + type: string + afterSb2Pri: + description: |- + afterSb2Pri is the recovery action when both sides were Primary + (only possible if allow-two-primaries was enabled). + enum: + - disconnect + - violently-as0p + - call-pri-lost-after-sb + type: string + allowTwoPrimaries: + description: |- + allowTwoPrimaries enables dual-primary mode (live-migration, + shared-export NFS Ganesha). Must be paired with consumer-side + fencing — DRBD does NOT serialise concurrent writes from two + primaries. + type: boolean + maxBuffers: + description: maxBuffers is the maximum number of in-flight + network buffers. + format: int32 + type: integer + protocol: + description: |- + protocol picks the DRBD replication protocol. A=async (writer + returns once data hits local disk), B=memory-sync (returns on + peer ACK after kernel buffer), C=sync (returns on peer disk + fsync). DRBD-9 default is C. + enum: + - A + - B + - C + type: string + sharedSecretRef: + description: |- + sharedSecretRef references a Secret containing the DRBD network + authentication shared secret under the key `shared-secret`. + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + type: object + x-kubernetes-map-type: atomic + type: object + peerDevice: + description: |- + peerDevice configures the `peer-device { ... }` block (per-peer + resync rate caps and similar). + properties: + cMaxRate: + description: |- + cMaxRate caps the per-peer resync transfer rate. Format + matches DRBD: integer + suffix (`100M`, `1G`). + type: string + type: object + resource: + description: |- + resource configures resource-level `options { ... }` (auto- + promote, quorum mode, on-no-quorum action). + properties: + autoPromote: + description: |- + autoPromote causes DRBD to promote the resource to Primary + automatically when a consumer opens the device, provided no + other peer is already Primary. Cluster-wide default true. + type: boolean + autoTieBreaker: + description: |- + autoTieBreaker gates auto-creation of a DISKLESS+TIE_BREAKER + witness when a parent RD has an even number of diskful + replicas and no operator-placed diskless replica. Replaces + `Props["DrbdOptions/AutoAddQuorumTiebreaker"]`. nil inherits + the cluster-wide default (true). Phase 10.3. + type: boolean + onNoQuorum: + description: |- + onNoQuorum is the action when quorum is lost. `io-error` + returns EIO to the consumer (drbd-reactor's typical trigger + for failover). `suspend-io` blocks I/O until quorum returns + (useful for deliberate maintenance windows). + enum: + - io-error + - suspend-io + - freeze-io + type: string + quorum: + description: |- + quorum picks the quorum policy. `majority` requires more than + half of all replicas (including diskless witnesses) to be + connected before allowing writes. `off` allows writes from any + replica regardless of partition state — split-brain risk. + `all` requires every replica to be reachable, useful only for + strict 2-replica configurations under deliberate operator + control. + enum: + - "off" + - majority + - all + type: string + type: object + type: object + extraProps: + additionalProperties: + type: string + description: |- + extraProps carries upstream-LINSTOR-shaped Props keys we have + not yet typed into structured fields. Forward-compat shim + populated only by the REST shim when golinstor sends an + unknown key. Drained as we type more fields here. + type: object + nodeConnections: + additionalProperties: + additionalProperties: + type: string + type: object + description: |- + nodeConnections is the per-(nodeA,nodeB) property bag exposed + at `/v1/node-connections/{nodeA}/{nodeB}` — backs upstream + LINSTOR's `linstor node-connection set-property / list` CLI + (Bug 101). Keys are the canonical pair-id `::` where + `` and `` are the lexicographically lower / higher of + the two node names — so a write against (A,B) and a read + against (B,A) hit the same record without the caller having + to remember any ordering convention. + + Stored on the cluster-wide ControllerConfig singleton rather + than a per-pair CRD: upstream LINSTOR persists these on a + flat in-memory matrix attached to the Controller, and the + cozystack node-connection use case is overwhelmingly empty + or one-off ("flag this pair as cross-site"). A dedicated CRD + per pair would add admission/RBAC surface for a feature that + in practice carries ≤ a handful of rows on any given cluster. + type: object + passphraseSecretRef: + description: |- + passphraseSecretRef points at the Secret carrying the + cluster-wide LUKS passphrase under the key `passphrase`. The + satellite reads it via the apiserver during reconcile; + passphrase never lands on Spec in plaintext. Replaces + `Props["DrbdOptions/Encryption/passphrase"]` on the legacy + ControllerProps instance. + properties: + name: + description: name is the Secret name. Required. + type: string + required: + - name + type: object + type: object + status: + description: status defines the observed state of ControllerConfig + properties: + conditions: + description: |- + conditions track the current state of the ControllerConfig + (e.g. PassphraseSecretFound, DRBDOptionsValid). + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/packages/system/linstor/definitions/blockstor.cozystack.io_nodes.yaml b/packages/system/linstor/definitions/blockstor.cozystack.io_nodes.yaml new file mode 100644 index 000000000..c94128ed1 --- /dev/null +++ b/packages/system/linstor/definitions/blockstor.cozystack.io_nodes.yaml @@ -0,0 +1,252 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.20.1 + name: nodes.blockstor.cozystack.io +spec: + group: blockstor.cozystack.io + names: + kind: Node + listKind: NodeList + plural: nodes + singular: node + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: Node is the Schema for the nodes API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: spec defines the desired state of Node + properties: + drbdMinorRange: + description: |- + drbdMinorRange is the inclusive [min, max] /dev/drbd minor + range the allocator picks from. Replaces + `Props["DrbdOptions/MinorNrRange"]`. nil inherits the + controller-wide default (20000–65535). Phase 10.3. + properties: + max: + description: max is the upper bound (inclusive). Must be ≥ Min. + format: int32 + minimum: 0 + type: integer + min: + description: min is the lower bound (inclusive). + format: int32 + minimum: 0 + type: integer + required: + - max + - min + type: object + drbdPortRange: + description: |- + drbdPortRange is the inclusive [min, max] TCP port range the + allocator picks DRBD listen ports from for replicas placed on + this node. Replaces `Props["DrbdOptions/TcpPortRange"]`. nil + inherits the controller-wide default (20000–20999). Phase 10.3. + properties: + max: + description: max is the upper bound (inclusive). Must be ≥ Min. + format: int32 + minimum: 0 + type: integer + min: + description: min is the lower bound (inclusive). + format: int32 + minimum: 0 + type: integer + required: + - max + - min + type: object + flags: + description: |- + flags is the desired set of LINSTOR flags. Most node flags are + observed (computed by the satellite); set via spec only those that + are user-controlled. + items: + type: string + type: array + netInterfaces: + description: |- + netInterfaces is the desired list of advertised network interfaces. + The first interface is treated as the satellite endpoint. + items: + description: NodeNetInterface is one advertised endpoint of a satellite. + properties: + address: + description: address is the IP address of the endpoint. + type: string + name: + description: name is the user-facing identifier ("default", + "drbd-net", etc.). + type: string + satelliteEncryptionType: + description: satelliteEncryptionType is "PLAIN" or "SSL". + enum: + - PLAIN + - SSL + type: string + satellitePort: + description: satellitePort is the port the satellite listens + on; 0 means default. + format: int32 + type: integer + required: + - address + - name + type: object + type: array + props: + additionalProperties: + type: string + description: |- + props is the LINSTOR property map for this node. Keys are LINSTOR + namespace paths (e.g. `Aux/foo`, `DrbdOptions/Net/...`). + type: object + satelliteEndpoint: + description: |- + satelliteEndpoint is the controller→satellite gRPC endpoint + (`host:port`). Phase 10.3: replaces `Props["SatelliteEndpoint"]` + — the dispatcher reads this typed field first, falling back to + the props bag for forward-compat with pre-migration data. The + field becomes irrelevant once Phase 10.6 lands and the gRPC + path is gone. + type: string + type: + description: |- + type is the LINSTOR node role. Common values: SATELLITE, COMBINED, + CONTROLLER, AUXILIARY. + enum: + - CONTROLLER + - SATELLITE + - COMBINED + - AUXILIARY + - REMOTE_SPDK + - OPENFLEX_TARGET + - EBS_TARGET + - EBS_INIT + type: string + required: + - type + type: object + status: + description: status defines the observed state of Node + properties: + conditions: + description: |- + conditions represents the current state of the Node resource. + The well-known `Ready` condition (status=True when the satellite + is healthy, Unknown when its heartbeat is stale, False when the + satellite reports a fatal state) is what consumers should look + at. Other conditions may follow as we surface more invariants. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + connectionStatus: + description: |- + connectionStatus is a coarse projection of the Ready condition + (ONLINE when Ready=True, OFFLINE when False/Unknown) kept for + kubectl-friendly columns + golinstor round-trip compatibility. + Written by the controller-side heartbeat watchdog; do not hand-set. + type: string + flags: + description: flags computed by the satellite (e.g. EVICTED, EVACUATING). + items: + type: string + type: array + lastHeartbeatTime: + description: |- + lastHeartbeatTime is when this node's satellite last stamped the + status (kubelet-style liveness). The controller-side watchdog + flips the Ready condition to Unknown when this is older than the + node-monitor grace period. Updated on every satellite reconcile + tick regardless of state changes — the "did we hear from this + satellite recently?" signal. + format: date-time + type: string + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/packages/system/linstor/definitions/blockstor.cozystack.io_physicaldevices.yaml b/packages/system/linstor/definitions/blockstor.cozystack.io_physicaldevices.yaml new file mode 100644 index 000000000..3dfcef46e --- /dev/null +++ b/packages/system/linstor/definitions/blockstor.cozystack.io_physicaldevices.yaml @@ -0,0 +1,229 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.20.1 + name: physicaldevices.blockstor.cozystack.io +spec: + group: blockstor.cozystack.io + names: + kind: PhysicalDevice + listKind: PhysicalDeviceList + plural: physicaldevices + singular: physicaldevice + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: |- + PhysicalDevice is one raw block device discovered on a satellite. + Phase 10.7 — replaces the upstream `linstor physical-storage` + PropsContainers / gRPC pattern. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: spec defines the desired state of PhysicalDevice + properties: + attachTo: + description: |- + attachTo is the controller-side request that this device be + added to the named pool. Empty/nil means "available". Phase + 10.7 step 2 wires the REST endpoint that flips this; until + then operators can edit the CRD directly. + properties: + directory: + description: |- + directory is the mount-point where a FILE / FILE_THIN + pool's backing files live. The satellite formats + mounts + the device on this path before flipping the pool to + available. + type: string + providerKind: + description: |- + providerKind picks the storage backend ("LVM", "LVM_THIN", + "ZFS", "ZFS_THIN", "FILE", "FILE_THIN"). + enum: + - LVM + - LVM_THIN + - ZFS + - ZFS_THIN + - FILE + - FILE_THIN + type: string + storagePoolName: + description: |- + storagePoolName is the target pool name (matches the + upstream LINSTOR pool name a Resource refers to). + type: string + thinPoolName: + description: |- + thinPoolName is the LVM thin pool to create on top of VG + (LVM_THIN only). Ignored otherwise. + type: string + vgName: + description: |- + vgName is the LVM volume group to create (LVM / LVM_THIN + kinds). Ignored otherwise. + type: string + wipe: + description: |- + wipe is the explicit consent flag the operator must set to + `true` to allow the satellite to overwrite existing on-disk + signatures (LVM/ZFS/MD/filesystems). Without it the attach + fails with `Status.Phase=Failed` rather than risk data loss. + type: boolean + zPoolName: + description: |- + zPoolName is the ZFS zpool to create (ZFS / ZFS_THIN + kinds). Ignored otherwise. + type: string + required: + - providerKind + - storagePoolName + type: object + type: object + status: + description: status defines the observed state of PhysicalDevice + properties: + conditions: + description: |- + conditions carry detailed state (e.g. `WipeRequired` when + the device has on-disk signatures and `Spec.AttachTo.Wipe` + is false). + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + currentDevPath: + description: |- + currentDevPath is the volatile `/dev/sdN` or `/dev/nvmeNnN` + path from the most recent discovery tick. Refreshed on + every discovery — operators MUST NOT rely on this being + stable across reboots. + type: string + devicePath: + description: |- + devicePath is the canonical /dev/disk/by-id symlink the + satellite uses internally. Stable across reboots (unless the + device is physically replaced). + type: string + model: + description: model carries the manufacturer model string (lsblk MODEL). + type: string + nodeName: + description: nodeName is the satellite that owns this device. + type: string + phase: + description: phase is the discovery + attach state. + enum: + - Available + - Attaching + - Failed + type: string + rotational: + description: |- + rotational reflects the kernel's view of the spindle — + false for SSD/NVMe, true for HDD. Used by the autoplacer + to bias placement when ResourceGroup says so. + type: boolean + serial: + description: |- + serial carries the device serial number when reported by + the firmware. Some virtualised setups (virtio without + serial passthrough) leave this empty. + type: string + sizeBytes: + description: sizeBytes is the device size as reported by `lsblk -o + SIZE`. + format: int64 + type: integer + stableID: + description: |- + stableID is the stable identifier the satellite picked from + `/dev/disk/by-id/...` (preferring `wwn-*` → `scsi-SATA_*` + → `nvme-*` → `by-path/*`). The CRD's metadata.name is + derived from this so it survives `/dev/sdN` re-lettering. + type: string + transport: + description: transport is the bus type ("sata", "nvme", "scsi", "virtio"). + type: string + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/packages/system/linstor/definitions/blockstor.cozystack.io_resourcedefinitions.yaml b/packages/system/linstor/definitions/blockstor.cozystack.io_resourcedefinitions.yaml new file mode 100644 index 000000000..08e2b98d8 --- /dev/null +++ b/packages/system/linstor/definitions/blockstor.cozystack.io_resourcedefinitions.yaml @@ -0,0 +1,499 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.20.1 + name: resourcedefinitions.blockstor.cozystack.io +spec: + group: blockstor.cozystack.io + names: + kind: ResourceDefinition + listKind: ResourceDefinitionList + plural: resourcedefinitions + singular: resourcedefinition + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: ResourceDefinition is the Schema for the resourcedefinitions + API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: spec defines the desired state of ResourceDefinition + properties: + drbdOptions: + description: |- + drbdOptions is the typed DRBD configuration applied to this + RD. Overrides the parent ResourceGroup's drbdOptions + field-by-field; in turn overridden by per-Resource drbdOptions + at the Resource scope. Phase 10.3. + properties: + disk: + description: |- + disk configures the `disk { ... }` section (on-io-error, + activity-log size, resync hints). + properties: + alExtents: + description: |- + alExtents is the activity-log size (in extents). Larger values + reduce metadata write amplification at the cost of longer + resync windows. + format: int32 + type: integer + onIoError: + description: |- + onIOError is the action when the local backing device returns + an I/O error. `detach` is the production-safe default — the + satellite drops the local replica to Diskless and consumers + keep going via the network path. + enum: + - detach + - pass-on + - call-local-io-error + type: string + type: object + handlers: + additionalProperties: + type: string + description: |- + handlers maps event names to script paths (e.g. fence-peer, + before-resync-target). Free-form for now; the rendered .res + emits one line per pair under `handlers { }`. + type: object + net: + description: |- + net configures the `net { ... }` section of the rendered .res + file (replication protocol, secret, dual-primary, after-sb). + properties: + afterSb0Pri: + description: |- + afterSb0Pri is the recovery action when DRBD detects split- + brain and both sides were Secondary at the time. + enum: + - disconnect + - discard-younger-primary + - discard-older-primary + - discard-zero-changes + - discard-least-changes + - discard-local + - discard-remote + type: string + afterSb1Pri: + description: afterSb1Pri is the recovery action when one side + was Primary. + enum: + - disconnect + - consensus + - violently-as0p + - discard-secondary + - call-pri-lost-after-sb + type: string + afterSb2Pri: + description: |- + afterSb2Pri is the recovery action when both sides were Primary + (only possible if allow-two-primaries was enabled). + enum: + - disconnect + - violently-as0p + - call-pri-lost-after-sb + type: string + allowTwoPrimaries: + description: |- + allowTwoPrimaries enables dual-primary mode (live-migration, + shared-export NFS Ganesha). Must be paired with consumer-side + fencing — DRBD does NOT serialise concurrent writes from two + primaries. + type: boolean + maxBuffers: + description: maxBuffers is the maximum number of in-flight + network buffers. + format: int32 + type: integer + protocol: + description: |- + protocol picks the DRBD replication protocol. A=async (writer + returns once data hits local disk), B=memory-sync (returns on + peer ACK after kernel buffer), C=sync (returns on peer disk + fsync). DRBD-9 default is C. + enum: + - A + - B + - C + type: string + sharedSecretRef: + description: |- + sharedSecretRef references a Secret containing the DRBD network + authentication shared secret under the key `shared-secret`. + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + type: object + x-kubernetes-map-type: atomic + type: object + peerDevice: + description: |- + peerDevice configures the `peer-device { ... }` block (per-peer + resync rate caps and similar). + properties: + cMaxRate: + description: |- + cMaxRate caps the per-peer resync transfer rate. Format + matches DRBD: integer + suffix (`100M`, `1G`). + type: string + type: object + resource: + description: |- + resource configures resource-level `options { ... }` (auto- + promote, quorum mode, on-no-quorum action). + properties: + autoPromote: + description: |- + autoPromote causes DRBD to promote the resource to Primary + automatically when a consumer opens the device, provided no + other peer is already Primary. Cluster-wide default true. + type: boolean + autoTieBreaker: + description: |- + autoTieBreaker gates auto-creation of a DISKLESS+TIE_BREAKER + witness when a parent RD has an even number of diskful + replicas and no operator-placed diskless replica. Replaces + `Props["DrbdOptions/AutoAddQuorumTiebreaker"]`. nil inherits + the cluster-wide default (true). Phase 10.3. + type: boolean + onNoQuorum: + description: |- + onNoQuorum is the action when quorum is lost. `io-error` + returns EIO to the consumer (drbd-reactor's typical trigger + for failover). `suspend-io` blocks I/O until quorum returns + (useful for deliberate maintenance windows). + enum: + - io-error + - suspend-io + - freeze-io + type: string + quorum: + description: |- + quorum picks the quorum policy. `majority` requires more than + half of all replicas (including diskless witnesses) to be + connected before allowing writes. `off` allows writes from any + replica regardless of partition state — split-brain risk. + `all` requires every replica to be reachable, useful only for + strict 2-replica configurations under deliberate operator + control. + enum: + - "off" + - majority + - all + type: string + type: object + type: object + drbdPort: + description: |- + drbdPort is an OPTIONAL preferred TCP port seed for this RD, + mirroring upstream LINSTOR's `RscDfn.port` preferred value. The + per-node port allocator (Resource.Spec.DRBDPort) tries this + value first on each hosting node and falls back to a per-node + free port on collision. nil means "no preference — allocate + per-node freely". This is a seed, NOT the authoritative + listen-port: the authoritative per-replica value lives on + Resource.Spec.DRBDPort. clusterIP-style settable-once so an + accidental edit can't perturb the per-node allocation. + format: int32 + type: integer + x-kubernetes-validations: + - message: drbdPort is settable-once + optionalOldSelf: true + rule: '!oldSelf.hasValue() || self == oldSelf.value()' + encryption: + description: |- + encryption configures LUKS encryption for the volumes in this + RD. The passphrase is held in a referenced Secret rather than + inline in the spec. Phase 10.3. + properties: + passphraseSecretRef: + description: |- + passphraseSecretRef references the Secret carrying the LUKS + passphrase under the key `passphrase`. The satellite reads it + via the apiserver during reconcile; the passphrase never lands + on Spec in plaintext. + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + type: object + x-kubernetes-map-type: atomic + type: object + externalName: + description: |- + externalName is the user-facing name surfaced by csi (CSI volume id). + Empty means the same as metadata.name. + type: string + extraProps: + additionalProperties: + type: string + description: |- + extraProps carries upstream-LINSTOR property keys we have not + yet typed into structured fields. Forward-compat shim populated + only by the REST shim when golinstor sends an unknown key. + Phase 10.3. + type: object + flags: + description: flags carries user-controlled RD flags (DELETE, INACTIVE, + ...). + items: + type: string + type: array + initialized: + description: |- + initialized is the durable "this RD has completed its initial + replica-set establishment and now holds (or has held) committed + data" latch. The controller flips it true ONCE, append-only, the + first time any diskful replica of the RD reports a real + data-bearing disk state that has advanced past the deterministic + day0 GI (a genuine write, or an adoption of pre-existing data) — + see ResourceReconciler.ensureRDInitialized. Once true it is NEVER + cleared or mutated. + + It is the OFFLINE-SAFE, BACKUP-SAFE source of truth for the + skip-initial-sync decision (replaces the live-kernel + AnyConnectedPeerHasData probe as the authoritative signal): + + - A Resource created while initialized is nil/false is part of + the genuinely-fresh initial set — every such replica is + stamped Spec.SkipInitialSync=true and skips the initial sync + (instant UpToDate, no SyncTarget). Invariant 1. + - A Resource created AFTER initialized latched true (relocate / + migrate-disk / extra replica) is stamped + Spec.SkipInitialSync=false and must SyncTarget the real data — + EVEN IF the sole data-holder is offline at seed time, because + this latch was set while the data was being written (holder + online) and PERSISTS in Spec across the holder going offline. + Invariant 2 + offline-safety. + + Lives in Spec (backed up by `kubectl get -o yaml`, restored by + `kubectl apply`), NOT Status — a restored, already-initialized RD + must keep forcing new replicas to sync rather than skip. Invariant + 3 (backup/restore-safe). + + clusterIP-style append-only: nil means "not yet initialized" (the + conservative pre-upgrade / fresh default → fresh replicas may skip, + the controller flips it on first real data). The controller writes + it only when transitioning nil/false→true and never otherwise, so + a user `kubectl apply` / golinstor REST that omits it never fights + the controller (3-way-merge-safe — invariant 4). + type: boolean + x-kubernetes-validations: + - message: 'initialized is append-only: it may go unset→value or false→true + but never back to false' + optionalOldSelf: true + rule: '!oldSelf.hasValue() || self == oldSelf.value() || (oldSelf.value() + == false && self == true)' + layerStack: + description: |- + layerStack is the LINSTOR layer composition for this RD's + satellite-side render — `["DRBD","STORAGE"]` (default) renders a + .res file and runs drbdadm; `["LUKS","STORAGE"]` layers + cryptsetup over the storage device with no DRBD; `["STORAGE"]` + is single-replica local mode (no replication, no encryption). + Order is top-down: the first layer's device is what the + consumer Pod mounts, the last is the raw block device the + storage provider creates. + Empty = inherits from the parent ResourceGroup; both empty = + `["DRBD","STORAGE"]`. + items: + type: string + type: array + props: + additionalProperties: + type: string + description: props is the LINSTOR property map. + type: object + resourceGroupName: + description: |- + resourceGroupName references the ResourceGroup template this RD was + spawned from (or empty if directly created). + type: string + volumeDefinitions: + description: volumeDefinitions are the volume slots inside this RD. + items: + description: ResourceDefinitionVolume is one volume slot inside + an RD. + properties: + drbdMinor: + description: |- + drbdMinor is the /dev/drbd device minor for THIS volume, + identical on every node that hosts a replica (the minor is the + device identity, not a per-replica value). Mirrors upstream + LINSTOR's per-volume-definition `VLM_MINOR_NR`. + + clusterIP-style allocation (Service.spec.clusterIP model): nil + means "controller, allocate one for me"; a non-nil value is + authoritative and is NEVER overwritten — that is what makes a + plain `kubectl get -o yaml` backup + `kubectl apply` restore + preserve the device identity with no resync/flap. The pointer + (rather than a plain int32) distinguishes "unset" from a valid + minor 0. + + Replaces the legacy single `RD.Status.DRBDMinor` base + + `base+volumeNumber` derivation: each volume carries its own + minor, so adoption can preserve arbitrary (possibly + non-contiguous) LINSTOR per-volume minors verbatim. + + NOTE: no CEL settable-once rule here. volumeDefinitions is a + plain (uncorrelatable) array — CEL `oldSelf` cannot track an + element across an update, so a transition rule on a nested + array field is rejected by the apiserver. Immutability is + instead enforced by the controller's allocate-if-nil / + respect-preset pass (it NEVER overwrites a non-nil minor) plus + the store-side VolumeDefinitions carry-across that preserves the + value through a REST modify. The settable-once CEL is retained + on the (correlatable scalar) Resource.Spec.DRBDPort / DRBDNodeID + and RD.Spec.DRBDPort fields. + format: int32 + type: integer + flags: + items: + type: string + type: array + props: + additionalProperties: + type: string + type: object + sizeKib: + format: int64 + type: integer + volumeNumber: + format: int32 + type: integer + required: + - sizeKib + - volumeNumber + type: object + type: array + type: object + status: + description: status defines the observed state of ResourceDefinition + properties: + conditions: + description: conditions represent the current state of the ResourceDefinition. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + drbdMinor: + description: |- + drbdMinor is a LEGACY read-only mirror of the (historically + cluster-scope, base+k) DRBD minor. DEPRECATED: the authoritative + per-volume minor now lives on + ResourceDefinition.Spec.VolumeDefinitions[].DRBDMinor. Retained + so the one-time status→spec backfill migration can read the + pre-upgrade base value (expanded base+k per volume). Not written + by the allocator any more. Bug 268. + format: int32 + type: integer + drbdPort: + description: |- + drbdPort is a LEGACY read-only mirror of the (historically + cluster-scope) DRBD port. DEPRECATED: the authoritative DRBD + listen-port now lives per-replica on Resource.Spec.DRBDPort, + and the optional preferred seed on RD.Spec.DRBDPort. Retained + so the one-time status→spec backfill migration can read the + pre-upgrade value, and so observers/REST that still read it + don't break in the same change. Not written by the allocator + any more. Bug 266. + format: int32 + type: integer + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/packages/system/linstor/definitions/blockstor.cozystack.io_resourcegroups.yaml b/packages/system/linstor/definitions/blockstor.cozystack.io_resourcegroups.yaml new file mode 100644 index 000000000..8515b5aef --- /dev/null +++ b/packages/system/linstor/definitions/blockstor.cozystack.io_resourcegroups.yaml @@ -0,0 +1,377 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.20.1 + name: resourcegroups.blockstor.cozystack.io +spec: + group: blockstor.cozystack.io + names: + kind: ResourceGroup + listKind: ResourceGroupList + plural: resourcegroups + singular: resourcegroup + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: ResourceGroup is the Schema for the resourcegroups API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: spec defines the desired state of ResourceGroup + properties: + description: + description: description is human-readable. + type: string + drbdOptions: + description: |- + drbdOptions is the typed DRBD configuration applied to every + ResourceDefinition spawned from this ResourceGroup. Lower scope + (RD, Resource) overrides this field-by-field. Phase 10.3. + properties: + disk: + description: |- + disk configures the `disk { ... }` section (on-io-error, + activity-log size, resync hints). + properties: + alExtents: + description: |- + alExtents is the activity-log size (in extents). Larger values + reduce metadata write amplification at the cost of longer + resync windows. + format: int32 + type: integer + onIoError: + description: |- + onIOError is the action when the local backing device returns + an I/O error. `detach` is the production-safe default — the + satellite drops the local replica to Diskless and consumers + keep going via the network path. + enum: + - detach + - pass-on + - call-local-io-error + type: string + type: object + handlers: + additionalProperties: + type: string + description: |- + handlers maps event names to script paths (e.g. fence-peer, + before-resync-target). Free-form for now; the rendered .res + emits one line per pair under `handlers { }`. + type: object + net: + description: |- + net configures the `net { ... }` section of the rendered .res + file (replication protocol, secret, dual-primary, after-sb). + properties: + afterSb0Pri: + description: |- + afterSb0Pri is the recovery action when DRBD detects split- + brain and both sides were Secondary at the time. + enum: + - disconnect + - discard-younger-primary + - discard-older-primary + - discard-zero-changes + - discard-least-changes + - discard-local + - discard-remote + type: string + afterSb1Pri: + description: afterSb1Pri is the recovery action when one side + was Primary. + enum: + - disconnect + - consensus + - violently-as0p + - discard-secondary + - call-pri-lost-after-sb + type: string + afterSb2Pri: + description: |- + afterSb2Pri is the recovery action when both sides were Primary + (only possible if allow-two-primaries was enabled). + enum: + - disconnect + - violently-as0p + - call-pri-lost-after-sb + type: string + allowTwoPrimaries: + description: |- + allowTwoPrimaries enables dual-primary mode (live-migration, + shared-export NFS Ganesha). Must be paired with consumer-side + fencing — DRBD does NOT serialise concurrent writes from two + primaries. + type: boolean + maxBuffers: + description: maxBuffers is the maximum number of in-flight + network buffers. + format: int32 + type: integer + protocol: + description: |- + protocol picks the DRBD replication protocol. A=async (writer + returns once data hits local disk), B=memory-sync (returns on + peer ACK after kernel buffer), C=sync (returns on peer disk + fsync). DRBD-9 default is C. + enum: + - A + - B + - C + type: string + sharedSecretRef: + description: |- + sharedSecretRef references a Secret containing the DRBD network + authentication shared secret under the key `shared-secret`. + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + type: object + x-kubernetes-map-type: atomic + type: object + peerDevice: + description: |- + peerDevice configures the `peer-device { ... }` block (per-peer + resync rate caps and similar). + properties: + cMaxRate: + description: |- + cMaxRate caps the per-peer resync transfer rate. Format + matches DRBD: integer + suffix (`100M`, `1G`). + type: string + type: object + resource: + description: |- + resource configures resource-level `options { ... }` (auto- + promote, quorum mode, on-no-quorum action). + properties: + autoPromote: + description: |- + autoPromote causes DRBD to promote the resource to Primary + automatically when a consumer opens the device, provided no + other peer is already Primary. Cluster-wide default true. + type: boolean + autoTieBreaker: + description: |- + autoTieBreaker gates auto-creation of a DISKLESS+TIE_BREAKER + witness when a parent RD has an even number of diskful + replicas and no operator-placed diskless replica. Replaces + `Props["DrbdOptions/AutoAddQuorumTiebreaker"]`. nil inherits + the cluster-wide default (true). Phase 10.3. + type: boolean + onNoQuorum: + description: |- + onNoQuorum is the action when quorum is lost. `io-error` + returns EIO to the consumer (drbd-reactor's typical trigger + for failover). `suspend-io` blocks I/O until quorum returns + (useful for deliberate maintenance windows). + enum: + - io-error + - suspend-io + - freeze-io + type: string + quorum: + description: |- + quorum picks the quorum policy. `majority` requires more than + half of all replicas (including diskless witnesses) to be + connected before allowing writes. `off` allows writes from any + replica regardless of partition state — split-brain risk. + `all` requires every replica to be reachable, useful only for + strict 2-replica configurations under deliberate operator + control. + enum: + - "off" + - majority + - all + type: string + type: object + type: object + extraProps: + additionalProperties: + type: string + description: |- + extraProps carries upstream-LINSTOR property keys we have not + yet typed into structured fields. Populated only by the REST + compatibility shim when golinstor sends a key we don't + recognise. Operators editing via kubectl should prefer the + typed fields above. Phase 10.3. + type: object + peerSlots: + description: peerSlots is the DRBD peer-slot count baked into spawned + resources. + format: int32 + type: integer + props: + additionalProperties: + type: string + description: props is the LINSTOR property map for this resource group. + type: object + selectFilter: + description: |- + selectFilter constrains autoplacer when spawning resources from this + group. + properties: + disklessOnRemaining: + type: boolean + layerStack: + items: + type: string + type: array + nodeNameList: + items: + type: string + type: array + notPlaceWithRsc: + items: + type: string + type: array + notPlaceWithRscRegex: + type: string + placeCount: + format: int32 + type: integer + providerList: + items: + type: string + type: array + replicasOnDifferent: + items: + type: string + type: array + replicasOnSame: + items: + type: string + type: array + storagePool: + type: string + storagePoolDisklessList: + items: + type: string + type: array + storagePoolList: + items: + type: string + type: array + type: object + volumeGroups: + description: volumeGroups templates the per-volume props/flags for + spawned resources. + items: + description: ResourceGroupVolumeGroup is one volume's template inside + a ResourceGroup. + properties: + flags: + items: + type: string + type: array + props: + additionalProperties: + type: string + type: object + volumeNumber: + format: int32 + type: integer + required: + - volumeNumber + type: object + type: array + type: object + status: + description: status defines the observed state of ResourceGroup + properties: + conditions: + description: conditions represent the current state of the ResourceGroup. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/packages/system/linstor/definitions/blockstor.cozystack.io_resources.yaml b/packages/system/linstor/definitions/blockstor.cozystack.io_resources.yaml new file mode 100644 index 000000000..a360db9f3 --- /dev/null +++ b/packages/system/linstor/definitions/blockstor.cozystack.io_resources.yaml @@ -0,0 +1,762 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.20.1 + name: resources.blockstor.cozystack.io +spec: + group: blockstor.cozystack.io + names: + kind: Resource + listKind: ResourceList + plural: resources + singular: resource + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: |- + Resource is the Schema for the resources API. + + The CEL rule above enforces the cluster-wide naming convention every + node-bound CRD in the project follows: `metadata.name == .`. + Keeping the composite key encoded in the name lets operators grep for + `.` across kinds (Resource, Snapshot, StoragePool) and find every + resource bound to one satellite at once. + + BUG-047: the comparison is case-INSENSITIVE (.lowerAscii() on both + sides), mirroring StoragePool. LINSTOR identifiers are case-insensitive + and the k8s store's Name() helper lowercases metadata.name, while + spec.resourceDefinitionName preserves the caller's original case. With + an uppercase RD name (e.g. csi-sanity's `…BA880D4F…`) a case-SENSITIVE + rule rejected the Resource create with "must equal" even though the + names address the same object. lowerAscii() on both sides keeps the + `.` convention intact while tolerating case differences. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: spec defines the desired state of Resource + properties: + drbdNodeID: + description: |- + drbdNodeID is the DRBD-9 node-id assigned to this replica. + Per-replica, allocated once and stable for the replica's life — + re-numbering a live replica re-maps its DRBD bitmaps and + corrupts peer-to-peer resync. Range 0..15 (drbd-9 max-peers). + + clusterIP-style allocation: nil means "controller, allocate"; + non-nil is authoritative and NEVER overwritten (restore-safe). + Pointer distinguishes "unset" from a valid node-id 0 + (LowestFreeNodeID hands out 0 for the first/freed slot). + format: int32 + type: integer + x-kubernetes-validations: + - message: 'drbdNodeID is settable-once: it may go from unset to a + value but not be changed once set' + optionalOldSelf: true + rule: '!oldSelf.hasValue() || self == oldSelf.value()' + drbdOptions: + description: |- + drbdOptions is the typed DRBD configuration applied to this + specific replica. Overrides the parent RD's drbdOptions + field-by-field. Rare — most config lives at RD or RG scope. + Phase 10.3. + properties: + disk: + description: |- + disk configures the `disk { ... }` section (on-io-error, + activity-log size, resync hints). + properties: + alExtents: + description: |- + alExtents is the activity-log size (in extents). Larger values + reduce metadata write amplification at the cost of longer + resync windows. + format: int32 + type: integer + onIoError: + description: |- + onIOError is the action when the local backing device returns + an I/O error. `detach` is the production-safe default — the + satellite drops the local replica to Diskless and consumers + keep going via the network path. + enum: + - detach + - pass-on + - call-local-io-error + type: string + type: object + handlers: + additionalProperties: + type: string + description: |- + handlers maps event names to script paths (e.g. fence-peer, + before-resync-target). Free-form for now; the rendered .res + emits one line per pair under `handlers { }`. + type: object + net: + description: |- + net configures the `net { ... }` section of the rendered .res + file (replication protocol, secret, dual-primary, after-sb). + properties: + afterSb0Pri: + description: |- + afterSb0Pri is the recovery action when DRBD detects split- + brain and both sides were Secondary at the time. + enum: + - disconnect + - discard-younger-primary + - discard-older-primary + - discard-zero-changes + - discard-least-changes + - discard-local + - discard-remote + type: string + afterSb1Pri: + description: afterSb1Pri is the recovery action when one side + was Primary. + enum: + - disconnect + - consensus + - violently-as0p + - discard-secondary + - call-pri-lost-after-sb + type: string + afterSb2Pri: + description: |- + afterSb2Pri is the recovery action when both sides were Primary + (only possible if allow-two-primaries was enabled). + enum: + - disconnect + - violently-as0p + - call-pri-lost-after-sb + type: string + allowTwoPrimaries: + description: |- + allowTwoPrimaries enables dual-primary mode (live-migration, + shared-export NFS Ganesha). Must be paired with consumer-side + fencing — DRBD does NOT serialise concurrent writes from two + primaries. + type: boolean + maxBuffers: + description: maxBuffers is the maximum number of in-flight + network buffers. + format: int32 + type: integer + protocol: + description: |- + protocol picks the DRBD replication protocol. A=async (writer + returns once data hits local disk), B=memory-sync (returns on + peer ACK after kernel buffer), C=sync (returns on peer disk + fsync). DRBD-9 default is C. + enum: + - A + - B + - C + type: string + sharedSecretRef: + description: |- + sharedSecretRef references a Secret containing the DRBD network + authentication shared secret under the key `shared-secret`. + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + type: object + x-kubernetes-map-type: atomic + type: object + peerDevice: + description: |- + peerDevice configures the `peer-device { ... }` block (per-peer + resync rate caps and similar). + properties: + cMaxRate: + description: |- + cMaxRate caps the per-peer resync transfer rate. Format + matches DRBD: integer + suffix (`100M`, `1G`). + type: string + type: object + resource: + description: |- + resource configures resource-level `options { ... }` (auto- + promote, quorum mode, on-no-quorum action). + properties: + autoPromote: + description: |- + autoPromote causes DRBD to promote the resource to Primary + automatically when a consumer opens the device, provided no + other peer is already Primary. Cluster-wide default true. + type: boolean + autoTieBreaker: + description: |- + autoTieBreaker gates auto-creation of a DISKLESS+TIE_BREAKER + witness when a parent RD has an even number of diskful + replicas and no operator-placed diskless replica. Replaces + `Props["DrbdOptions/AutoAddQuorumTiebreaker"]`. nil inherits + the cluster-wide default (true). Phase 10.3. + type: boolean + onNoQuorum: + description: |- + onNoQuorum is the action when quorum is lost. `io-error` + returns EIO to the consumer (drbd-reactor's typical trigger + for failover). `suspend-io` blocks I/O until quorum returns + (useful for deliberate maintenance windows). + enum: + - io-error + - suspend-io + - freeze-io + type: string + quorum: + description: |- + quorum picks the quorum policy. `majority` requires more than + half of all replicas (including diskless witnesses) to be + connected before allowing writes. `off` allows writes from any + replica regardless of partition state — split-brain risk. + `all` requires every replica to be reachable, useful only for + strict 2-replica configurations under deliberate operator + control. + enum: + - "off" + - majority + - all + type: string + type: object + type: object + drbdPort: + description: |- + drbdPort is the TCP port THIS replica listens on for the RD's + DRBD replication mesh. PER-NODE (per-replica): the allocator's + taken-set is the ports already used by OTHER Resources ON THE + SAME NODE, so the same port number is freely reused across + different nodes — this scales to 1000+ resources per node + instead of exhausting a cluster-unique 20000-20999 window at + ~1000 resources cluster-wide. The optional RD.Spec.DRBDPort + preferred seed is tried first on each node. + + clusterIP-style allocation (Service.spec.clusterIP model): nil + means "controller, allocate one for me"; non-nil is + authoritative and is NEVER overwritten — that is what makes a + `kubectl get -o yaml` backup + `kubectl apply` restore preserve + the port with no flap. The pointer distinguishes "unset" from a + valid port 0 (never allocated, but kept for type symmetry). The + .res renderer puts each peer's own Spec.DRBDPort into that + peer's `on ` block. + format: int32 + type: integer + x-kubernetes-validations: + - message: 'drbdPort is settable-once: it may go from unset to a value + but not be changed once set' + optionalOldSelf: true + rule: '!oldSelf.hasValue() || self == oldSelf.value()' + extraProps: + additionalProperties: + type: string + description: |- + extraProps carries upstream-LINSTOR property keys we have not + yet typed into structured fields. Forward-compat shim populated + only by the REST shim when golinstor sends an unknown key. + Phase 10.3. + type: object + flags: + description: flags carries the user-controlled placement flags. + items: + type: string + type: array + nodeName: + description: nodeName is the satellite hosting this replica. + type: string + props: + additionalProperties: + type: string + description: props is the LINSTOR per-resource property map. + type: object + resourceDefinitionName: + description: resourceDefinitionName is the parent ResourceDefinition. + type: string + skipInitialSync: + description: |- + skipInitialSync is the controller-authoritative, persisted decision + of whether THIS replica may skip the DRBD initial sync (come up + instantly UpToDate via the day0 `set-gi` seed) or MUST run a real + SyncTarget from a data-bearing peer. Stamped ONCE at first reconcile + (append-only, set-if-nil, never mutated) as + `!ResourceDefinition.Spec.Initialized`: + + - true → the replica was created while its RD was still a + genuinely-fresh, never-written initial set (RD.Spec.Initialized + nil/false). It is safe to seed the day0 skip → instant UpToDate, + out_of_sync=0, no SyncTarget. The whole initial replica set is + stamped true together, so a fresh 2-/3-replica deployment skips + in lock-step (invariant 1). + - false → the replica joined an RD that had ALREADY held committed + data (RD.Spec.Initialized==true): relocate, migrate-disk, or an + extra replica. It MUST NOT skip — it comes up Inconsistent and + SyncTargets the real data from a peer (invariant 2). This holds + EVEN IF the sole data-holder is offline at seed time, because + the decision is read from the persisted RD latch, NOT from live + kernel/peer state (offline-safety + the core fix). + + This REPLACES the satellite's live-kernel AnyConnectedPeerHasData + probe as the authoritative skip decision (that probe is unsafe: it + only sees CONNECTED peers, so an offline data-holder made a fresh + replica skip → falsely UpToDate while EMPTY). The probe is retained + only as a defense-in-depth secondary veto. + + clusterIP-style: nil means "controller, decide and stamp me" + (conservative pre-upgrade / pre-stamp default in resolveVolumeSeed: + do NOT skip — full sync, invariant 5). A non-nil value is + authoritative and NEVER overwritten — restore-safe (invariant 3) + and 3-way-merge-safe (the user never sets it → it is never in their + last-applied → `kubectl apply` / golinstor REST that omit it never + strip it; invariant 4). + type: boolean + x-kubernetes-validations: + - message: 'skipInitialSync is settable-once: it may go from unset + to a value but not be changed once set' + optionalOldSelf: true + rule: '!oldSelf.hasValue() || self == oldSelf.value()' + storagePool: + description: |- + storagePool is the LINSTOR storage pool name this replica + allocates from. Replaces `Spec.Props["StorPoolName"]` (which + the dispatcher's buildVolumes already prefers when set). + Phase 10.3 step. + type: string + toggleDiskCancel: + description: |- + toggleDiskCancel asks the satellite reconciler to abort an + in-flight diskless→diskful conversion and roll back to the + pre-toggle Diskless state. Set by the REST shim when the + operator passes `?cancel=true` to PUT toggle-disk (upstream + LINSTOR's `linstor r td --cancel` shape). Bug 40. + + The reconciler observes this flag in conjunction with a + "partial diskful" state (storage carved, DRBD not yet Up or + not yet UpToDate) and unwinds by: + + 1. drbdadm down (idempotent if the kernel resource is + already gone), + 2. DeleteVolume on the storage provider, + 3. re-stamping the DISKLESS flag on Spec.Flags, + 4. clearing this flag and Status.ToggleDiskRetries. + + Once cleared the satellite resumes normal reconcile loops + against the (now diskless) Spec. A cancel issued against a + Resource that's already past the partial-state window (DRBD + is Up and Volumes report UpToDate) is a no-op — the operator + must issue a fresh toggle-disk to demote. + type: boolean + volumes: + description: |- + volumes carries per-volume seed configuration that the + satellite applies once on first activation of this replica. + Today the only field is SeedFromGI (Phase 8.1) — when set, + the satellite stamps the new replica's DRBD metadata with + this generation identifier before `drbdadm up` so the GI + handshake sees the new device as already-in-sync with that + peer, skipping the full initial-sync. + items: + description: |- + ResourceVolumeSpec is one volume's per-replica configuration knobs. + Distinct from ResourceVolumeStatus: this carries one-shot seeding + hints the satellite consumes during first activation, the Status + counterpart carries observed runtime state. + properties: + seedFromGI: + description: |- + seedFromGI pre-seeds the DRBD-9 generation identifier of this + replica's metadata block before the first `drbdadm up`. When + set to the CurrentGI of an existing UpToDate peer, DRBD's GI + handshake on first connect sees the match and skips the full + initial-sync — turning hours of resync on multi-TiB volumes + into instant. Phase 8.1. + + Consumed once on first activation; subsequent reconciles + ignore it (the satellite checks `drbdmeta show-gi` before + re-stamping). + type: string + volumeNumber: + description: |- + volumeNumber matches the corresponding ResourceDefinition + VolumeDefinition. +required when this struct is populated. + format: int32 + type: integer + required: + - volumeNumber + type: object + type: array + x-kubernetes-list-map-keys: + - volumeNumber + x-kubernetes-list-type: map + required: + - nodeName + - resourceDefinitionName + type: object + status: + description: status defines the observed state of Resource + properties: + conditions: + description: conditions represent the current state of the Resource. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + connections: + description: |- + connections is the per-peer DRBD connection state observed by the + satellite (from `drbdsetup events2` / `drbdsetup status`). The + Python `linstor r list --faulty` reads this through the REST + `layer_object.drbd.connections` map — without it, the CLI cannot + distinguish a healthy three-peer mesh from one with a broken + connection. Keyed by peer node name. + items: + description: |- + ResourceConnectionStatus is the state of one DRBD peer connection + from this replica's point of view. Maps 1:1 to upstream LINSTOR's + `DrbdConnection` REST shape — the Python CLI walks the `connected` + flag to color the Conns column red on `linstor r list`. + properties: + connected: + description: |- + connected is true iff DRBD reports the connection as + `Connected` (handshake complete, replication active). + type: boolean + message: + description: |- + message is the human-readable DRBD connection state + (`Connected`, `StandAlone`, `BrokenPipe`, `NetworkFailure`, + `Connecting`, `Timeout`, etc.) as reported by `drbdsetup + events2`. Populated even when Connected — useful for + surfacing transitional states. + type: string + peerDRBDNodeID: + description: |- + peerDrbdNodeId is the DRBD-9 node-id assigned to the peer in + this resource's connection table. Read from `drbdsetup + events2` connection-frame `peer-node-id` field. Six e2e + tests today parse this value out of `drbdsetup status + --verbose` adjacent to the peer-name — surfacing it on + Status lets them switch to a k8s-native read. The peer's + own Resource CRD also carries this number under + `Status.DRBDNodeID`, so callers with the atomic-view luxury + can cross-check; the field is retained here for ergonomics + when only the local Resource is in hand. + format: int32 + type: integer + peerNodeName: + description: |- + peerNodeName is the name of the peer Resource (and the node + it lives on — Resource names are RD.node). + type: string + peerVolumes: + description: |- + peerVolumes is the peer's view of each volume's disk state + on this connection — read from `drbdsetup events2 + --statistics` peer-device frames' `peer-disk:` token. + Important under network-partition: the local replica's + `Status.Volumes[i].DiskState` (UpToDate from this node's + kernel) and the peer's view of the same volume + (`DUnknown` from the peer's kernel) diverge. The + state-standalone-partition.sh and network-partition.sh + e2e tests assert against this divergence; without + peerVolumes they shell into the satellite and grep + drbdsetup. Keyed by volumeNumber. + items: + description: |- + PeerVolumeStatus is the per-volume slice of a peer's view of one + connection: what the peer's kernel reports its replica's disk_state + to be. Distinct from the local-side `ResourceVolumeStatus.DiskState` + because under network-partition the two views diverge (local says + UpToDate, peer says DUnknown / Outdated). 8 e2e partition tests + parse this token out of `drbdsetup status --verbose`; the field + gives them a kubectl-native substitute. + properties: + peerDiskState: + description: |- + peerDiskState is the peer's DRBD-9 disk_state for this volume + — `UpToDate`, `Outdated`, `Inconsistent`, `Diskless`, or + `DUnknown` (the local kernel cannot determine the peer's + disk state, typical under partition). Mirrors the + `peer-disk:` token in `drbdsetup events2 + --statistics` peer-device frames. + type: string + volumeNumber: + description: |- + volumeNumber is the DRBD-9 volume number this peer-view entry + describes. Matches the parent + `ResourceDefinition.Spec.VolumeDefinitions[].VolumeNumber`. + format: int32 + type: integer + required: + - volumeNumber + type: object + type: array + x-kubernetes-list-map-keys: + - volumeNumber + x-kubernetes-list-type: map + replicationState: + description: |- + replicationState is the DRBD-9 replication state for this + peer reported by `drbdsetup events2 --statistics` peer- + device frames: Established / SyncSource / SyncTarget / + PausedSync* / VerifyS / VerifyT / Ahead / Behind / Off / + WFBitMap* / WFSyncUUID / StartingSyncS / StartingSyncT. The + Python CLI's `linstor v l` Repl column reads this. + type: string + required: + - peerNodeName + type: object + type: array + x-kubernetes-list-map-keys: + - peerNodeName + x-kubernetes-list-type: map + drbdMinor: + description: |- + drbdMinor is a read-only mirror of the volume-0 minor now + living authoritatively on + ResourceDefinition.Spec.VolumeDefinitions[0].DRBDMinor. Kept so + the cluster-wide taken-set scan and observers that still read + Status keep working during the migration window. + format: int32 + type: integer + drbdNodeID: + description: |- + drbdNodeID is a read-only mirror of the authoritative + Spec.DRBDNodeID, kept so observers/REST/tests that still read + Status during the migration window don't break. The allocator + writes Spec.DRBDNodeID; the reconciler mirrors it here. nil + means not yet allocated. + format: int32 + type: integer + drbdPort: + description: |- + drbdPort is a read-only mirror of the authoritative + Spec.DRBDPort (per-node listen port), kept so the REST DTO + (drbdLayerFromStatus → TCPPorts) and observers that still read + Status keep working during the migration window. The allocator + writes Spec.DRBDPort; the reconciler mirrors it here. + format: int32 + type: integer + drbdState: + description: |- + drbdState is the current resource-level DRBD state reported by + `drbdsetup events2` — `UpToDate`, `Outdated`, `Connected`, + `Failed`, etc. Phase 10.2: written by the satellite via the + Status subresource so a concurrent Spec mutation + (auto-diskful, resize) can't clobber it. + type: string + inUse: + description: inUse is whether DRBD reports the resource as primary + anywhere. + type: boolean + role: + description: |- + role is the kernel-reported DRBD-9 role on this node, parsed + from the `role:` token in `drbdsetup events2` resource frames. + Values mirror the DRBD-9 enum: `Primary` (open for write), + `Secondary` (replication-only), `Unknown` (transient — kernel + just attached, has not yet picked a role). Per-replica, in + contrast to the cluster-wide `inUse` bool: a 3-replica RD has + up to one Primary and two Secondaries, all on different nodes. + ~15 e2e tests `grep role:` from `drbdsetup status`; surfacing + it on Status lets them switch to a k8s-native read. + type: string + suspended: + description: |- + suspended is the kernel-reported reason for I/O suspension on + this replica, parsed from the `suspended:` token in + `drbdsetup events2` resource frames. Values mirror the DRBD-9 + enum: `No` (I/O serves normally), `Quorum` (quorum lost, + `on-no-quorum=suspend-io` blocked the I/O queue), `User` + (`drbdadm suspend-io` issued by operator), `NoData` (no + UpToDate replica reachable, kernel is waiting for one), + `Fencing` (resource-and-stonith fencing handler running). + Paired with the per-volume `quorum` field for quorum-loss + recovery tests — 3 e2e tests need this to distinguish a + recoverable quorum suspend from a user/fencing suspend. + type: string + toggleDiskRetries: + description: |- + toggleDiskRetries counts how many times the satellite + reconciler has failed mid-conversion while running the + diskless→diskful chain (storage carve → drbdmeta create-md + → drbdadm up → initial-sync). Upstream LINSTOR exposes the + same counter under `Resource.toggle_disk_retries` so + operators can spot a permanently-stuck conversion via + `linstor r l`. Bug 39. + + Reset to 0 when the conversion succeeds (Resource reaches + the diskful steady-state) or when a cancel completes via + `Spec.ToggleDiskCancel`. The reconciler does NOT impose a + hard cap — the bound is policy that lives in the controller + layer (today the legacy backoff cap of 10 attempts) and is + surfaced via a `ToggleDiskFailed` condition once exceeded. + format: int32 + type: integer + volumes: + description: volumes is the per-volume runtime state reported by the + satellite. + items: + description: ResourceVolumeStatus is the runtime state of one volume + of a Resource. + properties: + allocatedKib: + format: int64 + type: integer + currentGI: + description: |- + currentGi is the DRBD-9 current generation identifier reported + by `drbdsetup events2` for this replica's local volume. The + controller reads it when adding a new replica to skip the full + initial-sync: pre-seeding the new metadata block with this GI + makes DRBD's GI handshake see the new peer as already-in-sync, + turning hours of resync on multi-TiB volumes into instant. + Updated by the satellite-side observer; never set in Spec. + type: string + devicePath: + type: string + diskState: + type: string + historyGI: + description: |- + historyGi carries the historical GI chain (DRBD keeps 3-4 + previous generations). Useful for split-brain forensics and + cluster-state UI; may be elided when we run tight on Status + budget. Order is newest-first. + items: + type: string + type: array + outOfSyncKib: + description: |- + outOfSyncKib is the worst-case "how many KiB this volume is + behind any peer" reported by `drbdsetup events2 --statistics` + peer-device frames. Combined with RD.Spec.VolumeDefinitions + SizeKib, callers compute a sync-progress percentage: + progress = (1 - outOfSyncKib / sizeKib) * 100 + + 0 means fully in sync; sizeKib (or close to it) means fresh + resync hasn't started yet. Surfaced via the REST view layer + so `linstor r l` / piraeus dashboards can render a CDI-style + progress bar without polling drbdsetup themselves. + format: int64 + type: integer + quorum: + description: |- + quorum reports the DRBD-9 kernel's per-volume quorum view + from the `quorum:yes|no` field in events2 `device` frames. + true means the local replica has quorum and may serve I/O; + false means the kernel has marked the volume quorum-lost + (writes block / fail-fast depending on `on-no-quorum` + policy). Per-volume is finer-grained than the node-wide + `drbd.linbit.com/lost-quorum` Kubernetes taint: a node with + quorum on one RD and no-quorum on another surfaces both + states correctly. The CSI plugin's quorum-aware mount path + (refusing to mount a no-quorum volume) reads this signal. + type: boolean + storagePool: + type: string + usableKib: + format: int64 + type: integer + volumeNumber: + format: int32 + type: integer + required: + - volumeNumber + type: object + type: array + x-kubernetes-list-map-keys: + - volumeNumber + x-kubernetes-list-type: map + type: object + required: + - spec + type: object + x-kubernetes-validations: + - message: metadata.name must equal . + (case-insensitive) + optionalOldSelf: true + rule: oldSelf.hasValue() || self.metadata.name.lowerAscii() == (self.spec.resourceDefinitionName + + '.' + self.spec.nodeName).lowerAscii() + served: true + storage: true + subresources: + status: {} diff --git a/packages/system/linstor/definitions/blockstor.cozystack.io_snapshots.yaml b/packages/system/linstor/definitions/blockstor.cozystack.io_snapshots.yaml new file mode 100644 index 000000000..7b669964c --- /dev/null +++ b/packages/system/linstor/definitions/blockstor.cozystack.io_snapshots.yaml @@ -0,0 +1,315 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.20.1 + name: snapshots.blockstor.cozystack.io +spec: + group: blockstor.cozystack.io + names: + kind: Snapshot + listKind: SnapshotList + plural: snapshots + singular: snapshot + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: |- + Snapshot is the Schema for the snapshots API. + + The CEL rule above enforces the cluster-wide naming convention every + composite-keyed CRD in the project follows: `metadata.name == .`. + Keeping the composite key encoded in the name lets the store's + `snapshotCRDName` helper round-trip the (rd, snap) pair through k8s + metadata without a sidecar index, and lets operators grep for + `.` across kinds (Resource, Snapshot, StoragePool) to find every + object bound to one parent. The `optionalOldSelf` escape makes the + rule create-only — finalizer-strip on a stale-named Snapshot + (e.g. one created before this marker existed) is never blocked. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: spec defines the desired state of Snapshot + properties: + groupID: + description: |- + groupID, when non-empty, marks this Snapshot as a member of a + transactional multi-RD batch — every Snapshot CRD stamped with + the same GroupID participates in a SINGLE suspend-io broadcast + across the UNION of every sibling's targeted nodes. Bug 353: + `linstor s create-multiple` (POST /v1/actions/snapshot/multi) + previously looped per-RD through the Bug-351 orchestrator and + each Snapshot ran its own independent 3-phase suspend/take/ + resume — so per-RD suspend windows did not overlap and the + cross-RD point-in-time consistency operators expect from a + "group snapshot" (DB + WAL on separate RDs) was lost. + + Lifecycle (driven by the controller-side SnapshotReconciler): + 1. apiserver stamps every batched Snapshot with the same + crypto/rand-generated GroupID + SuspendIO=true. + 2. Controller gates phase advancement on the FULL group: + Phase 2 only fires when every sibling's every targeted + node has acked the suspend. + 3. Phase 3 only fires when every sibling's every targeted + node is Ready — or any sibling node Failed=true, in + which case the abort cascade fires SuspendIO=false on + every sibling immediately. + + Empty GroupID is the single-snap path (Bug 351 behaviour + preserved verbatim — siblings denominator collapses to self). + type: string + groupSize: + description: |- + groupSize is the number of Snapshot CRDs the apiserver fanned + out for this transactional batch (len of the + `snapshot create-multiple` entry list). It is the denominator the + controller-side SnapshotReconciler uses to decide when the group + is fully ASSEMBLED before it opens the suspend-io barrier. + + Bug 046 / Bug-353 atomicity fix: the apiserver creates the + sibling CRDs SEQUENTIALLY (one Store.Create per entry, with + hydration + an offline pre-check between each), so on a busy + stand the last sibling's CRD can land ~15s after the first. If + each satellite started `drbdsetup suspend-io` the instant its + own sibling appeared (the old behaviour, with SuspendIO stamped + at Create time), the group's volumes would freeze ~15s APART — + well over the ≤5s consistency budget — so a DB's data volume and + WAL volume on separate RDs would be captured at different + instants and a group restore could be corrupt. + + With GroupSize the controller holds the WHOLE group at Phase 0 + (no SuspendIO) until it observes every member, then flips + SuspendIO=true on every sibling in a single reconcile pass so + they all enter suspend within one controller cycle (sub-second), + bounding the suspend-entry slip far under budget. + + Zero means "not a coordinated batch" (the single-snap Bug-351 + path, or a legacy grouped Snapshot created before this field + existed) — in that case the controller falls back to the + observed-siblings count so a GroupID with no GroupSize still + makes progress instead of hanging on a missing denominator. + format: int32 + type: integer + nodes: + description: |- + nodes are the satellites the snapshot should live on. Empty means + "every node currently hosting the parent resource". + items: + type: string + type: array + props: + additionalProperties: + type: string + description: props is the LINSTOR property map for the snapshot. + type: object + resourceDefinitionName: + description: resourceDefinitionName is the parent ResourceDefinition. + type: string + snapshotName: + description: snapshotName is the user-facing snapshot identifier. + type: string + suspendIO: + description: |- + suspendIO, when true, signals every satellite that hosts a + diskful replica of the parent ResourceDefinition to call + `drbdsetup suspend-io ` before taking the local backing + snapshot. Bug 351: two diskful replicas snapshotting + independently would otherwise capture divergent bytes while + the application writer's traffic is still streaming through + DRBD; suspending I/O on every peer first freezes the + replicated block stream at a single, common point so the + per-node LV / zvol snapshots all reflect the same + point-in-time bytes. + + Lifecycle (driven by the controller-side SnapshotReconciler): + 1. apiserver creates Snapshot CRD with SuspendIO=true, + TakeSnapshot=false. Satellites stamp + Status.NodeStatus[].SuspendIOAcked once their suspend-io + call returns. + 2. Once every targeted node has acked, the controller stamps + Spec.TakeSnapshot=true. Satellites then dispatch + provider.CreateSnapshot and stamp Status.NodeStatus[].Ready. + 3. Once every targeted node is Ready (or any has Failed=true), + the controller flips Spec.SuspendIO=false and satellites + issue `drbdsetup resume-io `. + + Resume-on-failure is mandatory — a partially-acked suspend + followed by an abort MUST still resume I/O on the nodes that + did ack, otherwise application I/O hangs forever. The + controller's abort path clears SuspendIO unconditionally. + type: boolean + takeSnapshot: + description: |- + takeSnapshot, when true, signals each satellite that has + already acked the suspend-io barrier (see SuspendIO above) to + dispatch the local provider.CreateSnapshot. The flag is + stamped by the controller-side SnapshotReconciler once every + targeted node's Status.NodeStatus[].SuspendIOAcked is true — + the two-step `suspend → take → resume` shape mirrors upstream + LINSTOR's CtrlSnapshotCrtApiCallHandler 3-phase flow so the + per-node backing snapshots all reflect the same point-in-time + bytes. + type: boolean + volumeDefinitions: + description: volumeDefinitions records the size of each volume captured. + items: + description: SnapshotVolumeRef is one volume slot inside a Snapshot. + properties: + sizeKib: + format: int64 + type: integer + volumeNumber: + format: int32 + type: integer + required: + - sizeKib + - volumeNumber + type: object + type: array + required: + - resourceDefinitionName + - snapshotName + type: object + status: + description: status defines the observed state of Snapshot + properties: + conditions: + description: conditions represent the current state of the Snapshot. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + flags: + description: |- + flags carries terminal-state markers. Currently only + "FAILED" is meaningful — stamped by the satellite when + CreateSnapshot returns a non-retryable error class. + items: + type: string + type: array + nodeStatus: + description: nodeStatus reports per-node readiness from the satellites. + items: + description: |- + SnapshotPerNodeStatus is the satellite-reported state of one + materialisation of the snapshot. + properties: + createTimestamp: + format: int64 + type: integer + failed: + description: |- + failed is stamped true when the local satellite hit a + terminal failure while either suspending I/O, taking the + per-node snapshot, or resuming I/O. The controller-side + SnapshotReconciler treats any Failed=true entry as an abort + signal: it flips Spec.SuspendIO=false immediately so the + already-suspended siblings resume rather than wait + indefinitely on the doomed node, and stamps the parent + Snapshot's Status.Flags with FAILED. Bug 351. + type: boolean + nodeName: + type: string + ready: + type: boolean + suspendIOAcked: + description: |- + suspendIOAcked is stamped true by the local satellite once + `drbdsetup suspend-io ` has returned for the parent + ResourceDefinition. The controller-side SnapshotReconciler + gates the Phase-2 `TakeSnapshot` transition on every targeted + node having acked. Cleared back to false when the controller + flips Spec.SuspendIO=false and the satellite issues + `drbdsetup resume-io `. Bug 351. + type: boolean + required: + - nodeName + type: object + type: array + type: object + required: + - spec + type: object + x-kubernetes-validations: + - message: metadata.name must equal . + (case-insensitive) + optionalOldSelf: true + rule: oldSelf.hasValue() || self.metadata.name.lowerAscii() == (self.spec.resourceDefinitionName + + '.' + self.spec.snapshotName).lowerAscii() + served: true + storage: true + subresources: + status: {} diff --git a/packages/system/linstor/definitions/blockstor.cozystack.io_storagepools.yaml b/packages/system/linstor/definitions/blockstor.cozystack.io_storagepools.yaml new file mode 100644 index 000000000..2fa9911ed --- /dev/null +++ b/packages/system/linstor/definitions/blockstor.cozystack.io_storagepools.yaml @@ -0,0 +1,210 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.20.1 + name: storagepools.blockstor.cozystack.io +spec: + group: blockstor.cozystack.io + names: + kind: StoragePool + listKind: StoragePoolList + plural: storagepools + singular: storagepool + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: |- + StoragePool is the Schema for the storagepools API. + + The CEL rule above enforces the cluster-wide naming convention every + node-bound CRD in the project follows: `metadata.name == .`. + Keeping the composite key encoded in the name lets operators grep for + `.` across kinds (Resource, Snapshot, StoragePool) and find every + resource bound to one satellite at once. + + The match is case-insensitive (`lowerAscii()` on both sides) because + k8s metadata.Name is RFC-1123 (lowercase only) while LINSTOR identifiers + preserve their CamelCase spelling on the wire. Upstream's well-known + `DfltDisklessStorPool` is the canonical example — we must be able to + store it under metadata.name `dfltdisklessstorpool.` while keeping + `spec.poolName == "DfltDisklessStorPool"` for byte-equal comparisons in + the satellite's provider registry (Bug 59). + + The rule fires on both Create and Update; the REST layer + (`pkg/rest/storage_pools.go`) also rejects non-canonical bodies with a + friendlier 400 message so callers don't have to parse the k8s 422 + Invalid envelope. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: spec defines the desired state of StoragePool + properties: + nodeName: + description: |- + nodeName is the name of the satellite hosting this pool. Same as the + LINSTOR Node CRD's metadata.name. + type: string + poolName: + description: |- + poolName is the LINSTOR pool name (LVM VG, ZFS dataset, etc.). The + CRD-level CEL rule pins `metadata.name == poolName + "." + nodeName`, + so this field is required — without it the rule cannot evaluate. + type: string + props: + additionalProperties: + type: string + description: props is the LINSTOR property map for this pool. + type: object + providerKind: + description: providerKind is the storage backend. + enum: + - LVM + - LVM_THIN + - ZFS + - ZFS_THIN + - FILE + - FILE_THIN + - DISKLESS + type: string + sharedSpaceID: + description: |- + sharedSpaceId groups pools that physically share the same backing + LUN (e.g. an EXOS / NetApp / Ceph-RBD-as-shared-disk slice attached + to multiple satellites). Pools in the same group contribute their + free capacity once to cluster totals instead of summing, and the + autoplacer treats them as anti-affine for replica placement so a + 2-replica RD never lands twice on the same physical LUN. + Empty string = local pool (default). + type: string + required: + - nodeName + - poolName + - providerKind + type: object + status: + description: status defines the observed state of StoragePool + properties: + conditions: + description: conditions represent the current state of the StoragePool + resource. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + freeCapacity: + description: |- + freeCapacity is the free capacity in KiB reported by the satellite. + Matches the wire shape (gRPC SatellitePool.FreeCapacityKib, REST + `free_capacity_kib`) so /v1/view/storage-pools and the autoplacer + can read this field directly without a unit conversion. + format: int64 + type: integer + poolMissing: + description: |- + poolMissing indicates the satellite's last PoolStatus probe failed — + typically the backing pool (zpool / VG / FILE_THIN dir) was destroyed + out-of-band. While true, the placer skips this pool and the REST + wire view emits state="Faulty" instead of "Ok". + type: boolean + staticTraits: + additionalProperties: + type: string + description: staticTraits exposes provider-static attributes (kind, + etc.). + type: object + supportsSnapshots: + description: supportsSnapshots is whether the backing provider can + create snapshots. + type: boolean + totalCapacity: + description: totalCapacity is the total capacity in KiB reported by + the satellite. + format: int64 + type: integer + type: object + required: + - spec + type: object + x-kubernetes-validations: + - message: metadata.name must equal . (case-insensitive) + optionalOldSelf: true + rule: oldSelf.hasValue() || self.metadata.name.lowerAscii() == (self.spec.poolName + + '.' + self.spec.nodeName).lowerAscii() + served: true + storage: true + subresources: + status: {} diff --git a/packages/system/linstor/templates/backend-guard.yaml b/packages/system/linstor/templates/backend-guard.yaml new file mode 100644 index 000000000..0089c96ae --- /dev/null +++ b/packages/system/linstor/templates/backend-guard.yaml @@ -0,0 +1,9 @@ +{{- /* +Every template here renders one backend or the other from this value, so +an unrecognised one renders some of each and exits 0. The platform chart +validates storage.backend before passing it on, but a value arriving here +any other way, a hand-set component value for one, is checked here too. +*/ -}} +{{- if not (has .Values.backend (list "linstor" "blockstor")) }} +{{- fail (printf "linstor: backend must be \"linstor\" or \"blockstor\", got %q" (toString .Values.backend)) }} +{{- end }} diff --git a/packages/system/linstor/templates/blockstor-apiserver-tls.yaml b/packages/system/linstor/templates/blockstor-apiserver-tls.yaml new file mode 100644 index 000000000..02803e23f --- /dev/null +++ b/packages/system/linstor/templates/blockstor-apiserver-tls.yaml @@ -0,0 +1,110 @@ +{{- if eq .Values.backend "blockstor" }} +--- +{{- /* + cert-manager PKI for the blockstor apiserver's mutual-TLS endpoint. + + Chain (the same shape as linstor-api-tls.yaml; chained from the + cozy-linstor ca-bootstrapper self-signed Issuer that the + piraeus-operator package creates in this namespace, so there is no + self-managed root here): + ca-bootstrapper (Issuer, from piraeus-operator package) + └─> blockstor-api-ca (CA Certificate, 10y) + └─> blockstor-api-ca (CA Issuer) + ├─> blockstor-apiserver-server (serving cert, Service DNS SANs) + └─> blockstor-apiserver-client (client cert for in-cluster consumers) + + The apiserver's TLS listener (RequireAndVerifyClientCert) verifies + every client cert against ca.crt of the server Secret, and serves + tls.crt/tls.key. cert-manager rotates these in place; the apiserver + hot-reloads them from disk WITHOUT a restart — there are intentionally + NO reloader.stakater.com annotations. LinstorCluster.spec.apiTLS + references the blockstor-api-ca Issuer so linstor-csi gets client + certs chained to the same CA. */}} +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: blockstor-api-ca + namespace: {{ .Release.Namespace }} +spec: + commonName: blockstor-api-ca + secretName: blockstor-api-ca + duration: 87600h # 10 years + isCA: true + privateKey: + rotationPolicy: Never + usages: + - signing + - key encipherment + - cert sign + issuerRef: + name: ca-bootstrapper + kind: Issuer +--- +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + name: blockstor-api-ca + namespace: {{ .Release.Namespace }} +spec: + ca: + secretName: blockstor-api-ca +--- +{{- /* + Serving certificate for the apiserver TLS listener. The dnsNames cover + the Service FQDN in-cluster clients dial: + blockstor-apiserver.cozy-linstor.svc(.cluster.local). MUST stay in + sync with LinstorCluster.spec.externalController.url in cluster.yaml. */}} +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: blockstor-apiserver-server + namespace: {{ .Release.Namespace }} +spec: + secretName: blockstor-apiserver-server-tls + duration: 2160h # 90 days + renewBefore: 360h # 15 days + privateKey: + algorithm: ECDSA + size: 256 + rotationPolicy: Always + usages: + - server auth + - digital signature + - key encipherment + dnsNames: + - blockstor-apiserver + - blockstor-apiserver.cozy-linstor + - blockstor-apiserver.cozy-linstor.svc + - blockstor-apiserver.cozy-linstor.svc.cluster.local + issuerRef: + name: blockstor-api-ca + kind: Issuer +--- +{{- /* + Client certificate for in-cluster consumers: piraeus-operator's own + API probe, linstor-scheduler and linstor-gui (the platform points both + here under this backend), and the `linstor` CLI. Presented to the + apiserver's RequireAndVerifyClientCert listener. linstor-csi gets its + own client cert from the operator via LinstorCluster.spec.apiTLS. */}} +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: blockstor-apiserver-client + namespace: {{ .Release.Namespace }} +spec: + secretName: blockstor-apiserver-client-tls + commonName: blockstor-apiserver-client + duration: 2160h # 90 days + renewBefore: 360h # 15 days + privateKey: + algorithm: ECDSA + size: 256 + rotationPolicy: Always + usages: + - client auth + - digital signature + - key encipherment + issuerRef: + name: blockstor-api-ca + kind: Issuer +{{- end }} diff --git a/packages/system/linstor/templates/blockstor-apiserver.yaml b/packages/system/linstor/templates/blockstor-apiserver.yaml new file mode 100644 index 000000000..4f714832c --- /dev/null +++ b/packages/system/linstor/templates/blockstor-apiserver.yaml @@ -0,0 +1,186 @@ +{{- if eq .Values.backend "blockstor" }} +--- +{{- /* + blockstor apiserver — the LINSTOR-compatible REST front end split out + of the controller binary. linstor-csi (external mode) and the + `linstor` CLI dial it. Three replicas behind a Service. */}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: blockstor-apiserver + namespace: {{ .Release.Namespace }} +--- +{{- /* + CRUD on the blockstor.cozystack.io CRDs, named rather than wildcarded so a kind + added to the group later is not granted by omission. No finalizers, + events or leases: the REST handlers do not write those. */}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: blockstor-apiserver +rules: + - apiGroups: [blockstor.cozystack.io] + resources: + - controllerconfigs + - controllerconfigs/status + - nodes + - nodes/status + - physicaldevices + - physicaldevices/status + - resourcedefinitions + - resourcedefinitions/status + - resourcegroups + - resourcegroups/status + - resources + - resources/status + - snapshots + - snapshots/status + - storagepools + - storagepools/status + verbs: [get, list, watch, create, update, patch, delete] + {{- /* + Read-only, and cluster-wide only because the apiserver reads the + passphrase Secret through controller-runtime's default cached client, + whose informer lists and watches Secrets at cluster scope. Narrowing + this needs the binary to scope its Secret cache to its own namespace; + until then a namespaced Role here would leave that informer forbidden + and every passphrase read hanging. */}} + - apiGroups: [""] + resources: [secrets] + verbs: [get, list, watch] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: blockstor-apiserver +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: blockstor-apiserver +subjects: + - kind: ServiceAccount + name: blockstor-apiserver + namespace: {{ .Release.Namespace }} +--- +{{- /* + Writes to Secrets stay in this namespace: the only Secret the apiserver + writes is the encryption passphrase, `encryption create-passphrase` and + `modify-passphrase`, and it always lives here. A cluster-wide write + grant would let this ServiceAccount rewrite any tenant's credentials. */}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: blockstor-apiserver-secrets + namespace: {{ .Release.Namespace }} +rules: + - apiGroups: [""] + resources: [secrets] + verbs: [create, update, patch] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: blockstor-apiserver-secrets + namespace: {{ .Release.Namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: blockstor-apiserver-secrets +subjects: + - kind: ServiceAccount + name: blockstor-apiserver + namespace: {{ .Release.Namespace }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: blockstor-apiserver + namespace: {{ .Release.Namespace }} + labels: + app: blockstor-apiserver + app.kubernetes.io/component: blockstor-apiserver +spec: + replicas: 3 + selector: {matchLabels: {app: blockstor-apiserver}} + template: + metadata: + labels: + app: blockstor-apiserver + app.kubernetes.io/component: blockstor-apiserver + spec: + serviceAccountName: blockstor-apiserver + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: ScheduleAnyway + labelSelector: + matchLabels: {app: blockstor-apiserver} + containers: + - name: apiserver + image: {{ .Values.blockstorApiserver.image.repository }}:{{ .Values.blockstorApiserver.image.tag }} + imagePullPolicy: IfNotPresent + args: + {{- /* + Plain-HTTP debug listener with no client authentication. + Bound to loopback so nothing on the pod network reaches it: + `kubectl port-forward` connects from inside the pod's network + namespace, so it still works. */}} + - --rest-bind-address=127.0.0.1:3370 + {{- /* + Mutual-TLS listener — the ONLY port the Service exposes. + Requires + verifies client certs against the mounted CA; + hot-reloads cert/key/CA on cert-manager rotation. */}} + - --tls-bind-address=:3371 + - --tls-cert-file=/etc/blockstor/tls/tls.crt + - --tls-key-file=/etc/blockstor/tls/tls.key + - --tls-client-ca-file=/etc/blockstor/tls/ca.crt + - --health-probe-bind-address=:8081 + - --metrics-bind-address=0 + env: + - name: POD_NAMESPACE + valueFrom: {fieldRef: {fieldPath: metadata.namespace}} + ports: + - {name: rest-tls, containerPort: 3371} + - {name: health, containerPort: 8081} + volumeMounts: + - name: api-tls + mountPath: /etc/blockstor/tls + readOnly: true + readinessProbe: + httpGet: {path: /readyz, port: health} + initialDelaySeconds: 5 + livenessProbe: + httpGet: {path: /healthz, port: health} + initialDelaySeconds: 15 + securityContext: + runAsNonRoot: true + runAsUser: 65532 + allowPrivilegeEscalation: false + capabilities: {drop: [ALL]} + seccompProfile: {type: RuntimeDefault} + resources: + requests: {cpu: 50m, memory: 128Mi} + limits: {cpu: 500m, memory: 512Mi} + volumes: + - name: api-tls + secret: + secretName: blockstor-apiserver-server-tls +--- +{{- /* + mTLS-only Service: exposes ONLY :3371. The plain-HTTP debug port + (3370) is deliberately NOT listed. Clients dial + https://blockstor-apiserver.cozy-linstor.svc:3371 presenting a client + cert. This DNS MUST match LinstorCluster.spec.externalController.url + and a serving-cert SAN. */}} +apiVersion: v1 +kind: Service +metadata: + name: blockstor-apiserver + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/component: blockstor-apiserver +spec: + selector: {app: blockstor-apiserver} + ports: + - {name: rest-tls, port: 3371, targetPort: 3371} +{{- end }} diff --git a/packages/system/linstor/templates/blockstor-controller.yaml b/packages/system/linstor/templates/blockstor-controller.yaml new file mode 100644 index 000000000..fd50b32d0 --- /dev/null +++ b/packages/system/linstor/templates/blockstor-controller.yaml @@ -0,0 +1,124 @@ +{{- if eq .Values.backend "blockstor" }} +--- +{{- /* + blockstor controller — runs the reconcilers for the blockstor.cozystack.io + CRDs (ResourceDefinitions / Resources / Snapshots / StoragePools / + Nodes). The REST API is split out into the separate apiserver + Deployment; the controller runs with --enable-rest-api=false. */}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: blockstor-controller + namespace: {{ .Release.Namespace }} +--- +{{- /* + Cluster-wide read on Kubernetes Nodes and the blockstor.cozystack.io kinds + the reconcilers manage, as blockstor's own config/rbac/role.yaml grants + them, kind by kind so a kind added to the group later is not granted by + omission. No leases: the controller runs without leader election. */}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: blockstor-controller +rules: + - apiGroups: [""] + resources: [events] + verbs: [create, patch] + - apiGroups: [events.k8s.io] + resources: [events] + verbs: [create, patch] + - apiGroups: [""] + resources: [nodes] + verbs: [get, list, watch] + - apiGroups: [blockstor.cozystack.io] + resources: [controllerconfigs] + verbs: [get, list, watch] + - apiGroups: [blockstor.cozystack.io] + resources: [nodes, resourcedefinitions, resourcegroups, resources, snapshots, storagepools] + verbs: [get, list, watch, create, update, patch, delete] + - apiGroups: [blockstor.cozystack.io] + resources: + - nodes/finalizers + - resourcedefinitions/finalizers + - resourcegroups/finalizers + - resources/finalizers + - snapshots/finalizers + - storagepools/finalizers + verbs: [update] + - apiGroups: [blockstor.cozystack.io] + resources: + - nodes/status + - resourcedefinitions/status + - resourcegroups/status + - resources/status + - snapshots/status + - storagepools/status + verbs: [get, update, patch] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: blockstor-controller +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: blockstor-controller +subjects: + - kind: ServiceAccount + name: blockstor-controller + namespace: {{ .Release.Namespace }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: blockstor-controller + namespace: {{ .Release.Namespace }} + labels: + app: blockstor-controller + app.kubernetes.io/component: blockstor-controller +spec: + replicas: 1 + {{- /* + One reconciler at a time. The binary runs without leader election, so a + rolling update would run the old and the new pod side by side against the + same CRDs; Recreate stops the old one before the new one starts. */}} + strategy: + type: Recreate + selector: {matchLabels: {app: blockstor-controller}} + template: + metadata: + labels: + app: blockstor-controller + app.kubernetes.io/component: blockstor-controller + spec: + serviceAccountName: blockstor-controller + containers: + - name: manager + image: {{ .Values.blockstorController.image.repository }}:{{ .Values.blockstorController.image.tag }} + imagePullPolicy: IfNotPresent + args: + {{- /* + REST API lives in the separate apiserver Deployment — + controller only runs reconcilers. */}} + - --enable-rest-api=false + - --health-probe-bind-address=:8081 + - --metrics-bind-address=0 + - --leader-elect=false + ports: + - {name: health, containerPort: 8081} + readinessProbe: + httpGet: {path: /readyz, port: 8081} + initialDelaySeconds: 5 + livenessProbe: + httpGet: {path: /healthz, port: 8081} + initialDelaySeconds: 15 + securityContext: + runAsNonRoot: true + runAsUser: 65532 + allowPrivilegeEscalation: false + capabilities: {drop: [ALL]} + seccompProfile: {type: RuntimeDefault} + resources: + requests: {cpu: 50m, memory: 64Mi} + limits: {cpu: 500m, memory: 256Mi} +{{- end }} diff --git a/packages/system/linstor/templates/blockstor-satellite.yaml b/packages/system/linstor/templates/blockstor-satellite.yaml new file mode 100644 index 000000000..297c0d984 --- /dev/null +++ b/packages/system/linstor/templates/blockstor-satellite.yaml @@ -0,0 +1,281 @@ +{{- define "blockstor.satellite.drbdGlobalConf" -}} +# blockstor satellite — global_common.conf. +# Kept minimal: per-resource tuning lives in the rendered .res +# files, not here. Mirrors the drbd-utils trixie default. +global { + usage-count no; + udev-always-use-vnr; +} +common { + handlers {} + startup {} + options {} + disk {} + net {} +} +{{- end }} +{{- if eq .Values.backend "blockstor" }} +--- +{{- /* + blockstor-satellite DaemonSet. Runs on every node, drives drbdadm + + ZFS/LVM reconcile, registers its StoragePools (declared via the + StoragePool CRDs) and writes node-scoped Status back to the apiserver. + + This DaemonSet loads no kernel module and mounts nothing from + /run/systemd, so it needs no Talos-specific patch. It expects DRBD to be + loaded already: on Talos by the siderolabs/drbd extension, on generic + Linux by the drbd-module-loader init container of piraeus's own + satellite pod on the same node, which nothing here orders this pod + after. */}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: blockstor-satellite + namespace: {{ .Release.Namespace }} +--- +{{- /* + /etc/drbd.d is a hostPath bind (below), which hides the + global_common.conf baked into the image. drbdadm reads that file on + every invocation, so it is mounted back on top of the bind by subPath. */}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: blockstor-satellite-drbd-conf + namespace: {{ .Release.Namespace }} +data: + global_common.conf: | +{{ include "blockstor.satellite.drbdGlobalConf" . | indent 4 }} +--- +{{- /* + What the satellite writes, and no more. It creates and deletes only the + PhysicalDevices it discovers; on Nodes, Resources, Snapshots and + StoragePools it updates props and finalizers and server-side-applies the + SkipDisk prop, which is a patch; everything else it reads. Kubernetes + Nodes are read for their InternalIP. No leases: it runs no leader + election. Secrets are in the namespaced Role below. */}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: blockstor-satellite +rules: + - apiGroups: [""] + resources: [events] + verbs: [create, patch] + - apiGroups: [""] + resources: [nodes] + verbs: [get, list, watch] + - apiGroups: [blockstor.cozystack.io] + resources: + - controllerconfigs + - nodes + - physicaldevices + - resourcedefinitions + - resourcegroups + - resources + - snapshots + - storagepools + verbs: [get, list, watch] + - apiGroups: [blockstor.cozystack.io] + resources: [physicaldevices] + verbs: [create, update, patch, delete] + - apiGroups: [blockstor.cozystack.io] + resources: [nodes, resources, snapshots, storagepools] + verbs: [update, patch] + - apiGroups: [blockstor.cozystack.io] + resources: + - nodes/status + - physicaldevices/status + - resources/status + - snapshots/status + - storagepools/status + - nodes/finalizers + - physicaldevices/finalizers + - resources/finalizers + - snapshots/finalizers + - storagepools/finalizers + verbs: [get, update, patch] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: blockstor-satellite +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: blockstor-satellite +subjects: + - kind: ServiceAccount + name: blockstor-satellite + namespace: {{ .Release.Namespace }} +--- +{{- /* + The satellite reads one Secret, the LUKS passphrase, in its own + namespace, with a direct GET rather than through a cache, so a + namespaced get is all it needs. A privileged pod on every node holding + a token that reads every Secret in the cluster would hand any node + compromise every tenant's credentials. */}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: blockstor-satellite-secrets + namespace: {{ .Release.Namespace }} +rules: + - apiGroups: [""] + resources: [secrets] + verbs: [get] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: blockstor-satellite-secrets + namespace: {{ .Release.Namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: blockstor-satellite-secrets +subjects: + - kind: ServiceAccount + name: blockstor-satellite + namespace: {{ .Release.Namespace }} +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: blockstor-satellite + namespace: {{ .Release.Namespace }} + labels: + app: blockstor-satellite + app.kubernetes.io/component: blockstor-satellite +spec: + selector: {matchLabels: {app: blockstor-satellite}} + template: + metadata: + labels: + app: blockstor-satellite + app.kubernetes.io/component: blockstor-satellite + {{- /* The file is mounted by subPath, which Kubernetes never refreshes, + so a change to it has to roll the pods. */}} + annotations: + checksum/drbd-conf: {{ include "blockstor.satellite.drbdGlobalConf" . | sha256sum }} + spec: + serviceAccountName: blockstor-satellite + hostPID: true + {{- /* + hostNetwork so the container's hostname matches the node name + (drbdadm picks the `on ` block by hostname) and the + advertised endpoint equals the node IP. */}} + hostNetwork: true + hostIPC: true + dnsPolicy: ClusterFirstWithHostNet + tolerations: + - operator: Exists + {{- /* + Runs on every node, control-plane nodes included, which is what + the tolerations above are for: storage lives wherever the DRBD + module and a pool are, not on workers only. + Short grace and no preStop drain: DRBD state lives in the host + kernel and survives the pod. On startup the next satellite keeps + every resource it finds with a usable disk or a live peer, and + tears down the rest. */}} + terminationGracePeriodSeconds: 10 + containers: + - name: satellite + image: {{ .Values.blockstorSatellite.image.repository }}:{{ .Values.blockstorSatellite.image.tag }} + imagePullPolicy: IfNotPresent + args: + {{- /* + drbd's /etc/drbd.conf includes /etc/drbd.d/*.res; the + satellite writes rendered files there. The host backing + is /var/lib/blockstor-drbd.d (writable on Talos; /etc is + read-only). */}} + - --state-dir=/etc/drbd.d + {{- /* + Storage pools come from StoragePool objects, not flags. */}} + - --health-probe-bind-address=:9101 + env: + - name: NODE_NAME + valueFrom: {fieldRef: {fieldPath: spec.nodeName}} + - name: POD_IP + valueFrom: {fieldRef: {fieldPath: status.podIP}} + - name: POD_NAMESPACE + valueFrom: {fieldRef: {fieldPath: metadata.namespace}} + livenessProbe: + httpGet: {path: /healthz, port: 9101} + initialDelaySeconds: 15 + periodSeconds: 20 + timeoutSeconds: 3 + failureThreshold: 3 + readinessProbe: + httpGet: {path: /readyz, port: 9101} + initialDelaySeconds: 5 + periodSeconds: 10 + timeoutSeconds: 3 + failureThreshold: 3 + securityContext: + privileged: true + volumeMounts: + {{- /* + Plain bind of host /dev, no mountPropagation: the + partitions `zpool create` makes appear in the host's + devtmpfs, which is where libzfs opens them. */}} + - {name: dev, mountPath: /dev} + - {name: modules, mountPath: /lib/modules, readOnly: true} + - {name: lvm-run, mountPath: /run/lvm} + {{- /* + Host udev database, which libzfs and libblkid look devices up in. */}} + - {name: run-udev, mountPath: /run/udev, readOnly: true} + - {name: state, mountPath: /var/lib/blockstor-satellite} + - {name: pool, mountPath: /var/lib/blockstor-pool} + {{- /* + The satellite's own DRBD config dir on the host, + /var/lib/blockstor-drbd.d, so its .res files never mix with + another DRBD user's /etc/drbd.d. */}} + - {name: drbd-cfg, mountPath: /etc/drbd.d} + - name: drbd-global-conf + mountPath: /etc/drbd.d/global_common.conf + subPath: global_common.conf + readOnly: true + resources: + requests: {cpu: 50m, memory: 64Mi} + limits: {cpu: 500m, memory: 512Mi} + volumes: + - {name: dev, hostPath: {path: /dev, type: Directory}} + - {name: modules, hostPath: {path: /lib/modules}} + - {name: lvm-run, hostPath: {path: /run/lvm, type: DirectoryOrCreate}} + - {name: run-udev, hostPath: {path: /run/udev, type: Directory}} + - {name: state, hostPath: {path: /var/lib/blockstor-satellite, type: DirectoryOrCreate}} + - {name: pool, hostPath: {path: /var/lib/blockstor-pool, type: DirectoryOrCreate}} + - {name: drbd-cfg, hostPath: {path: /var/lib/blockstor-drbd.d, type: DirectoryOrCreate}} + - name: drbd-global-conf + configMap: + name: blockstor-satellite-drbd-conf + items: + - {key: global_common.conf, path: global_common.conf} +--- +{{- /* + blockstor-satellite runs on host networking and, in this release, listens + on every address without authentication: 9100 serves snapshot streams to + other satellites, 9101 its health probes, 8080 controller-runtime's + metrics. None of them is for anything outside the cluster, so they are + closed to the world the way restrict-drbd-reactor closes drbd-reactor's. */}} +apiVersion: cilium.io/v2 +kind: CiliumClusterwideNetworkPolicy +metadata: + name: restrict-blockstor-satellite +spec: + ingressDeny: + - fromEntities: + - world + toPorts: + - ports: + - port: "9100" + - port: "9101" + - port: "8080" + ingress: + - fromEntities: + - world + - host + - cluster + nodeSelector: + matchLabels: {} +{{- end }} diff --git a/packages/system/linstor/templates/cluster.yaml b/packages/system/linstor/templates/cluster.yaml index 4639e677b..271611b26 100644 --- a/packages/system/linstor/templates/cluster.yaml +++ b/packages/system/linstor/templates/cluster.yaml @@ -7,14 +7,46 @@ metadata: spec: #nodeSelector: # node-role.kubernetes.io/linstor: "" + {{- if eq .Values.backend "blockstor" }} + {{- /* External mode: piraeus-operator runs no linstor-controller of its + own. linstor-csi talks to blockstor-apiserver, which serves the + LINSTOR REST API on the mTLS port :3371 only. The URL has to match + the Service and a SAN of its serving certificate, both in + blockstor-apiserver*.yaml. linstor-scheduler and linstor-gui read + this URL and clientSecretName below from this object too, so no + other package names blockstor's Service or Secret. */}} + externalController: + url: https://blockstor-apiserver.cozy-linstor.svc:3371 + {{- else }} internalTLS: certManager: name: linstor-internal-ca kind: Issuer + {{- end }} apiTLS: certManager: + {{- if eq .Values.backend "blockstor" }} + {{- /* The operator issues linstor-csi-{controller,node}-tls from this + Issuer, so the CSI pods present a client certificate chained to + the CA blockstor-apiserver verifies. */}} + name: blockstor-api-ca + {{- else }} name: linstor-api-ca + {{- end }} kind: Issuer + {{- if eq .Values.backend "blockstor" }} + {{- /* The operator is a client of the API itself: it probes + /v1/controller/version before every LinstorCluster and + LinstorSatellite reconcile. In external mode it issues no + certificate for that client and only reads the Secret named here, + whose default, linstor-client-tls, either does not exist or, on a + cluster that ran the LINSTOR backend, still carries the old CA. + Either way the probe fails with "certificate signed by unknown + authority" and every reconcile stops before it starts, freezing the + satellite DaemonSets at their last spec. This is the client + certificate the chart issues from the same CA as the serving one. */}} + clientSecretName: blockstor-apiserver-client-tls + {{- end }} properties: {{- if .Values.linstor.autoDiskful.enabled }} - name: DrbdOptions/auto-diskful @@ -32,6 +64,7 @@ spec: value: "20" - name: DrbdOptions/Net/timeout value: "100" + {{- if eq .Values.backend "linstor" }} controller: enabled: true podTemplate: @@ -80,6 +113,7 @@ spec: configMap: name: linstor-plunger defaultMode: 0755 + {{- end }} csiController: podTemplate: spec: @@ -148,6 +182,7 @@ spec: - name: linstor-wait-node-online image: {{ .Values.linstorCSI.image.repository }}:{{ .Values.linstorCSI.image.tag }} patches: + {{- if eq .Values.backend "linstor" }} - target: kind: Deployment name: linstor-controller @@ -155,6 +190,7 @@ spec: - op: add path: /metadata/annotations/reloader.stakater.com~1auto value: "true" + {{- end }} - target: kind: Deployment name: linstor-csi-controller diff --git a/packages/system/linstor/templates/crds/crds.yaml b/packages/system/linstor/templates/crds/crds.yaml new file mode 100644 index 000000000..d50a07087 --- /dev/null +++ b/packages/system/linstor/templates/crds/crds.yaml @@ -0,0 +1,24 @@ +{{- /* +Blockstor's CRDs ship only with the blockstor backend. A LINSTOR +cluster has no use for them, and installing a component's schema +without the component that reconciles it invites objects nothing +serves. + +Every CRD is kept on an upgrade that stops rendering it. These live +under templates/, so they are ordinary release members: switching the +backend back to linstor would otherwise delete them, and the API server +deletes every object of a CRD before it removes the CRD. Those objects +are blockstor's whole database; it runs with no other datastore. The +annotation is added here rather than in definitions/, which is copied +verbatim from blockstor's generated manifests by `make update-blockstor-crds`. +*/}} +{{- if eq .Values.backend "blockstor" }} +{{- range $path, $_ := .Files.Glob "definitions/*" }} +{{- $crd := $.Files.Get $path | fromYaml }} +{{- $annotations := default dict $crd.metadata.annotations }} +{{- $_ := set $annotations "helm.sh/resource-policy" "keep" }} +{{- $_ := set $crd.metadata "annotations" $annotations }} +--- +{{ toYaml $crd }} +{{- end }} +{{- end }} diff --git a/packages/system/linstor/templates/linstor-api-tls.yaml b/packages/system/linstor/templates/linstor-api-tls.yaml index 055e6d082..c178b1a67 100644 --- a/packages/system/linstor/templates/linstor-api-tls.yaml +++ b/packages/system/linstor/templates/linstor-api-tls.yaml @@ -1,3 +1,4 @@ +{{- if eq .Values.backend "linstor" }} --- apiVersion: cert-manager.io/v1 kind: Certificate @@ -27,3 +28,4 @@ metadata: spec: ca: secretName: linstor-api-ca +{{- end }} diff --git a/packages/system/linstor/templates/linstor-internal-tls.yaml b/packages/system/linstor/templates/linstor-internal-tls.yaml index fe5ff4b1f..52913afde 100644 --- a/packages/system/linstor/templates/linstor-internal-tls.yaml +++ b/packages/system/linstor/templates/linstor-internal-tls.yaml @@ -1,3 +1,5 @@ +{{- /* Under both backends: the satellite configuration in + satellites-cozy.yaml takes its internalTLS certificates from this CA. */ -}} --- apiVersion: cert-manager.io/v1 kind: Certificate diff --git a/packages/system/linstor/templates/plunger/configmap-scripts.yaml b/packages/system/linstor/templates/plunger/configmap-scripts.yaml index 7dc72ef59..871a554d2 100644 --- a/packages/system/linstor/templates/plunger/configmap-scripts.yaml +++ b/packages/system/linstor/templates/plunger/configmap-scripts.yaml @@ -1,3 +1,4 @@ +{{- if eq .Values.backend "linstor" }} {{- $files := .Files.Glob "hack/plunger/*.sh" -}} {{/* TODO Add checksum of scripts to the pod selectors */}} --- @@ -7,3 +8,4 @@ metadata: name: linstor-plunger namespace: cozy-linstor data: {{- $files.AsConfig | nindent 2 }} +{{- end }} diff --git a/packages/system/linstor/templates/podscrape.yaml b/packages/system/linstor/templates/podscrape.yaml index 05b1483e1..2ed584d38 100644 --- a/packages/system/linstor/templates/podscrape.yaml +++ b/packages/system/linstor/templates/podscrape.yaml @@ -20,6 +20,7 @@ spec: selector: matchLabels: app.kubernetes.io/component: linstor-satellite +{{- if eq .Values.backend "linstor" }} --- apiVersion: operator.victoriametrics.com/v1beta1 kind: VMPodScrape @@ -44,3 +45,4 @@ spec: matchLabels: app.kubernetes.io/component: linstor-controller {{- end }} +{{- end }} diff --git a/packages/system/linstor/templates/satellites-cozy.yaml b/packages/system/linstor/templates/satellites-cozy.yaml index bb6240128..5f35e9088 100644 --- a/packages/system/linstor/templates/satellites-cozy.yaml +++ b/packages/system/linstor/templates/satellites-cozy.yaml @@ -1,3 +1,12 @@ +{{- /* Rendered under both backends. piraeus-operator creates a + linstor-satellite pod on every node it selects for linstor-csi-node, + external mode included, and LinstorCluster has no switch that keeps + the satellites and drops nothing else. Without this configuration the + pod falls back to the operator's default image by tag, without TLS, + limits or host networking. Host networking matters most under + blockstor: the operator registers each node at its satellite pod's + address, and on the pod network that address is one DRBD peers cannot + reach. */ -}} apiVersion: piraeus.io/v1 kind: LinstorSatelliteConfiguration metadata: diff --git a/packages/system/linstor/templates/satellites-plunger.yaml b/packages/system/linstor/templates/satellites-plunger.yaml index 78109e167..8a0fc603a 100644 --- a/packages/system/linstor/templates/satellites-plunger.yaml +++ b/packages/system/linstor/templates/satellites-plunger.yaml @@ -1,3 +1,4 @@ +{{- if eq .Values.backend "linstor" }} apiVersion: piraeus.io/v1 kind: LinstorSatelliteConfiguration metadata: @@ -94,3 +95,4 @@ spec: configMap: name: linstor-plunger defaultMode: 0755 +{{- end }} diff --git a/packages/system/linstor/templates/satellites-talos.yaml b/packages/system/linstor/templates/satellites-talos.yaml index 6a986c95e..ea3f5cfc6 100644 --- a/packages/system/linstor/templates/satellites-talos.yaml +++ b/packages/system/linstor/templates/satellites-talos.yaml @@ -1,10 +1,23 @@ {{- if .Values.talos.enabled }} +{{- /* Gated on the OS, never on .Values.backend: piraeus creates the + linstor-satellite. DaemonSets under blockstor too, and on Talos + they wedge at Init:0/3 on the run-systemd-system hostPath without + this patch. On generic Linux the patch must not apply at all: it + drops drbd-module-loader, the only thing that loads DRBD there. */ -}} {{- $shutdown := .Values.talos.gracefulShutdown | default dict }} {{- $enabled := dig "enabled" false $shutdown }} {{- if kindIs "invalid" $enabled }}{{- $enabled = false }}{{- end }} {{- if not (kindIs "bool" $enabled) }} {{- fail "linstor: talos.gracefulShutdown.enabled must be a boolean" }} {{- end }} +{{- /* The hook runs `drbdsetup down` on every idle Secondary resource in the + host kernel when the piraeus satellite stops. Under blockstor those + resources are blockstor-satellite's, so a rollout of the idle piraeus + pod would take healthy replicas down. Refused rather than dropped, so + the setting does not look like it took effect. */ -}} +{{- if and $enabled (eq .Values.backend "blockstor") }} +{{- fail "linstor: talos.gracefulShutdown.enabled is not supported with backend blockstor: its hook would tear down blockstor's DRBD resources" }} +{{- end }} apiVersion: piraeus.io/v1 kind: LinstorSatelliteConfiguration metadata: diff --git a/packages/system/linstor/tests/apiserver_tls_test.yaml b/packages/system/linstor/tests/apiserver_tls_test.yaml new file mode 100644 index 000000000..5e4fb7adb --- /dev/null +++ b/packages/system/linstor/tests/apiserver_tls_test.yaml @@ -0,0 +1,58 @@ +suite: blockstor apiserver PKI (blockstor backend) + +# The operator's own API client is wired by NAME, from +# LinstorCluster.spec.apiTLS.clientSecretName, and piraeus-operator does not +# create that secret in external mode — it only reads it. So the name has to +# match a Certificate this chart issues from the blockstor CA, and nothing in +# the cluster tells you when it stops matching: the operator falls back on +# whatever secret carries that name, validates against the ca.crt in it, and +# the probe fails at runtime with "certificate signed by unknown authority" +# while every HelmRelease still reports Ready. +# +# That is exactly how the bug shipped. The default name, linstor-client-tls, +# is a real secret on any cluster switched over from the LINSTOR backend — +# issued from linstor-api-ca, which cannot verify the blockstor serving cert. + +templates: + - templates/blockstor-apiserver-tls.yaml + +set: + backend: blockstor + +tests: + - it: "issues the client certificate the operator is pointed at, from the blockstor CA" + template: templates/blockstor-apiserver-tls.yaml + documentIndex: 3 + asserts: + - isKind: + of: Certificate + - equal: + path: metadata.name + value: blockstor-apiserver-client + # The name cluster.yaml hands the operator. A rename on either side + # leaves the operator reading some other secret's CA. + - equal: + path: spec.secretName + value: blockstor-apiserver-client-tls + - equal: + path: spec.issuerRef.name + value: blockstor-api-ca + # Without client auth the :3371 listener, which is + # RequireAndVerifyClientCert, rejects the operator's connection even + # once it trusts the CA. + - contains: + path: spec.usages + content: client auth + + - it: "serves from the same CA the client certificate validates against" + template: templates/blockstor-apiserver-tls.yaml + documentIndex: 2 + asserts: + - isKind: + of: Certificate + - equal: + path: metadata.name + value: blockstor-apiserver-server + - equal: + path: spec.issuerRef.name + value: blockstor-api-ca diff --git a/packages/system/linstor/tests/backend_test.yaml b/packages/system/linstor/tests/backend_test.yaml new file mode 100644 index 000000000..0b70e69f3 --- /dev/null +++ b/packages/system/linstor/tests/backend_test.yaml @@ -0,0 +1,178 @@ +suite: storage backend selection + +# The backend is opt-in and defaults to LINSTOR. That default is what every +# existing cluster runs, so a change that quietly flipped it would swap the +# storage control plane under live data on the next reconcile. These tests +# pin the default and prove each backend renders only its own control plane. + +release: + name: linstor + namespace: cozy-linstor + +tests: + - it: "defaults to the LINSTOR backend" + templates: + - templates/cluster.yaml + asserts: + - isKind: + of: LinstorCluster + # The operator runs its own in-cluster controller: no external URL. + - notExists: + path: spec.externalController + + - it: "renders no blockstor control plane by default" + templates: + - templates/blockstor-controller.yaml + - templates/blockstor-apiserver.yaml + - templates/blockstor-satellite.yaml + asserts: + - hasDocuments: + count: 0 + + - it: "renders no blockstor CRDs by default" + templates: + - templates/crds/crds.yaml + asserts: + - hasDocuments: + count: 0 + + # piraeus still runs a linstor-satellite pod per node in external mode, so + # what it runs is pinned the same way under either backend: cozystack's + # image, TLS, limits and host networking. + - it: "pins the piraeus satellite under the blockstor backend" + set: + backend: blockstor + piraeusServer.image.repository: example.org/piraeus-server + piraeusServer.image.tag: pinned + templates: + - templates/satellites-cozy.yaml + asserts: + - hasDocuments: + count: 1 + - equal: + path: spec.podTemplate.spec.hostNetwork + value: true + - equal: + path: spec.internalTLS.certManager.name + value: linstor-internal-ca + - equal: + path: spec.podTemplate.spec.containers[0].image + value: example.org/piraeus-server:pinned + + - it: "issues the satellite's internal CA under the blockstor backend" + set: + backend: blockstor + templates: + - templates/linstor-internal-tls.yaml + asserts: + - hasDocuments: + count: 2 + - equal: + path: kind + value: Issuer + documentIndex: 1 + + # The plunger runs drbdadm against the node's DRBD resources on its own + # schedule. Under blockstor those belong to blockstor-satellite alone, so the + # plunger stays with the LINSTOR backend. + - it: "renders no plunger on the blockstor backend" + set: + backend: blockstor + templates: + - templates/satellites-plunger.yaml + asserts: + - hasDocuments: + count: 0 + + # The Talos patch is NOT one of those. piraeus-operator still creates + # linstor-satellite. DaemonSets in external mode, and on Talos + # they wedge at Init:0/3 without it — the hostPath /run/systemd/system + # does not exist there — which then churns linstor-csi-node and blocks + # every PVC attach while every HelmRelease still reports Ready. + - it: "patches the satellite for Talos under both backends" + set: + backend: blockstor + templates: + - templates/satellites-talos.yaml + asserts: + - hasDocuments: + count: 1 + - isKind: + of: LinstorSatelliteConfiguration + - equal: + path: metadata.name + value: cozystack-talos + + - it: "patches the satellite for Talos on the LINSTOR backend too" + set: + backend: linstor + templates: + - templates/satellites-talos.yaml + asserts: + - hasDocuments: + count: 1 + - equal: + path: metadata.name + value: cozystack-talos + + - it: "ships the blockstor CRDs on the blockstor backend" + set: + backend: blockstor + templates: + - templates/crds/crds.yaml + asserts: + - hasDocuments: + count: 8 + - isKind: + of: CustomResourceDefinition + + # A value arriving outside the platform chart's own check, a hand-set + # component value for one, rendered some objects of each backend and + # exited 0. + - it: fails the render on an unrecognised backend + templates: + - templates/backend-guard.yaml + set: + backend: blokstor + asserts: + - failedTemplate: + errorMessage: 'linstor: backend must be "linstor" or "blockstor", got "blokstor"' + + - it: accepts the blockstor backend + templates: + - templates/backend-guard.yaml + set: + backend: blockstor + asserts: + - hasDocuments: + count: 0 + + # drbd-reactor in the piraeus satellite pod reads DRBD state from the kernel, + # which is the same under either control plane, so its metrics and the alerts + # built on them stay. The controller scrape targets the Java controller, which + # blockstor does not run. + - it: "keeps scraping the satellites under the blockstor backend" + set: + backend: blockstor + capabilities: + apiVersions: + - operator.victoriametrics.com/v1beta1 + templates: + - templates/podscrape.yaml + asserts: + - hasDocuments: + count: 1 + - equal: + path: metadata.name + value: linstor-satellite + + # The guard is the only check that reaches the default value through the + # whole chart; every other default test renders named templates. + - it: accepts the default backend + templates: + - templates/backend-guard.yaml + set: + backend: linstor + asserts: + - hasDocuments: + count: 0 diff --git a/packages/system/linstor/tests/blockstor_cluster_test.yaml b/packages/system/linstor/tests/blockstor_cluster_test.yaml new file mode 100644 index 000000000..47dcc6089 --- /dev/null +++ b/packages/system/linstor/tests/blockstor_cluster_test.yaml @@ -0,0 +1,103 @@ +suite: LinstorCluster external mode (blockstor backend) + +# Pins the LinstorCluster surface this package renders on the BLOCKSTOR +# backend. piraeus-operator runs in EXTERNAL mode there: it deploys no +# in-cluster linstor-controller and instead points linstor-csi at the blockstor +# apiserver (spec.externalController.url), issuing the CSI client certs from the +# blockstor-api-ca Issuer (spec.apiTLS). Controller-level DRBD tuning is carried +# in spec.properties, which the operator applies to the external controller over +# the LINSTOR REST API. There must be NO spec.controller block (no in-cluster +# controller / plunger sidecar) in this mode. + +templates: + - templates/cluster.yaml + +# Blockstor is opt-in. Without this the suite renders the LINSTOR backend, +# whose LinstorCluster is a different shape entirely. +set: + backend: blockstor + +tests: + - it: "renders a LinstorCluster pointed at the external blockstor apiserver" + asserts: + - isKind: + of: LinstorCluster + - equal: + path: spec.externalController.url + value: https://blockstor-apiserver.cozy-linstor.svc:3371 + - equal: + path: spec.apiTLS.certManager.name + value: blockstor-api-ca + - equal: + path: spec.apiTLS.certManager.kind + value: Issuer + # The operator's OWN client, the one that probes + # /v1/controller/version, is not provisioned by certManager in + # external mode — piraeus-operator emits no controller-side + # Certificate there. Left at its default it looks for + # linstor-client-tls, finds nothing, and cannot verify a serving + # cert signed by blockstor-api-ca; the probe fails and every + # satellite reconcile stops behind it. + - equal: + path: spec.apiTLS.clientSecretName + value: blockstor-apiserver-client-tls + + - it: "runs in external mode — no in-cluster linstor-controller / plunger" + asserts: + - notExists: + path: spec.controller + - notExists: + path: spec.internalTLS + + - it: "carries controller-level DRBD Net tuning as properties" + asserts: + - contains: + path: spec.properties + content: + name: DrbdOptions/Net/verify-alg + value: "crc32c" + - contains: + path: spec.properties + content: + name: DrbdOptions/Net/timeout + value: "100" + + - it: "auto-diskful properties are values-driven" + asserts: + - contains: + path: spec.properties + content: + name: DrbdOptions/auto-diskful + value: "30" + - contains: + path: spec.properties + content: + name: DrbdOptions/auto-diskful-allow-cleanup + value: "true" + + - it: "auto-diskful properties are dropped when disabled" + set: + linstor: + autoDiskful: + enabled: false + asserts: + - notContains: + path: spec.properties + content: + name: DrbdOptions/auto-diskful + value: "30" + # Net tuning is unconditional and stays regardless of auto-diskful. + - contains: + path: spec.properties + content: + name: DrbdOptions/Net/verify-alg + value: "crc32c" + + - it: "the reused linstor-csi image pin is preserved on the CSI podTemplates" + asserts: + - matchRegex: + path: spec.csiController.podTemplate.spec.containers[0].image + pattern: "^ghcr\\.io/cozystack/cozystack/linstor-csi:" + - matchRegex: + path: spec.csiNode.podTemplate.spec.containers[0].image + pattern: "^ghcr\\.io/cozystack/cozystack/linstor-csi:" diff --git a/packages/system/linstor/tests/blockstor_controller_events_test.yaml b/packages/system/linstor/tests/blockstor_controller_events_test.yaml new file mode 100644 index 000000000..560ce64f6 --- /dev/null +++ b/packages/system/linstor/tests/blockstor_controller_events_test.yaml @@ -0,0 +1,22 @@ +# The controller records events through events.k8s.io; without the grant +# its warnings (a definition short of its group's layer stack) are dropped. +suite: blockstor controller events +templates: + - templates/blockstor-controller.yaml +release: + name: linstor + namespace: cozy-linstor +set: + backend: blockstor +tests: + - it: lets the controller record events.k8s.io events + documentSelector: + path: kind + value: ClusterRole + asserts: + - contains: + path: rules + content: + apiGroups: [events.k8s.io] + resources: [events] + verbs: [create, patch] diff --git a/packages/system/linstor/tests/blockstor_images_test.yaml b/packages/system/linstor/tests/blockstor_images_test.yaml new file mode 100644 index 000000000..8e31355c3 --- /dev/null +++ b/packages/system/linstor/tests/blockstor_images_test.yaml @@ -0,0 +1,53 @@ +suite: cozy-linstor blockstor image pins +release: + name: linstor + namespace: cozy-linstor +# Blockstor is opt-in; without this the suite renders the LINSTOR backend +# and every blockstor template is empty. +set: + backend: blockstor + +# Every image this package ships must be pinned by digest (tag@sha256:...) so a +# moving upstream tag can never silently change what runs. blockstor-* are the +# published ghcr.io/cozystack/blockstor-* release images; linstor-csi is reused +# unchanged and pinned on the LinstorCluster CSI podTemplates. +tests: + - it: pins blockstor-apiserver by digest + template: templates/blockstor-apiserver.yaml + documentSelector: + path: kind + value: Deployment + asserts: + - matchRegex: + path: spec.template.spec.containers[0].image + pattern: '^ghcr\.io/cozystack/blockstor-apiserver:[^@]+@sha256:[0-9a-f]{64}$' + + - it: pins blockstor-controller by digest + template: templates/blockstor-controller.yaml + documentSelector: + path: kind + value: Deployment + asserts: + - matchRegex: + path: spec.template.spec.containers[0].image + pattern: '^ghcr\.io/cozystack/blockstor-controller:[^@]+@sha256:[0-9a-f]{64}$' + + - it: pins blockstor-satellite by digest + template: templates/blockstor-satellite.yaml + documentSelector: + path: kind + value: DaemonSet + asserts: + - matchRegex: + path: spec.template.spec.containers[0].image + pattern: '^ghcr\.io/cozystack/blockstor-satellite:[^@]+@sha256:[0-9a-f]{64}$' + + - it: pins the reused linstor-csi by digest on the LinstorCluster + template: templates/cluster.yaml + documentSelector: + path: kind + value: LinstorCluster + asserts: + - matchRegex: + path: spec.csiController.podTemplate.spec.containers[0].image + pattern: '^ghcr\.io/cozystack/cozystack/linstor-csi:[^@]+@sha256:[0-9a-f]{64}$' diff --git a/packages/system/linstor/tests/blockstor_names_test.yaml b/packages/system/linstor/tests/blockstor_names_test.yaml new file mode 100644 index 000000000..ad61cc823 --- /dev/null +++ b/packages/system/linstor/tests/blockstor_names_test.yaml @@ -0,0 +1,61 @@ +# piraeus-operator creates and owns Service/linstor-controller and +# Certificate/linstor-client-tls. Rendering either name from this chart puts +# it in Helm's create set on a switch to blockstor, Helm refuses to adopt an +# object it does not own, and the upgrade aborts before anything applies, the +# LinstorCluster change that would prune piraeus's copies included. +suite: the blockstor backend renders no name piraeus-operator owns +templates: + - templates/*.yaml +release: + name: linstor + namespace: cozy-linstor +set: + backend: blockstor +tests: + - it: renders no linstor-controller Service + documentSelector: + path: metadata.name + value: linstor-controller + skipEmptyTemplates: true + asserts: + - notEqual: + path: kind + value: Service + + - it: renders no linstor-client-tls Certificate + documentSelector: + path: metadata.name + value: linstor-client-tls + skipEmptyTemplates: true + asserts: + - notEqual: + path: kind + value: Certificate + + # The apiserver Service is the mTLS listener only. The plain-HTTP listener + # on :3370 is for kubectl port-forward to a pod and must not be reachable + # through the Service. + - it: exposes only the mutual-TLS port on the apiserver Service + template: templates/blockstor-apiserver.yaml + documentSelector: + path: kind + value: Service + asserts: + - equal: + path: spec.ports + value: + - {name: rest-tls, port: 3371, targetPort: 3371} + + - it: serves the apiserver certificate for its own Service only + template: templates/blockstor-apiserver-tls.yaml + documentSelector: + path: metadata.name + value: blockstor-apiserver-server + asserts: + - equal: + path: spec.dnsNames + value: + - blockstor-apiserver + - blockstor-apiserver.cozy-linstor + - blockstor-apiserver.cozy-linstor.svc + - blockstor-apiserver.cozy-linstor.svc.cluster.local diff --git a/packages/system/linstor/tests/blockstor_rbac_test.yaml b/packages/system/linstor/tests/blockstor_rbac_test.yaml new file mode 100644 index 000000000..8c21efa87 --- /dev/null +++ b/packages/system/linstor/tests/blockstor_rbac_test.yaml @@ -0,0 +1,71 @@ +# The apiserver writes exactly one Secret, the encryption passphrase, and +# always in its own namespace. A cluster-wide write grant would reach every +# tenant's admin kubeconfig and every managed-service credential. +suite: blockstor apiserver Secret access +templates: + - templates/blockstor-apiserver.yaml +release: + name: linstor + namespace: cozy-linstor +set: + backend: blockstor +tests: + - it: grants Secrets only read access cluster-wide + documentSelector: + path: kind + value: ClusterRole + asserts: + - contains: + path: rules + content: + apiGroups: [""] + resources: [secrets] + verbs: [get, list, watch] + - notContains: + path: rules + content: + apiGroups: [""] + resources: [secrets] + verbs: [get, list, watch, create, update, patch] + + - it: grants Secret writes in the release namespace only + documentSelector: + path: kind + value: Role + asserts: + - equal: + path: metadata.namespace + value: cozy-linstor + - contains: + path: rules + content: + apiGroups: [""] + resources: [secrets] + verbs: [create, update, patch] + + - it: binds the namespaced Role to the apiserver ServiceAccount + documentSelector: + path: kind + value: RoleBinding + asserts: + - equal: + path: roleRef.name + value: blockstor-apiserver-secrets + - contains: + path: subjects + content: + kind: ServiceAccount + name: blockstor-apiserver + namespace: cozy-linstor + + - it: names the blockstor kinds instead of granting the whole group + documentSelector: + path: kind + value: ClusterRole + asserts: + - notContains: + path: rules + content: + apiGroups: [blockstor.cozystack.io] + resources: ["*"] + verbs: [get, list, watch, create, update, patch, delete] diff --git a/packages/system/linstor/tests/blockstor_workloads_test.yaml b/packages/system/linstor/tests/blockstor_workloads_test.yaml new file mode 100644 index 000000000..2a97883e2 --- /dev/null +++ b/packages/system/linstor/tests/blockstor_workloads_test.yaml @@ -0,0 +1,213 @@ +suite: blockstor workloads +release: + name: linstor + namespace: cozy-linstor +set: + backend: blockstor +tests: + # The plain-HTTP listener authenticates nobody. On the pod network any pod + # that can route to the apiserver would get the whole LINSTOR API, deletes + # included, around the mTLS on :3371. + - it: binds the apiserver's plain-HTTP listener to loopback + template: templates/blockstor-apiserver.yaml + documentSelector: + path: kind + value: Deployment + asserts: + - contains: + path: spec.template.spec.containers[0].args + content: --rest-bind-address=127.0.0.1:3370 + - notContains: + path: spec.template.spec.containers[0].ports + content: {name: rest-debug, containerPort: 3370} + + # The controller runs without leader election, so two pods side by side + # would both reconcile the same objects. + - it: never runs two controllers during a rollout + template: templates/blockstor-controller.yaml + documentSelector: + path: kind + value: Deployment + asserts: + - equal: + path: spec.strategy.type + value: Recreate + - equal: + path: spec.replicas + value: 1 + + - it: lets the satellite delete nothing but PhysicalDevices + template: templates/blockstor-satellite.yaml + documentSelector: + path: kind + value: ClusterRole + asserts: + - contains: + path: rules + content: + apiGroups: [blockstor.cozystack.io] + resources: [physicaldevices] + verbs: [create, update, patch, delete] + - contains: + path: rules + content: + apiGroups: [blockstor.cozystack.io] + resources: [nodes, resources, snapshots, storagepools] + verbs: [update, patch] + - lengthEqual: + path: rules + count: 6 + + - it: gives the satellite no Secret or Lease access at cluster scope + template: templates/blockstor-satellite.yaml + documentSelector: + path: kind + value: ClusterRole + asserts: + - notContains: + path: rules + content: + apiGroups: [""] + resources: [secrets] + verbs: [get, list, watch] + - notContains: + path: rules + content: + apiGroups: [coordination.k8s.io] + resources: [leases] + verbs: [get, list, watch, create, update, patch, delete] + + - it: lets the satellite read Secrets in its own namespace only + template: templates/blockstor-satellite.yaml + documentSelector: + path: kind + value: Role + asserts: + - equal: + path: metadata.namespace + value: cozy-linstor + - equal: + path: rules + value: + - apiGroups: [""] + resources: [secrets] + verbs: [get] + + - it: binds the satellite's Secret Role to its ServiceAccount + template: templates/blockstor-satellite.yaml + documentSelector: + path: kind + value: RoleBinding + asserts: + - equal: + path: roleRef.name + value: blockstor-satellite-secrets + - equal: + path: subjects[0].name + value: blockstor-satellite + + - it: gives the controller no Lease access + template: templates/blockstor-controller.yaml + documentSelector: + path: kind + value: ClusterRole + asserts: + - notContains: + path: rules + content: + apiGroups: [coordination.k8s.io] + resources: [leases] + verbs: [get, list, watch, create, update, patch, delete] + + - it: closes the satellite's unauthenticated ports to the world + template: templates/blockstor-satellite.yaml + documentSelector: + path: kind + value: CiliumClusterwideNetworkPolicy + asserts: + - equal: + path: spec.ingressDeny[0].fromEntities + value: [world] + - equal: + path: spec.ingressDeny[0].toPorts[0].ports + value: + - port: "9100" + - port: "9101" + - port: "8080" + + # A kind added to the group later must not be granted by omission, so the + # roles are pinned whole: a wildcard or a new kind shows up as a diff here. + - it: pins the controller ClusterRole rule by rule + template: templates/blockstor-controller.yaml + documentSelector: + path: kind + value: ClusterRole + asserts: + - equal: + path: rules + value: + - apiGroups: [''] + resources: [events] + verbs: [create, patch] + - apiGroups: [events.k8s.io] + resources: [events] + verbs: [create, patch] + - apiGroups: [''] + resources: [nodes] + verbs: [get, list, watch] + - apiGroups: [blockstor.cozystack.io] + resources: [controllerconfigs] + verbs: [get, list, watch] + - apiGroups: [blockstor.cozystack.io] + resources: [nodes, resourcedefinitions, resourcegroups, resources, snapshots, storagepools] + verbs: [get, list, watch, create, update, patch, delete] + - apiGroups: [blockstor.cozystack.io] + resources: [nodes/finalizers, resourcedefinitions/finalizers, resourcegroups/finalizers, + resources/finalizers, snapshots/finalizers, storagepools/finalizers] + verbs: [update] + - apiGroups: [blockstor.cozystack.io] + resources: [nodes/status, resourcedefinitions/status, resourcegroups/status, resources/status, + snapshots/status, storagepools/status] + verbs: [get, update, patch] + + - it: pins the satellite ClusterRole rule by rule + template: templates/blockstor-satellite.yaml + documentSelector: + path: kind + value: ClusterRole + asserts: + - equal: + path: rules + value: + - apiGroups: [''] + resources: [events] + verbs: [create, patch] + - apiGroups: [''] + resources: [nodes] + verbs: [get, list, watch] + - apiGroups: [blockstor.cozystack.io] + resources: [controllerconfigs, nodes, physicaldevices, resourcedefinitions, resourcegroups, + resources, snapshots, storagepools] + verbs: [get, list, watch] + - apiGroups: [blockstor.cozystack.io] + resources: [physicaldevices] + verbs: [create, update, patch, delete] + - apiGroups: [blockstor.cozystack.io] + resources: [nodes, resources, snapshots, storagepools] + verbs: [update, patch] + - apiGroups: [blockstor.cozystack.io] + resources: [nodes/status, physicaldevices/status, resources/status, snapshots/status, + storagepools/status, nodes/finalizers, physicaldevices/finalizers, resources/finalizers, + snapshots/finalizers, storagepools/finalizers] + verbs: [get, update, patch] + + # global_common.conf is a subPath mount, which is never refreshed in place. + - it: rolls the satellites when global_common.conf changes + template: templates/blockstor-satellite.yaml + documentSelector: + path: kind + value: DaemonSet + asserts: + - matchRegex: + path: spec.template.metadata.annotations["checksum/drbd-conf"] + pattern: '^[0-9a-f]{64}$' diff --git a/packages/system/linstor/tests/crds_test.yaml b/packages/system/linstor/tests/crds_test.yaml new file mode 100644 index 000000000..22f727cd0 --- /dev/null +++ b/packages/system/linstor/tests/crds_test.yaml @@ -0,0 +1,31 @@ +# Blockstor keeps its entire control-plane state in objects of these CRDs. +# They render from templates/, so an upgrade that stops rendering them, a +# switch of the backend back to linstor, would delete them and every object +# with them. helm.sh/resource-policy: keep is what stops that. +# +# The kind assertion catches a non-CRD document carrying the annotation, +# which the annotation assertion alone would accept. +suite: blockstor CRDs survive a switch back to linstor +templates: + - templates/crds/crds.yaml +tests: + - it: annotates every CRD the blockstor backend renders + set: + backend: blockstor + asserts: + - hasDocuments: + count: 8 + - equal: + path: kind + value: CustomResourceDefinition + - equal: + path: metadata.annotations["helm.sh/resource-policy"] + value: keep + - equal: + path: metadata.annotations["controller-gen.kubebuilder.io/version"] + value: v0.20.1 + + - it: renders no CRD under the linstor backend + asserts: + - hasDocuments: + count: 0 diff --git a/packages/system/linstor/tests/csi-topology_test.yaml b/packages/system/linstor/tests/csi-topology_test.yaml index 1b346a93e..de357db97 100644 --- a/packages/system/linstor/tests/csi-topology_test.yaml +++ b/packages/system/linstor/tests/csi-topology_test.yaml @@ -62,3 +62,18 @@ tests: - equal: path: spec.csiController.podTemplate.spec.containers[1].name value: csi-snapshotter + + # The LinstorCluster is one document for both backends, so the CSI controller + # half is shared and blockstor gets the same constraint. linstor-csi issues the + # same CreateVolume either way; only the API behind it differs. + - it: the provisioner is constrained under the blockstor backend too + template: templates/cluster.yaml + set: + backend: blockstor + asserts: + - contains: + path: spec.csiController.podTemplate.spec.containers[?(@.name=="csi-provisioner")].args + content: --strict-topology + - lengthEqual: + path: spec.csiController.podTemplate.spec.containers[?(@.name=="csi-provisioner")].args + count: 12 diff --git a/packages/system/linstor/tests/talos_gate_test.yaml b/packages/system/linstor/tests/talos_gate_test.yaml new file mode 100644 index 000000000..69d24db31 --- /dev/null +++ b/packages/system/linstor/tests/talos_gate_test.yaml @@ -0,0 +1,35 @@ +suite: Talos satellite patch is gated on the OS, not the backend +templates: + - templates/satellites-talos.yaml + +# The patch drops drbd-module-loader, which is what loads DRBD on a node +# whose kernel does not ship it as a Talos extension. On generic Linux it +# must not render at all. On Talos it renders under both backends, since +# piraeus creates the linstor-satellite DaemonSets under blockstor too. +tests: + - it: renders nothing on generic Linux under the linstor backend + set: + talos.enabled: false + backend: linstor + asserts: + - hasDocuments: + count: 0 + + - it: renders nothing on generic Linux under the blockstor backend + set: + talos.enabled: false + backend: blockstor + asserts: + - hasDocuments: + count: 0 + + - it: renders on Talos under the blockstor backend + set: + talos.enabled: true + backend: blockstor + asserts: + - isKind: + of: LinstorSatelliteConfiguration + - equal: + path: metadata.name + value: cozystack-talos diff --git a/packages/system/linstor/tests/talos_shutdown_test.yaml b/packages/system/linstor/tests/talos_shutdown_test.yaml index a2de6ab2c..a454f3b7a 100644 --- a/packages/system/linstor/tests/talos_shutdown_test.yaml +++ b/packages/system/linstor/tests/talos_shutdown_test.yaml @@ -78,3 +78,22 @@ tests: - matchRegex: path: spec.patches[0].patch pattern: 'name: drbd-shutdown-guard' + + # The hook downs idle Secondary resources in the shared host kernel, which + # under blockstor belong to blockstor-satellite. + - it: refuses the hook under the blockstor backend + set: + backend: blockstor + talos.gracefulShutdown.enabled: true + asserts: + - failedTemplate: + errorMessage: "linstor: talos.gracefulShutdown.enabled is not supported with backend blockstor: its hook would tear down blockstor's DRBD resources" + + - it: keeps the Talos patch under blockstor when the hook is off + set: + backend: blockstor + asserts: + - notExists: + path: spec.podTemplate + - exists: + path: spec.patches diff --git a/packages/system/linstor/values.yaml b/packages/system/linstor/values.yaml index 4ee1429ec..a14daaa6c 100644 --- a/packages/system/linstor/values.yaml +++ b/packages/system/linstor/values.yaml @@ -1,7 +1,41 @@ +# Which storage control plane this package deploys. +# +# linstor — the Java linstor-controller driven by piraeus-operator +# (the default, and what every existing cluster runs). +# blockstor — blockstor's controller/apiserver/satellite, with +# piraeus-operator in EXTERNAL mode so it only drives +# linstor-csi. EXPERIMENTAL. +# +# Both backends serve the same CSI wire shape through the same +# linstor-csi build, so the StorageClasses (provisioner +# linstor.csi.linbit.com) are the same under either. +# +# blockstor is for new clusters only. Switching a cluster that already +# holds LINSTOR volumes is not supported: the pinned blockstor release +# cannot adopt existing DRBD resources safely, and this chart does not +# convert LINSTOR's database into blockstor's. +backend: linstor + piraeusServer: image: repository: ghcr.io/cozystack/cozystack/piraeus-server tag: v1.6.0@sha256:70ddd1a66fbc1ea58078f4645fc572ab8e2e189dbb4d9a5f9ca43d5663106483 + +# Blockstor images are component-versioned: they are released from the +# blockstor repository and carry ITS version, so a cozystack release +# must not retag them to the cozystack version. +blockstorController: + image: + repository: ghcr.io/cozystack/blockstor-controller + tag: 0.1.17@sha256:19b5733565e4bbe9510eecae8d47a181e72e07009b3d565848e8ccf1cd9393e8 +blockstorApiserver: + image: + repository: ghcr.io/cozystack/blockstor-apiserver + tag: 0.1.17@sha256:102cf8c8d431f3b6714bca53752327ae8bb793b2d5ebed3aae47d51a85805f26 +blockstorSatellite: + image: + repository: ghcr.io/cozystack/blockstor-satellite + tag: 0.1.17@sha256:8bd15bca47f33464eaf489884c33fd50ef2574a0ad856ab5ab9b921186a98bea # Talos-specific workarounds (disable for generic Linux like Ubuntu/Debian) talos: enabled: true @@ -59,6 +93,9 @@ linstor: enabled: true minutes: 30 allowCleanup: true +# linstor-csi is REUSED unchanged — blockstor serves the same CSI +# wire-shape, so the existing StorageClasses (provisioner +# linstor.csi.linbit.com) keep working. linstorCSI: ## Constrain provisioning to the node the scheduler actually picked. ##