Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow increasing the size of CSI volumes #382

Merged
merged 10 commits into from
Oct 25, 2023
Merged

Allow increasing the size of CSI volumes #382

merged 10 commits into from
Oct 25, 2023

Conversation

gulducat
Copy link
Member

Nomad is enabling CSI volume expansion per hashicorp/nomad#10324 -- slated for the next 1.6.x release (looks like 1.6.3 specifically)

To that end here, capacity_min and capacity_max changes will no longer force replacement of nomad_csi_volumes, nomad_csi_volume_registrations can take those values too, and updating them appropriately can trigger a volume expansion for CSI plugins that support it.

On older versions of Nomad, this should produce idempotent Create or Register API calls (for nomad_csi_volume and nomad_csi_volume_registration respectively), and if this TF provider detects that expansion has not occurred (by comparing against actual Capacity as returned by Nomad API), it will issue a warning to the user.

I did not update nomad_external_volume as it's marked as deprecated, and honestly I considered excluding nomad_csi_volume_registration too, because it didn't take capacity min/max to begin with. But! It shares chunks of code with noamd_csi_volume, and I did update the Register Nomad API to behave the ~same as Create so registration came along too.

There's quite a bit of unit test coverage of the new supporting functions, but very minimal change to the acceptance test. For example, from what I can tell there is nothing testing Update operations at all, and I have not really improved that situation. I can take a swing at it though if anyone would like to push me to.

so that if they remove min/max after initial create,
it doesn't perpetually show "something" -> null
changes on every plan
})
}
}
capacityMin, capacityMax, capacityDiags := parseCapacity(d)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice refactor!

@@ -623,3 +690,107 @@ func flattenCSIVolumeTopologyRequests(topologyReqs *api.CSITopologyRequest) []in

return topologyRequestList
}

func csiErrIsRetryable(err error) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the prettiest but we talked about it already :)

{"10kib", "10 KiB"},
{"5.5 Gib", "5.5 GiB"},
{"5GB", "4.7 GiB"},
{"ugh", "ugh"}, // validation happens elsewhere
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lovely test values jejeje

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no test for empty values?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sure fair point, here go: cc1511a

Copy link
Member

@Juanadelacuesta Juanadelacuesta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gave up on the acceptance tests? The rest looks good

@gulducat
Copy link
Member Author

I didn't really start adding steps to acceptance tests, but your question @Juanadelacuesta was enough for me to go ahead and poke at it.

The current challenge I have with it is that the publicly-available version of Nomad doesn't support volume expansion, and the hostpath CSI plugin that we use here for the tests throws an error about the size changing on an existing volume:

│ Error: error creating CSI volume: Unexpected response code: 500 (1 error occurred:
│ * controller create volume: CSI.ControllerCreateVolume: volume "mysql_volume" already exists but is incompatible with these parameters: rpc error: code = AlreadyExists desc = Volume with the same name: mysql_volume but with different size already exist)

and it seems like the test framework -- specifically this Config field -- wants applying the config not to error.

All that to say, I think updating the acceptance test to confirm changes will make more sense after volume expansion in Nomad is released (and so available to pull in here).

@gulducat gulducat merged commit 9a3972e into main Oct 25, 2023
3 checks passed
@gulducat gulducat deleted the csi-expand branch October 25, 2023 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants