MOVE SERVE.YAML TO VERSION 2
This guide moves an existing serve.yaml from version 1 to version 2, the
version that refuses unknown keys and the only one that takes a serve federation
block.
Note
Preview. Serve federation is a preview feature: no flag turns it on, and its commands and the serve-hub app may change in later releases. Every serve and every CLI that uses it must run Swamp 20261129.160739.0 or later.
Before you start
Upgrading Swamp itself is safe. A version 1 file loads exactly as before, with no new warnings, and version 1 stays supported. Nothing has to change unless you want version 2's strictness or serve federation. Serve never rewrites a file: every step below is one you run.
If the serve has no config file and runs on flags alone, including a serve
installed with swamp serve daemon enable, there is nothing to migrate. Create
a file only when you join it to a hub; see
Join a Serve to a Hub.
Check what you have
Run swamp serve check-config in the repository. For a version 1 file it
reports Config version: 1 and whether the file is ready for version 2, listing
each key version 2 would refuse with the key it most resembles:
swamp serve check-configConfig version: 1
Ready for version 2: no (version 2 refuses unknown keys)
• max-concurent-runs (did you mean max-concurrent-runs?)
• auth.admns (did you mean auth.admins?)
• webhooks[0].schme (did you mean webhooks[0].scheme?)
Auth mode: token
No usernames to resolve in this mode.A file with nothing to refuse reports:
Config version: 1
Ready for version 2: yes (swamp serve check-config --upgrade stamps it)--json reports the same under configVersion and
version2: { ready, refusals: [{ key, suggestion }] }.
Fix what it lists
Correct or remove each listed key. A refused key is usually a misspelt setting
that version 1 has been silently ignoring, so fixing it can change how serve
behaves: the setting starts to apply. In the example above, correcting
max-concurent-runs to max-concurrent-runs starts limiting concurrent runs,
and correcting webhooks[0].schme changes how that webhook is verified. Check
each value before you correct its key.
Run swamp serve check-config again until it reports
Ready for version 2: yes.
Stamp the file
swamp serve check-config --upgrade✓ /srv/swamp/edge-2/.swamp/serve.yaml is now version 2. Serve reads it at its next start or reload.--upgrade adds version: 2 as the first line and keeps every other byte,
comments and layout included. It keeps the file's permissions and writes through
a symlink to its target. It never deletes a key: while any key would be refused
it writes nothing, lists the keys and exits 1:
✗ Not upgraded: version 2 would refuse these keys in /srv/swamp/edge-2/.swamp/serve.yaml. Fix or remove them, then run --upgrade again.
• max-concurent-runs (did you mean max-concurrent-runs?)Running it on a file that is already version 2 changes nothing. --upgrade runs
no other check; run swamp serve check-config afterwards for the full report.
Use --config <path> for a file outside .swamp/serve.yaml, the same path
serve starts with.
Apply it
Serve reads the file at its next start, or at once with swamp serve reload.
Version 2 means exactly the settings version 1 means, with the same defaults, so
a clean upgrade changes no setting.
By deployment style
A repository's .swamp/serve.yaml
Run the steps above in the repository.
Container image or Docker Compose
Stamp the source file the image or Compose file uses, and commit or bake the
result. --output - prints the upgraded file instead of writing it:
swamp serve check-config --upgrade --output -version: 2
port: 19602
max-concurrent-runs: 4Kubernetes ConfigMap or Secret
Generate the upgraded file with --output -, put it in the ConfigMap or Secret
that holds serve.yaml, and roll the deployment. See
Deploy swamp serve on Kubernetes
for where the file is mounted.
GitOps
In CI, write the upgraded copy to a path and open a pull request with it:
swamp serve check-config --upgrade --output upgraded/serve.yamlA relative --output path resolves against the repository, and missing
directories are created. --output works only with --upgrade.
Several serve nodes on one datastore
Move one node at a time, in team mode or a multi-instance deployment. Nodes on version 1 and version 2 behave identically while the rollout runs, because the settings mean the same.
Roll back
Delete the version: 2 line. The file is version 1 again, unchanged. A Swamp
release from before serve federation warns about and ignores version and
federation.
If you used the experimental flag
Serve federation was built behind SWAMP_EXPERIMENTAL_FEDERATION. That variable
is no longer read:
- Remove
SWAMP_EXPERIMENTAL_FEDERATIONfrom the environment. - A file that already says
version: 2is now strict: serve refuses to start on an unknown key. Itsfederationblock takes effect without the flag. Runswamp serve check-configbefore restarting. - Existing hubs and members keep their memberships across the upgrade.
- Every serve and every CLI that uses serve federation must run Swamp 20261129.160739.0 or later.
Behaviour changes to know
version: 1no longer warns thatversionis an unknown key.- A version above 2 refuses to start:
Error: serve.yaml version 3 needs a newer swamp. - A
versionthat is not a positive integer refuses to start, for exampleexpected 1 or 2, got "two". YAML reads2.0as 2. swamp/serve-memberappears in type lists, such asswamp behavior type search.
Related
- Serve Flags: Versions —
every mapping version 2 closes, and the
check-configJSON - Use a Config File
- Configuration Layers
- Join a Serve to a Hub