Skip to content

Add osism get mariadb-backup-host - #2729

Merged
berendt merged 1 commit into
mainfrom
mariadb-backup-host
Sep 28, 2026
Merged

berendt merged 1 commit into
mainfrom
mariadb-backup-host

Conversation

@ideaship

@ideaship ideaship commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

osism apply mariadb-backup writes its archives to one MariaDB host, and nothing in osism can say which one before a backup is taken. This adds osism get mariadb-backup-host.

Depends on:

That PR adds the playbook this command runs, so it has to be merged first.

Documentation:

Why the host cannot be looked up today

The mariadb role resolves it from a role default over a shard group built during the play, and the usual override is an extra var from environments/kolla/configuration.yml. None of that is in the inventory:

  • osism get hostvars <host> mariadb_backup_host reports the variable as not found;
  • osism get hosts -l mariadb sorts alphabetically, so it cannot show the inventory order the default depends on.

Operators are left to probe each MariaDB host for /etc/kolla/mariabackup.

What the command does

It runs the read-only kolla-mariadb-backup-host.yml play on the kolla-ansible worker. The play asks the mariadb role itself: it evaluates the backup task's own condition on every MariaDB host, across all shards, and reports once:

mariadb_backup_host=<host> resolved=<host per shard>

The first field is the host the backup runs on, empty if there is none; the second lists what each shard resolved.

The command dispatches it with kolla.run and publish=False, takes the output from the task result instead of streaming it, and prints only the answer:

  • a table by default;
  • with --format script, the bare host name for use in shell commands.

It exits non-zero:

  • if the play reports no backup host. The error names the resolved candidates: kolla backs up only the default shard and would skip the backup without a word, for example when mariadb_backup_host is overridden to a host outside it;
  • if the play reports nothing;
  • if the play fails. The play output is not streamed, so the error points at osism apply -e kolla mariadb-backup-host for the full output;
  • on timeout. The pending result is then forgotten explicitly; left to interpreter shutdown, Celery prints a traceback.

Why a play and not a local lookup

resolve_in_host_context evaluates expressions in a host's inventory context, but sees neither the role default nor the extra vars. Using it would mean copying kolla's rule into python-osism. The play leaves the resolution to the role, as osism validate already does for its kolla-ansible validators.

Testing

  • 7 new unit tests in tests/unit/commands/test_get.py.
  • On a 2026.1 cluster, with the playbook placed in the kolla-ansible container and this get.py loaded in osismclient:
    • both output formats printed the host holding /etc/kolla/mariabackup;
    • with a failing play (the playbook removed), it exited 1 with that pointer;
    • with --timeout 1, it exited 1 with the timeout error and no traceback.
  • The sharded and no-backup-host reports were verified at the play level, with a second shard simulated through an extra inventory source.

🤖 Generated with Claude Code

"osism apply mariadb-backup" writes its archives to one MariaDB host,
and nothing in osism can say which one before a backup is taken. The
mariadb role resolves it from a role default over a shard group built
during the play, and the usual override is an extra var from
environments/kolla/configuration.yml. None of that is in the
inventory, so "osism get hostvars" reports the variable as not found,
and "osism get hosts" sorts alphabetically and cannot show the
inventory order the default depends on. Operators are left to probe
each MariaDB host for /etc/kolla/mariabackup.

Add "osism get mariadb-backup-host". It runs the read-only
kolla-mariadb-backup-host.yml play on the kolla-ansible worker, which
asks the mariadb role itself. The play evaluates the backup task's own
condition on every MariaDB host, across all shards, and reports once:

  mariadb_backup_host=<host> resolved=<host per shard>

The first field is the host the backup runs on, empty if there is
none; the second lists what each shard resolved. The command
dispatches the play with kolla.run and publish=False and takes the
play output from the task result instead of streaming it, so only the
answer is printed. A table is printed by default; --format script
prints the bare host name, for use in shell commands.

The command exits non-zero if the play reports no backup host, naming
the resolved candidates: kolla backs up only the default shard and
would skip the backup without a word, for example when
mariadb_backup_host is overridden to a host outside it. It also exits
non-zero if the play reports nothing, if the play fails, and on
timeout. Since the play output is not streamed, the error for a
failed play points at "osism apply -e kolla mariadb-backup-host" for
the full output. On timeout the pending result is forgotten
explicitly; left to interpreter shutdown, Celery prints a traceback.

This depends on kolla-mariadb-backup-host.yml in
osism/container-image-kolla-ansible, which has to be merged first.

Tested on a 2026.1 cluster with the playbook placed in the
kolla-ansible container: the command printed the host holding
/etc/kolla/mariabackup in both formats; with a failing play (the
playbook removed) and with a 1 s timeout it exited 1 with the
respective error. The
sharded and no-backup-host reports were verified at the play level,
with a second shard simulated through an extra inventory source.

DocImpact
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Roger Luethi <luethi@osism.tech>
@ideaship
ideaship marked this pull request as ready for review September 28, 2026 07:17
@ideaship
ideaship requested a review from berendt September 28, 2026 07:17

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@berendt
berendt merged commit c88e3a1 into main Sep 28, 2026
3 checks passed
@berendt
berendt deleted the mariadb-backup-host branch September 28, 2026 07:19
berendt pushed a commit to osism/osism.github.io that referenced this pull request Sep 28, 2026
"osism get mariadb-backup-host" reports the host that "osism apply
mariadb-backup" writes its archives to. Until now an operator could
not look this up: the value is a kolla-ansible role default over a
shard group built during the play, and the usual override is an extra
var, none of which "osism get hostvars" or "osism get hosts" can see.

Add it to the CLI reference next to the other get commands: the
default table output, --format script for use in scripts, and
--timeout. Say that the host is resolved by the mariadb role itself,
so overrides of mariadb_backup_host count, and that the command runs
a read-only play on the kolla-ansible worker and therefore takes a
few seconds. Explain that with several MariaDB shards the command
reports the default shard's host, the only one kolla-ansible backs
up. Document the non-zero exits an operator will meet: no host that
would be backed up, for example with mariadb_backup_host set to a
host outside the default shard, where kolla-ansible skips the backup
without an error; and a failed play, whose full output "osism apply
-e kolla mariadb-backup-host" shows.

The command comes from osism/python-osism#2729, which needs the
playbook from osism/container-image-kolla-ansible#965. This should
merge only after both.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Roger Luethi <luethi@osism.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants