-
Notifications
You must be signed in to change notification settings - Fork 976
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
resource/kubernetes_persistent_volume: Add support for storage_class_name #111
resource/kubernetes_persistent_volume: Add support for storage_class_name #111
Conversation
This should partially address #74. |
I had a go at trying to allow empty or null storage class name for persistent volume claims, but that was thwarted by the fact that |
This patch worked perfectly for me, thanks! |
storage_class_name
in kubernetes_persistent_volume
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @sergei-ivanov
The code looks overall good, I just added missing test which exercises the new field and also changed a few existing tests which were previously failing (and your PR allowed us to fix them 🎉 ), so we can pull this in. Feel free to ask any questions about my two commits.
@@ -766,13 +772,27 @@ func patchPersistentVolumeSpec(pathPrefix, prefix string, d *schema.ResourceData | |||
Value: expandPersistentVolumeAccessModes(v.List()), | |||
}) | |||
} | |||
if d.HasChange(prefix + "access_modes") { | |||
if d.HasChange(prefix + "persistent_volume_reclaim_policy") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😱 good catch!
@radeksimko , thank you for looking after the tests. I did not have a spare GCP project to run them against, so I did not dare touch them. I ran a lot of manual checks against my local minikube though. Everything looks great, thank you for accepting the PR, we are looking forward to it being rolled into the next release of the provider! |
Thanks guys! |
Thanks for picking up the work, @sergei! |
It is basically a partial rebase of #72 plus a few additional fixes to make it actually work.
I have tested it against minikube by creating PVs with the source
host_path
, which is the simplest setup I could produce locally without hitting the cloud.The testing revealed that creating a PV without a storage class and then amending it to the one with a storage class did not work because Kubernetes sent back a JSON without
/spec/storageClassName
path in it. That resulted in:I had to tweak
patchPersistentVolumeSpec
a bit to produce eitheradd
orreplace
operation, which worked a treat in the end: I could add, change or remove storage class in the terraform manifest, and kubernetes applied the changes to the persistent volume.I am not very experienced in Go, and there may be a more elegant way of doing what I've done,
so please feel free to correct me here.
Closes #72