Repository navigation
fix: node-pool delete keeps labels/taints on other pools; no panic on --region without API key - #614
Merged
Merged
Conversation
`civo k8s node-pool delete` removed pools by sending the cluster's pool list back through UpdateKubernetesCluster with only ID, count and size. When that list is shorter than the cluster's, the API replaces the pools with it, so every remaining pool lost its labels and taints. Resolve the requested IDs up front (failing on unknown IDs, duplicates, or a request that would remove every pool, before touching anything), then delete each pool with DeleteKubernetesClusterPool, which leaves the other pools untouched and releases quota for the deleted pool. Also drops the unreachable len(args) == 1 branch, which indexed args[1], and the package-level slice that accumulated across invocations.
Every command created the client and then set client.Region from --region before checking the error from config.CivoAPIClient(). With no API key configured CivoAPIClient returns a nil client, so any command run with --region panicked with a nil pointer dereference instead of printing the 'no API key' error. Move the error check above the region override in all 119 call sites. This is a pure reordering, no other changes.
alessandroargentieri
approved these changes
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #607, fixing two issues found while reviewing it.
1.
node-pool deletewiped labels and taints on the remaining poolscivo k8s node-pool deleteremoved pools by rebuilding the cluster's pool list with onlyid,countandsize, then sending it throughUpdateKubernetesCluster. When the list is shorter than the cluster's, the API replaces the pools with the request (SetPools(updateReq.Pools)in api-goUpdateCluster), so every remaining pool lost its labels, and taints went out asnull.Now the command:
DeleteKubernetesClusterPool(DELETE /v2/kubernetes/clusters/{id}/pools/{pool_id}), which only removes that pool and releases its quota;It also drops the unreachable
len(args) == 1branch (which indexedargs[1]) and the package-level slice that accumulated across invocations. Matching still goes throughutility.RemoveNodePool, so prefix behaviour is unchanged from #607.2.
--regionwith no API key panickedEvery command set
client.Regionfrom--regionbefore checking the error fromconfig.CivoAPIClient(), which returns a nil client when no API key is configured:The second commit moves the error check above the region override in all 119 call sites. It is a pure reordering (360 lines moved, nothing else changed), done with a pattern match and then checked so that no
client.Region = common.RegionSetcomes before anif err != nilanywhere incmd/. With the fix the same command prints the normal "no API key" error.Testing
go build,go vet,go test ./...andgolangci-lint runall pass locally.HOME.