Repository navigation
fix(volume): resolve Network and Instance lookup fallbacks in volume ls (fixes #597) - #598
Conversation
fulviodenza
left a comment
There was a problem hiding this comment.
Thanks for this, and sorry for the slow review. The fix is real: I ran the new TestVolumeListLookups against the current volume_list.go on master and it fails exactly as described in #597 (unmatched rows show the last network label / last hostname, and an empty instance when the cluster resolves but the node does not), and it passes with your change. Still exactly 4 list calls total, lookups are in memory, and a miss now falls back to the raw ID instead of a plausible wrong value. It also merges cleanly onto current master and the tests pass there.
Requested changes (small):
- Restore global state in the test (
cmd/volume/volume_list_test.go): the test mutatesconfig.Current,common.OutputFormatandcommon.OutputFieldsand redirectsos.Stdoutwithout restoring them. It is harmless today because it is the only test in the package, but it will leak into any test added later. Please save the old values and restore them witht.Cleanup, and handle theos.Pipe()error instead of discarding it. - Rebase on master: the branch is a few months behind (civogo v0.7.2 vs v0.7.6 on master). No conflicts, but it would be good to have CI run on the current base.
Optional improvement: for volumes attached to cluster nodes where the volume's own cluster does not resolve, instance_id now shows the raw instance UUID. Since all clusters are already loaded, you could also search clusters.Items[*].Instances for the instance to show the node hostname, which is closer to what #597 asked for. Fine to leave for a follow-up.
The only CI run on this branch failed on a workflow file problem that predates the CI changes on master, so the rebase will also get it a proper run.
Address review feedback from @fulviodenza: - Save and restore config.Current, common.OutputFormat, common.OutputFields, and os.Stdout using t.Cleanup to prevent state leaks into future tests - Handle os.Pipe() error with t.Fatalf instead of discarding it
Thanks for the review @fulviodenza! Pushed the fix — global state is now saved and restored via t.Cleanup, and os.Pipe() error is handled. Will rebase on master for a clean CI run. |
|
LGTM 🚀 |
safely fall back to raw IDs instead of showing unrelated names or breaking table column
alignment.
instance lookups.
- Ensured
instance_idcolumn is always appended once per row for consistent tablealignment.
- Added unit tests in
cmd/volume/volume_list_test.goto verify matched and unmatchedfallback behavior.
Fixes #597