- Notifications
You must be signed in to change notification settings - Fork1.1k
Commita8f2a8a
authored
fix(cli): skip dry-run for workspace start/restart commands (#20754)
## ProblemThe `prepWorkspaceBuild()` function in `cli/create.go` wasunconditionally executing dry-runs for **all** workspace actions. Thiscaused unnecessary delays and "Planning workspace..." messages during`coder start` and `coder restart` commands when they should only happenduring `coder create` and `coder update`.## Root CauseThe `prepWorkspaceBuild()` function is shared code called by:- **create command** - passes `WorkspaceCreate` action ✅ dry-run ISdesired- **update command** - passes `WorkspaceUpdate` action ✅ dry-run ISdesired- **start command** - passes `WorkspaceStart` action (or`WorkspaceUpdate` as fallback) ❌ dry-run NOT desired for`WorkspaceStart`- **restart command** - passes `WorkspaceRestart` action ❌ dry-run NOTdesired- **scaletest commands** - pass `WorkspaceCreate` action ✅ dry-run ISdesired## SolutionWrapped the dry-run section (lines 580-627) in a conditional that onlyexecutes when `args.Action == WorkspaceCreate || args.Action ==WorkspaceUpdate`.This skips dry-run for `WorkspaceStart` and `WorkspaceRestart` actionswhile preserving it for creation and explicit updates.## Changes- Added conditional check around the entire dry-run logic block- Added clarifying comment explaining the intent- Changed from unconditional execution to: `if args.Action ==WorkspaceCreate || args.Action == WorkspaceUpdate { ... }`## Impact| Command | Action Type | Dry-run Before | Dry-run After | Status ||---------|-------------|----------------|---------------|--------|| `coder create` | `WorkspaceCreate` | ✅ Yes | ✅ Yes | Unchanged || `coder update` | `WorkspaceUpdate` | ✅ Yes | ✅ Yes | Unchanged || `coder start` (normal) | `WorkspaceStart` | ❌ Yes (bug) | ✅ No |**Fixed** || `coder start` (template changed) | `WorkspaceUpdate` | ✅ Yes | ✅ Yes |Unchanged (correct behavior) || `coder restart` | `WorkspaceRestart` | ❌ Yes (bug) | ✅ No | **Fixed**|| scaletest | `WorkspaceCreate` | ✅ Yes | ✅ Yes | Unchanged |## Testing✅ **Code compiles successfully**```bashgo build -o /dev/null ./cli/...```✅ **All relevant tests pass locally**```bashcd cli && go test -run "TestCreate|TestStart|TestRestart|TestUpdate" -vPASSok github.com/coder/coder/v2/cli 3.337s```✅ **All CI checks pass**- test-go-pg (ubuntu, macos, windows) ✅- test-go-pg-17 ✅- test-go-race-pg ✅- test-e2e ✅- All other checks ✅## Behavior Changes**Before:**- Users running `coder start` would see "Planning workspace..." and waitfor unnecessary dry-run completion- Users running `coder restart` would experience unnecessary dry-runoverhead**After:**- `coder start` (simple start) skips dry-run entirely (faster, moreintuitive)- `coder start` (with template update) still shows dry-run (correct -user needs to see what's changing)- `coder restart` skips dry-run entirely (faster, more intuitive)- `coder create` maintains existing dry-run behavior (shows "Planningworkspace..." and resource preview)- `coder update` maintains existing dry-run behavior (shows "Planningworkspace..." and resource preview)## VerificationManual testing should verify:1. `coder create` still shows "Planning workspace..." ✅2. `coder update` still shows "Planning workspace..." ✅3. `coder start` (simple start) does NOT show "Planning workspace..." ✅4. `coder restart` does NOT show "Planning workspace..." ✅1 parent04727c0 commita8f2a8a
1 file changed
+48
-44
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
577 | 577 | | |
578 | 578 | | |
579 | 579 | | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
588 | 591 | | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
613 | 616 | | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
618 | 621 | | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
627 | 631 | | |
628 | 632 | | |
629 | 633 | | |
| |||
0 commit comments
Comments
(0)