Skip to content

fix(mongodb): fail closed on uncertain member role - #3275

Draft
weicao wants to merge 2 commits into
mainfrom
brooks/mongodb-member-leave-role-probe-r33
Draft

fix(mongodb): fail closed on uncertain member role#3275
weicao wants to merge 2 commits into
mainfrom
brooks/mongodb-member-leave-role-probe-r33

Conversation

@weicao

@weicao weicao commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Problem

mongodb-member-leave.sh discarded the exit status from syncerctl getrole.
That made an uncertain role observation fail open: a timeout (124) or another
probe failure (7) with stale secondary output fell through to
syncerctl leave and returned success.

This conflicts with the addon lifecycle contract that member-leave actions
must repeat or fail safely and that diagnostic failures remain distinct from
successful convergence.

Change

  • Capture role stdout and the original probe exit status separately.
  • On a nonzero probe result, emit a bounded diagnostic, return the same status,
    and do not invoke leave.
  • Preserve the existing exact primary rejection.
  • Preserve KB_LEAVE_MEMBER_POD_NAME as the leave identity.
  • Keep syncerctl leave as the terminal command so its exit status propagates.

Test-first evidence

Exact test-only parent 086e64d277761ee8d750e0d08e5775585d1ba91c:

  • Bash 3.2.57: 4 examples, 2 failures
  • Bash 5.3.9: 4 examples, 2 failures
  • Exact failures: timeout 124 and probe rc 7 with stale secondary; both
    incorrectly returned 0 and invoked leave.

Exact implementation head 8f4da6594ef752a183eeb5226777c40c02cf757c:

  • Focused spec, Bash 3.2.57 / 5.3.9: 5/0 each
  • Full MongoDB specs, Bash 3.2.57 / 5.3.9: 83/0 each
  • Dual Bash syntax, dual ShellSpec syntax, ShellCheck error-level, diff-check,
    strict fsck, ASCII, credential-shape, and clean-worktree gates pass.
  • Fresh independent Dev review: APPROVE/BLOCKER_LIST0.

Review focus

  • Role-probe exit-status boundary and stale-output behavior
  • Exact member identity passed to leave
  • Preservation of primary rejection and terminal leave status

This PR proves the repository source/test contract only. It does not claim
package, Kubernetes, controller, syncer runtime, deployment, release, or
accepted test-run results.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (8e745a4) to head (8f4da65).

Files with missing lines Patch % Lines
...db/scripts-ut-spec/member_leave_role_probe_spec.sh 0.00% 45 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3275   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        165     166    +1     
  Lines      25632   25677   +45     
=====================================
- Misses     25632   25677   +45     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants