Dean Sheather
a8f2a8a44d
fix(cli): skip dry-run for workspace start/restart commands (#20754)
## Problem
The `prepWorkspaceBuild()` function in `cli/create.go` was
unconditionally executing dry-runs for **all** workspace actions. This
caused unnecessary delays and "Planning workspace..." messages during
`coder start` and `coder restart` commands when they should only happen
during `coder create` and `coder update`.
## Root Cause
The `prepWorkspaceBuild()` function is shared code called by:
- **create command** - passes `WorkspaceCreate` action ✅ dry-run IS
desired
- **update command** - passes `WorkspaceUpdate` action ✅ dry-run IS
desired
- **start command** - passes `WorkspaceStart` action (or
`WorkspaceUpdate` as fallback) ❌ dry-run NOT desired for
`WorkspaceStart`
- **restart command** - passes `WorkspaceRestart` action ❌ dry-run NOT
desired
- **scaletest commands** - pass `WorkspaceCreate` action ✅ dry-run IS
desired
## Solution
Wrapped the dry-run section (lines 580-627) in a conditional that only
executes when `args.Action == WorkspaceCreate || args.Action ==
WorkspaceUpdate`.
This skips dry-run for `WorkspaceStart` and `WorkspaceRestart` actions
while 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**
```bash
go build -o /dev/null ./cli/...
```
✅ **All relevant tests pass locally**
```bash
cd cli && go test -run "TestCreate|TestStart|TestRestart|TestUpdate" -v
PASS
ok 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 wait
for unnecessary dry-run completion
- Users running `coder restart` would experience unnecessary dry-run
overhead
**After:**
- `coder start` (simple start) skips dry-run entirely (faster, more
intuitive)
- `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 "Planning
workspace..." and resource preview)
- `coder update` maintains existing dry-run behavior (shows "Planning
workspace..." and resource preview)
## Verification
Manual 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..." ✅
2025-11-13 09:48:28 +11:00
..
2025-01-29 14:35:04 +00:00
2025-06-20 13:16:55 -06:00
2025-10-24 12:38:47 +03:00
2025-06-24 11:16:31 +02:00
2024-02-26 10:03:49 -06:00
2025-01-17 14:51:24 +02:00
2025-06-20 13:16:55 -06:00
2025-11-12 10:48:19 -07:00
2025-11-12 12:46:39 -06:00
2025-06-20 13:16:55 -06:00
2025-11-05 14:22:24 +02:00
2025-11-05 14:22:24 +02:00
2025-10-27 17:07:25 +01:00
2025-06-20 13:16:55 -06:00
2025-09-22 17:14:07 +04:00
2024-08-22 15:40:53 +10:00
2025-09-29 17:01:54 +04:00
2025-06-06 16:44:25 +04:00
2025-07-03 11:28:00 -06:00
2025-06-06 16:44:25 +04:00
2025-09-22 17:14:07 +04:00
2025-04-17 11:23:24 +04:00
2025-04-17 11:23:24 +04:00
2025-07-29 16:59:26 +01:00
2025-11-13 09:48:28 +11:00
2025-10-23 14:24:54 +02:00
2025-09-22 17:14:07 +04:00
2025-03-04 15:37:29 -07:00
2025-03-04 15:37:29 -07:00
2025-03-04 15:37:29 -07:00
2025-03-04 15:37:29 -07:00
2025-09-30 12:26:41 -05:00
2025-09-30 12:26:41 -05:00
2025-06-20 13:16:55 -06:00
2025-03-26 01:56:39 -05:00
2025-06-30 12:12:20 -08:00
2025-09-22 17:14:07 +04:00
2025-08-06 23:03:51 +02:00
2025-07-22 19:02:43 +01:00
2025-09-22 17:14:07 +04:00
2025-10-23 16:49:09 +04:00
2025-10-31 09:43:06 +01:00
2024-03-17 09:45:26 -05:00
2025-10-22 11:14:49 +02:00
2025-01-03 23:08:51 +02:00
2025-10-30 11:10:24 +04:00
2025-09-29 15:42:03 +01:00
2025-10-08 13:43:44 +01:00
2025-11-05 14:28:34 +00:00
2025-10-23 20:22:51 +03:00
2025-10-29 18:59:12 +00:00
2025-10-23 20:22:51 +03:00
2025-10-23 20:22:51 +03:00
2025-10-23 20:22:51 +03:00
2025-10-23 20:22:51 +03:00
2025-10-23 20:22:51 +03:00
2025-11-05 14:28:34 +00:00
2025-10-24 12:38:47 +03:00
2025-11-03 10:13:19 +00:00
2025-09-26 10:37:52 +01:00
2025-03-26 01:56:39 -05:00
2025-09-03 10:49:19 +04:00
2024-10-22 09:20:54 -05:00
2025-09-22 17:14:07 +04:00
2025-09-03 10:38:42 +04:00
2025-09-03 10:49:19 +04:00
2025-09-03 10:38:42 +04:00
2025-09-03 10:49:19 +04:00
2025-03-26 01:56:39 -05:00
2025-11-12 10:48:19 -07:00
2025-09-25 16:54:44 -04:00
2025-09-25 16:54:44 -04:00
2024-10-29 13:02:20 +00:00
2025-10-30 17:41:08 -06:00
2025-05-12 11:45:24 -07:00
2025-10-30 17:41:08 -06:00
2024-06-13 10:19:36 +04:00
2025-09-22 17:14:07 +04:00
2025-09-11 15:08:57 +02:00
2025-09-22 17:14:07 +04:00
2025-06-20 13:16:55 -06:00
2025-07-22 19:02:43 +01:00
2025-09-22 17:14:07 +04:00
2024-07-25 16:07:53 -05:00
2025-09-22 17:14:07 +04:00
2025-09-22 17:14:07 +04:00
2024-08-20 14:47:46 +10:00
2025-09-22 17:14:07 +04:00
2024-05-23 07:54:59 -10:00
2025-09-22 17:14:07 +04:00
2025-09-22 17:14:07 +04:00
2025-07-28 14:46:04 +01:00
2025-07-28 14:46:04 +01:00
2025-07-03 13:22:54 +10:00
2025-02-24 05:38:17 +00:00
2025-09-22 17:14:07 +04:00
2025-06-20 13:16:55 -06:00
2025-06-27 14:42:22 +04:00
2025-09-22 17:14:07 +04:00
2025-10-06 08:56:43 +00:00
2025-10-06 13:58:37 +02:00
2025-08-21 16:03:34 -04:00
2025-09-22 17:14:07 +04:00
2025-09-22 17:14:07 +04:00
2025-03-26 01:56:39 -05:00
2024-07-30 10:44:02 -06:00
2025-09-22 17:14:07 +04:00
2024-03-17 09:45:26 -05:00
2024-11-04 17:23:31 +01:00
2025-03-26 01:56:39 -05:00
2025-07-28 20:41:49 -05:00
2025-09-22 17:14:07 +04:00
2025-06-20 13:16:55 -06:00
2025-09-03 10:49:19 +04:00
2025-10-30 17:41:08 -06:00
2025-06-20 13:16:55 -06:00
2025-10-24 10:18:19 +00:00
2025-10-24 10:18:19 +00:00
2024-11-04 17:23:31 +01:00
2025-01-20 14:31:16 +01:00
2025-06-20 13:16:55 -06:00
2025-10-23 14:24:54 +02:00
2025-03-27 10:03:53 +00:00
2024-03-17 09:45:26 -05:00
2025-10-23 14:24:54 +02:00
2025-11-12 14:26:15 -06:00
2025-10-22 16:18:31 +11:00
2025-09-22 17:14:07 +04:00
2025-07-08 16:16:00 +00:00
2025-09-22 17:14:07 +04:00
2024-03-15 13:16:36 +00:00
2024-03-15 13:16:36 +00:00
2024-11-18 14:09:22 +04:00
2025-09-22 17:14:07 +04:00
2025-09-16 21:53:50 +04:00
2025-10-27 11:13:26 +11:00
2025-10-27 16:59:31 +11:00
2025-07-28 20:41:49 -05:00
2025-09-22 17:14:07 +04:00
2025-03-26 10:36:53 +00:00
2025-03-26 10:36:53 +00:00
2024-10-22 09:20:54 -05:00
2025-09-22 17:14:07 +04:00
2025-09-22 17:14:07 +04:00
2025-06-24 11:16:31 +02:00
2025-09-22 17:14:07 +04:00
2024-07-25 16:07:53 -05:00
2025-09-22 17:14:07 +04:00
2025-09-22 17:14:07 +04:00
2025-06-20 13:16:55 -06:00
2025-09-22 17:14:07 +04:00
2024-03-17 09:45:26 -05:00
2024-07-25 16:07:53 -05:00
2025-09-22 17:14:07 +04:00
2025-07-29 16:59:26 +01:00
2025-09-22 17:14:07 +04:00
2025-06-20 13:16:55 -06:00
2025-09-22 17:14:07 +04:00
2025-10-03 10:20:06 -05:00
2025-10-03 10:20:06 -05:00
2025-07-24 16:44:36 +01:00
2023-10-11 09:26:22 -05:00
2025-09-22 17:14:07 +04:00
2024-10-17 14:15:14 +05:00
2025-09-22 17:14:07 +04:00
2025-10-27 17:07:25 +01:00
2025-10-28 15:15:57 +00:00
2025-07-28 20:41:49 -05:00
2025-09-22 17:14:07 +04:00
2024-08-23 21:23:51 +00:00
2025-04-16 10:37:09 -06:00
2025-09-22 17:14:07 +04:00
2025-09-22 17:14:07 +04:00
2025-04-15 18:30:20 -04:00
2025-09-22 17:14:07 +04:00
2025-05-12 11:45:24 -07:00
2025-09-22 17:14:07 +04:00
2025-04-15 18:30:20 -04:00
2025-09-22 17:14:07 +04:00
2025-06-20 13:16:55 -06:00
2025-03-26 01:56:39 -05:00
2025-06-20 13:16:55 -06:00
2024-03-17 09:45:26 -05:00
2025-09-13 08:57:26 +02:00
2025-07-30 02:03:20 +10:00
2025-06-20 13:16:55 -06:00
2025-07-28 14:02:00 +10:00
2024-11-18 21:10:01 +10:00
2024-11-18 14:09:22 +04:00
2025-09-22 17:26:36 +04:00
2024-07-09 13:23:11 -05:00
2025-09-26 11:20:25 +01:00