Commit efdc64c
authored
feat(compute): improve error message when instance not found in zone (#805)
# Description
When `exo compute instance <action>` commands fail because the instance
does not exist in the default zone, the error message previously
surfaced a raw SDK message with no context:
```
"foo" not found in ListInstancesResponse: Not Found
```
This PR introduces a `findInstance` helper in
`cmd/compute/instance/instance.go` that wraps
`FindListInstancesResponseInstances` and enriches the not-found error
with the zone that was searched and a hint to use `-z`:
```
instance "foo" not found in zone ch-gva-2
Hint: use -z <zone> to specify a different zone, or run 'exo compute instance list' to see instances across all zones
```
Changes:
* Added `findInstance` helper in `cmd/compute/instance/instance.go`,
wrapping `FindListInstancesResponseInstances` with zone-aware error
enrichment.
* Migrated all 24 call sites across the instance subcommands (`show`,
`reboot`, `start`, `stop`, `scale`, `update`, `reset`, `reset-password`,
`reveal-password`, `resize-disk`, `scp`, `ssh`, `snapshot create`,
`snapshot revert`, `security-group add/remove`, `private-network
attach/detach/update-ip`, `elastic-ip attach/detach`, `enable-tpm`,
`console-url`, `delete`) to use the new helper.
* Added
`tests/e2e/scenarios/with-api/compute/instance_not_found_error.txtar`,
an API-driven e2e scenario verifying the enriched error message on
`show`, `reboot` and `stop`. Uses the testscript runner from #804.
* Redirected `go test` stderr to stdout in `.github/workflows/e2e.yml`
to suppress a spurious "Error" banner in the GitHub Actions UI that
appeared when the test runner wrote to stderr, even though the job
itself succeeded.
## Checklist
(For exoscale contributors)
* [x] Changelog updated (under *Unreleased* block, and add the Pull
Request #number for each bit you add to the `CHANGELOG.md`)
* [x] Testing
## Testing
Covered by the e2e scenario above (requires API credentials, runs under
`-tags=api`).1 parent 2aa48ff commit efdc64c
29 files changed
Lines changed: 187 additions & 26 deletions
File tree
- .github/workflows
- cmd/compute/instance
- tests/e2e/scenarios/with-api/compute
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
4 | 7 | | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
0 commit comments