Skip to content

backport: fix(instance-recovery): stop infinite recursion when consul-storage-lb is missing - #1046

Draft
vsz-work wants to merge 1 commit into
canonical:stable/2025.1from
vsz-work:2025.1/lp2168498-consul-storage-lb-recursion
Draft

vsz-work wants to merge 1 commit into
canonical:stable/2025.1from
vsz-work:2025.1/lp2168498-consul-storage-lb-recursion

Conversation

@vsz-work

Copy link
Copy Markdown
Commit Cherry-picked from Change
fix(instance-recovery): stop infinite recursion when consul-storage-lb is missing b3e87938 (#1015) Non-recursive _get_lb_service() lookup; ignore_errors honoured in PatchLoadBalancerServicesIPStep.run(); run() returns SKIPPED when every service was skipped; consul storage service name is now the base name consul-storage

The bug was reported on 2024.1 (2024.1/stable, rev 1101), and 2025.1 has the same code: sunbeam enable instance-recovery on MAAS crashes with RecursionError: maximum recursion depth exceeded when the storage space is the same as the management space. See #1015 for the full root cause.

Adaptations for 2025.1

None. The commit cherry-picked cleanly onto stable/2025.1 (cherry-pick -x). The code it touches is the same as on main:

  • The same 8 subclasses use the lookup (OpenStack, DNS, observability and consul patch steps), and all of them pass base service names. As on 2024.1, OpenStackPatchLoadBalancerServicesIPStep can also add ovn-relay, which is a base name too.
  • Only the consul storage steps pass ignore_errors=True, so the new SKIPPED result only changes their outcome. The other steps behave as before.
  • As on main, the consul storage patch steps are still always scheduled on MAAS. When storage shares the management space they now skip themselves instead of crashing.

QA steps

Unit tests (from sunbeam-python/):

tox -e unit -- tests/unit/sunbeam/core/test_steps.py
tox -e pep8 && tox -e mypy

On a 2025.1 MAAS deployment, with a snap built from this branch:

  1. Storage and management in the same space, with a <deployment>-storage-ippool range reserved: sunbeam -v enable instance-recovery finishes without RecursionError, and both consul storage patch steps report SKIPPED.
  2. A separate storage space with a <deployment>-storage-ippool range: consul-storage-lb gets the storage pool annotation and an IP from that pool.

Tested

Check Result
Unit suite on stable/2025.1 + this branch 4418 passed. ruff format, ruff check and mypy sunbeam are clean
1. Shared space, storage pool reserved TODO
2. Separate storage space TODO

The behaviour was tested on MAAS on main in #1015.

Links

Jira card: OPEN-XXXX

…b is missing

`sunbeam enable instance-recovery` on MAAS crashes with a RecursionError
when the storage space is shared with the management space. In that
layout no consul-storage server is deployed, so the consul-storage-lb
service does not exist. The consul storage patch steps passed
"consul-storage-lb" to _get_service(), which appended "-lb", got a 404,
fell back to "consul-storage-lb", got a 404 again and, because that name
ends in "-lb", called itself with find_lb=False until the stack ran out.

Replace the two copies of the recursive _get_service() in
PatchLoadBalancerServicesIP{,Pool}Step with a single non-recursive
_get_lb_service() helper. It tries "<name>-lb" and then "<name>" (or only
"<name>" with find_lb=False) and raises the last 404.

Make PatchLoadBalancerServicesIPStep.run() honour ignore_errors for a
missing service, as is_skip() and the Pool step's run() already do. In
both steps, run() now returns SKIPPED, like is_skip(), when every service
was skipped under ignore_errors, instead of reporting COMPLETED for a
step that patched nothing.

Use the base name "consul-storage" (CONSUL_STORAGE_SERVICE), like the
bind and traefik steps. When storage shares the management space, the
consul storage patch steps still run and now report SKIPPED.

Assisted-By: Claude Code (Claude Opus 5.5)
Closes-Bug: #2168498
Signed-off-by: Vítor Zeni <vitor.zeni@bairesdev.com>
(cherry picked from commit b3e8793)
@vsz-work
vsz-work marked this pull request as ready for review November 25, 2026 19:57
@vsz-work
vsz-work marked this pull request as draft November 25, 2026 19:57
@vsz-work

Copy link
Copy Markdown
Author

Heads-up if you test this on 2025.1: bootstrapping from 2025.1/candidate currently fails with terraform command failed and an empty stderr. This is unrelated to this PR.

The candidate manifest has no epa-orchestrator entry. Sunbeam then uses 2025.1/stable for that charm, which has no release on Charmhub.

Workaround: bootstrap with a manifest that adds the entry.

cp /snap/openstack/current/etc/manifests/2025.1/candidate.yml ~/bootstrap.yml
yq -y '.core.software.charms["epa-orchestrator"] = {"channel": "2025.1/candidate", "config": {"snap-channel": "2025.1/candidate"}}' \
  ~/bootstrap.yml > ~/bootstrap-epa.yml
sunbeam cluster bootstrap --manifest ~/bootstrap-epa.yml --role control,compute --accept-defaults

Use a fresh machine: rerunning a failed bootstrap isn't reliable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant