Simplify policy migration (#2582)

These steps are easier to accomplish and require only Headscale 0.26.
They also work when a user has already upgraded the database.

See: #2567
This commit is contained in:
nblock 2025-05-10 08:04:42 +02:00 committed by GitHub
parent dd0cbdf40c
commit d81b0053e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -68,22 +68,20 @@ new policy code passes all of our tests.
<summary>Migration notes when the policy is stored in the database.</summary> <summary>Migration notes when the policy is stored in the database.</summary>
This section **only** applies if the policy is stored in the database. This section **only** applies if the policy is stored in the database and
Headscale 0.26 doesn't start due to a policy error (`failed to load ACL
policy`).
Headscale won't start with an invalid policy and this also means that the policy * Start Headscale 0.26 with the environment variable `HEADSCALE_POLICY_V1=1`
can't be updated with the CLI. One may migrate a policy stored in the database set. You can check that Headscale picked up the environment variable by
following these steps: observing this message during startup: `Using policy manager version: 1`
* Dump the policy to a file: `headscale policy get > policy.json`
* Dump the policy to a file while still running Headscale 0.25: * Edit `policy.json` and migrate to policy V2. Use the command
`headscale policy get > policy.json` `headscale policy check --file policy.json` to check for policy errors.
* Create a dummy policy (here: allow all): * Load the modified policy: `headscale policy set --file policy.json`
`echo '{"acls":[{"action":"accept","src":["*"],"dst":["*:*"]}]}' > dummy.json` * Restart Headscale **without** the environment variable `HEADSCALE_POLICY_V1`.
* Load the dummy policy into Headscale 0.25: Headscale should now print the message `Using policy manager version: 2` and
`headscale policy set --file dummy.json` startup successfully.
* Edit `policy.json` and migrate to policy V2
* Update to Headscale 0.26
* Load the modified policy V2:
`headscale policy set --file policy.json`
</details> </details>