Skip to content

Unit stuck 'Waiting for primary re-election...' after scale-in to 0 then scale-out to 1 #590

Description

@almeidaraul

Summary

mongodb-k8s (rev 205, channel 8-transition/edge) fails to recover after a scale-in to 0 → scale-out to 1 cycle. The single unit comes back up but stays stuck in waiting/idle with message Waiting for primary re-election... and never returns to active, timing out after 15 minutes.

Environment

  • Charm: mongodb-k8s rev 205 (8-transition/edge)
  • Juju: 4.0.14
  • Base: ubuntu:24.04, Kubernetes, amd64
  • Test plan: integration/glauth-k8s:ldap/ldap/mongodb-k8s:ldap

Failing test

test_scale_in_and_scale_out_charm

juju.backend.JujuWaitTimeoutError: Timed out while waiting for applications:
[active], units: [active], unit agents: [idle] (units: ['target/0'])

What happens

The test scales the mongodb-k8s application (target) down to 0 units, then back up to 1 unit, and waits for it to become active/idle.

Before scale-in — unit healthy:

Unit          Workload  Agent  Message
target/0*     active    idle   Primary.

After scale-out to 1 — unit stuck (never recovers within the 15 min idle timeout):

Unit          Workload  Agent  Message
target/0*     waiting   idle   Waiting for primary re-election...

When the sole replica-set member is removed (scale to 0) and a fresh pod is brought back (scale to 1), the charm does not complete MongoDB primary re-election, so the unit remains waiting indefinitely.

All co-deployed applications (glauth-k8s, postgresql-k8s, self-signed-certificates) stayed healthy throughout — the failure is specific to mongodb-k8s.

Steps to reproduce

  1. Deploy mongodb-k8s (rev 205, 8-transition/edge) with 1 unit; wait for active/idle.
  2. juju scale-application <app> 0; wait for removal.
  3. juju scale-application <app> 1; wait for active/idle.
  4. Unit gets stuck in waitingWaiting for primary re-election....

References

Filed via automated Test Observer triage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions