Files
cozystack/packages/core/platform
Andrei Kvapil 684ef5464d feat(linstor): migrate an existing LINSTOR cluster to blockstor (#5466)
Stacked on #2942, and based on its branch, so the diff shows only the
migration.

<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
- Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
- Scopes are not an exhaustive list; pick the most specific scope for
the change and extend the list when a genuinely new area appears.
Examples:
- System components: dashboard, platform, operator, cilium, kube-ovn,
linstor, fluxcd, cluster-api
- Managed apps: postgres, mariadb, redis, kafka, clickhouse,
virtual-machine, kubernetes
- Development and maintenance: api, hack, tests, ci, docs, maintenance
- Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or
add a `BREAKING CHANGE:` footer
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats,
even if it's still a draft.
- Add the label `kind/backport` if it's a bugfix that needs to be
backported to a previous version.
-->

## What this PR does

#2942 adds blockstor as a backend for new clusters. This PR adds the way
to move a cluster that already holds LINSTOR volumes onto it, following
blockstor's `linstor-migrate` runbook: freeze CSI and stop LINSTOR,
deploy blockstor, apply the converted manifests, wait for adoption, and
repoint CSI last. Setting `storage.backend: blockstor` alone does all of
that in one step: piraeus-operator goes external, deletes
linstor-controller and repoints linstor-csi before a single volume is
adopted.

- `storage.blockstorMigration` on the platform, passed to the linstor
chart, splits the switch into the runbook's steps. With `hold` blockstor
is deployed with its controller held at zero replicas while the
converted manifests are applied. With `adopt` the controller runs and
adopts the volumes. In both steps every piraeus object renders exactly
as under `backend: linstor`, so an operator started again still finds
LINSTOR's shape. Removing the value moves `LinstorCluster` to external
mode with piraeus-operator running. The platform checks the value, so a
typo or a step left over after switching back to linstor fails the
platform render rather than the linstor release.
- linstor-scheduler and linstor-gui stay on LINSTOR through `hold` and
`adopt` and move to blockstor-apiserver in the same step as linstor-csi.
Before that blockstor serves nothing, or Resources it has not adopted
yet, and the scheduler extender panics on a Resource without volumes.
- piraeus-operator keeps running through the migration, as in
blockstor's runbook. Given LINSTOR's shape during `hold` and `adopt` it
has nothing to change, it does not own the replica counts the freeze
sets to zero (the `LinstorCluster` sets none), and its webhooks keep
serving, so the release passes them. Earlier revisions stopped it and
relaxed its webhooks from hook Jobs; those are gone.
- The post-install/upgrade hook from #2942 that points
`ControllerConfig/default` at the passphrase Secret now merge-patches
that one field, and creates the object only when it is missing. It used
a server-side `kubectl apply`, and on an object last written by a
client-side `kubectl apply` kubectl first hands every client-side-owned
field to the applying manager and re-sends the apply, which then removed
the migrated cluster-wide DRBD options (timeouts, `verify-alg`,
`on-no-data-accessible` and the rest) that the satellites apply live.
The README applies the converted manifests server-side as well, so a
server-side apply run by hand later cannot take them over either.
- `packages/system/linstor/README.md` marks the migration experimental
and gives the order step by step, with the way back from every step and
the two steps after which there is none (repointing CSI and unfreezing
it), the replica count piraeus-operator does not restore, how to check
the master key ID while the controller is held at zero, and that no step
is run together with a platform upgrade. The values files and the
backend-switch guard now point at that path instead of saying the
platform does not move such a cluster.

### Testing

A live run on blockstor v0.4.0 with the operator kept running, on the
revision before the last README-only change: a three-node cluster with
LINSTOR volumes (3 and 2 replicas with a tiebreaker, local, LUKS, a
detached volume and a CSI snapshot) taken through every README step with
nothing done by hand beyond them:

- adoption without a resync, and `drbdsetup show` on every node
identical to the capture before the freeze, the cluster-wide DRBD
options included;
- data intact in place and after moving volumes to other nodes through
blockstor's CSI, restore from the pre-migration snapshot, new PVCs,
online resize of adopted volumes;
- linstor-scheduler and linstor-gui on blockstor-apiserver after the
last step without a manual reconcile, after one failed render each;
- piraeus webhooks left at `Fail` and untouched throughout;
- the way back from `hold` and from `adopt` (on two nodes): DRBD
unchanged, no resync, data intact, LINSTOR serving again. That run found
the restarted linstor-controller locked; the README now says to enter
the passphrase.

Earlier runs on alpha builds covered the node-by-node satellite rollout
with `OnDelete`.

Unit tests:

- `make test` in `packages/system/linstor`: helm-unittest 145/145 in 21
suites, Python 26/26. `test_controllerconfig_hook.py` runs the
ControllerConfig script against a client-side-applied object carrying
DRBD options.
- `helm unittest` in `packages/core/platform`: 403/403.
- The new cases fail when a migration step changes a piraeus object,
when the consumer switch follows the backend alone, and when the
ControllerConfig hook goes back to a server-side apply.

### Not tested

- The way back from steps 3 and 4 followed by a second migration
attempt; the README's guidance for leftover blockstor objects is from
the code, not from a run.
- The migration in CI: no lane runs DRBD, so none can start from
populated LINSTOR state.

### Known limitations

- A Cozystack upgrade during the migration can bring a new
piraeus-operator or linstor-csi, which the running operator rolls out
mid-migration. The README says to run each step as its own change.
- There is no way back once `blockstorMigration` is removed.
- `linstor-csi-controller`'s replica count comes back only by hand, on
the way forward and on the way back.

### Screenshots

N/A, no UI change.

### Downstream repositories

<!--
Cozystack is upstream for repositories that are NOT kept in sync with it
automatically, and nothing in CI compares the two sides, so a change
here can break them silently.

Which change forces what, and which file to touch, is the trigger map in
docs/agents/contributing.md under "Downstream Repositories". Walk it
before you tick anything.
-->

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: https://github.com/cozystack/website/pull/667 carries the
LINSTOR to Blockstor migration guide; it has to follow the order in this
PR's README and `storage.blockstorMigration` before it merges.
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

The new `storage.blockstorMigration` key in
`packages/core/platform/values.yaml` belongs in website#667 with the
rest of the backend docs. Nothing else on the trigger map is touched.

### Release note

```release-note
feat(linstor): A cluster with LINSTOR volumes can be moved to the Blockstor backend in place with `storage.blockstorMigration` (`hold`, then `adopt`, then removed) on the platform, following the order in the linstor package README. Experimental.
```





<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Added a staged process for migrating existing LINSTOR volumes to
BlockStor, with `hold` and `adopt` stages before completing the switch.
* During migration, the BlockStor controller remains stopped during
`hold` and runs during `adopt`; existing LINSTOR resources are
preserved.
* **Documentation**
* Added migration guidance, including rollback paths and operational
constraints.
* Documented optional graceful shutdown settings for Talos satellites
and their prerequisites and limitations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-30 18:15:22 -05:00
..