Skip to content

Fix wait command to always check replica count - #106

Merged
firecow merged 2 commits into
mainfrom
fix/wait-cmd-replica-check
Feb 2, 2026
Merged

Fix wait command to always check replica count#106
firecow merged 2 commits into
mainfrom
fix/wait-cmd-replica-check

Conversation

@firecow

@firecow firecow commented Jan 31, 2026

Copy link
Copy Markdown
Member

Summary

Fixes two bugs in the wait command that could cause it to exit successfully when services weren't actually ready:

  1. Trusted UpdateStatus.State without verification - When UpdateStatus.State was "completed", the command assumed all replicas were running without checking.

  2. Task filter excluded starting tasks - The desired-state: ["running"] filter excluded tasks being scheduled (which have DesiredState: "ready"), causing the command to see 0 tasks and exit with success.

Changes

  • Remove the desired-state filter from listTasks to see all tasks
  • Compare running task count against the service's configured replica count (Spec.Mode.Replicated.Replicas)

Test plan

  • Service with all replicas running → succeeds immediately
  • Service with slow startup → waits until all replicas running, then succeeds
  • Service with failing tasks → keeps waiting and times out with error

@firecow
firecow force-pushed the fix/wait-cmd-replica-check branch from e6a7d88 to efc81b0 Compare January 31, 2026 17:55
Previously, the wait command had two issues:

1. It would trust UpdateStatus.State when present without verifying
   that all replicas were actually running.

2. The desired-state:running filter excluded tasks being scheduled
   (which have DesiredState:"ready"), causing the command to see 0
   tasks and incorrectly exit with success.

Now we:
- Remove the desired-state filter to see all tasks
- Compare running task count against the service's configured
  replica count (Spec.Mode.Replicated.Replicas)

This matches the behavior of docker-stack-wait.
@firecow
firecow force-pushed the fix/wait-cmd-replica-check branch from efc81b0 to 6f51cf4 Compare January 31, 2026 18:38

@moberghammer moberghammer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@firecow
firecow requested a review from Copilot January 31, 2026 19:59

Copilot AI 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.

Pull request overview

This PR fixes critical bugs in the Docker stack wait command that could cause premature success when services weren't ready. The fix ensures accurate service readiness detection by properly checking replica counts and task states.

Changes:

  • Removed the desired-state: ["running"] filter from task listing to capture all task states
  • Changed logic to always verify running task count matches the configured replica count before considering a service ready
  • Reordered checks to prioritize replica count verification over UpdateStatus state

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/commands/wait-cmd.ts Outdated
Comment thread src/commands/wait-cmd.ts
Instead of checking for states that are NOT completed, explicitly check
for known in-progress states (updating, paused, rollback_started,
rollback_paused). This makes the code clearer about which states it's
looking for.
@firecow
firecow requested a review from moberghammer February 1, 2026 08:06

@moberghammer moberghammer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@firecow
firecow merged commit 6d523bf into main Feb 2, 2026
4 checks passed
@firecow
firecow deleted the fix/wait-cmd-replica-check branch February 2, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants