-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add support for volumeAttributesClassName on persistent storage #11210
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
Add support for volumeAttributesClassName on persistent storage #11210
Conversation
Signed-off-by: Venkatesh Kannan <[email protected]>
Signed-off-by: Venkatesh Kannan <[email protected]>
Signed-off-by: Venkatesh Kannan <[email protected]>
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, I have one question.
} | ||
|
||
if (pathValue.endsWith("/volumeAttributesClass") && desired.getType().equals(current.getType())) { | ||
volumeAttributesClassChanged = true; |
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.
Shouldn't here be check that it's really different in comparison current/desired?
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.
You're right. I didn't think about that. Will change
Signed-off-by: Venkatesh Kannan <[email protected]>
1b96399
to
9882466
Compare
Signed-off-by: Venkatesh Kannan <[email protected]>
if (pathValue.endsWith("/volumeAttributesClass") && desired.getType().equals(current.getType()) && | ||
(isNull(persistentCurrent.getVolumeAttributesClass()) || isNull(persistentDesired.getVolumeAttributesClass()) || | ||
!persistentCurrent.getVolumeAttributesClass().equals(persistentDesired.getVolumeAttributesClass()))) { |
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 change, however from my point of view this is not much readable at the first sight.
I would keep the if (pathValue.endsWith("/volumeAttributesClass") && desired.getType().equals(current.getType()))
which you had there before and then checking if those two are equal or not.
Instead of these checks for null and then comparing, you can use Objects.equals()
as it can work with nulls and it will not throw NPEs.
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.
What do you think about moving the desired.getType().equals(current.getType())
to the first if? It is common in both volumeAttributeClass
and size
.
Like this
-if (current instanceof PersistentClaimStorage persistentCurrent && desired instanceof PersistentClaimStorage persistentDesired) {
+if (current instanceof PersistentClaimStorage persistentCurrent && desired instanceof PersistentClaimStorage persistentDesired &&
+ desired.getType().equals(current.getType())) {
Instead of these checks for null and then comparing, you can use Objects.equals() as it can work with nulls and it will not throw NPEs.
Thanks for that. Didn't know this existed.
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.
What do you think about moving the desired.getType().equals(current.getType()) to the first if? It is common in both volumeAttributeClass and size.
Yeah I guess that should be fine, good point.
Signed-off-by: Venkatesh Kannan <[email protected]>
Thanks for the PR can you elaborate a little bit more about this ...
|
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.
Hi @venkatesh2090, LGTM but I can't easily test the changes. Is there a way to test it locally? Are you using some AWS enabled instance? Thanks.
By that I meant, StorageDiff would consider everything in the Storage a change except if it is the size, overrides, deleteClaim and something with kraftMetadata that I couldn't wrap my head around. So I had to explicitly make it ignore a change in the volumeAttributesClass since it would treat that as immutable, when it shouldn't be. |
I used a feature gate in my kind setup. This is the cluster definition. But the CSI driver itself doesn't support VACs, so it wouldn't reconcile it. You would be able to see the change in the PVC though. I also tested it in AWS with rancher since EKS doesn't have that version of k8s. kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: strimzi
containerdConfigPatches:
- |
[plugins."io.containerd.grpc.v1.cri".registry]
config_path = "/etc/containerd/certs.d"
featureGates:
VolumeAttributesClass: true # <-- this
runtimeConfig:
storage.k8s.io/v1beta1: "true"
nodes:
- role: control-plane
- role: worker
- role: worker I had to follow some article to setup a local container registry as well. Can't remember off the top of my head. |
@venkatesh2090 @im-konge so what's the plan around STs for this taking into account that even local test seems to be not so easy? |
We have more things that are not so easy to actually write STs. I haven't got time to look and test it locally yet, however if it's something that will need for example some AWS stuff, we cannot simply test it in STs. We would need to manually verify it. |
@@ -70,6 +72,7 @@ private StorageDiff(Reconciliation reconciliation, Storage current, Storage desi | |||
boolean volumesAddedOrRemoved = false; | |||
boolean tooManyKRaftMetadataVolumes = false; | |||
boolean duplicateVolumeIds = false; | |||
boolean volumeAttributesClassChanged = false; |
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.
Do we really need to know it changed? Isn't it sufficient to ignore the change? We do not seem to use this anywhere in the production code.
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.
Yeah. It is only being used in tests. Can remove it and the related tests. I'll just add some KafkaAssemblyOperator
tests as well
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.
I think the tests for the StorageDiff can just test that it does not report any issues when the volume class atrributes change, or?
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.
Oh right... Didn't think this through before replying. Thanks
My general expectation for this was that it should be covered by unit tests. This is anyway more or less Kubernetes / infrastructure thing. So I do not think there is much for us to do in system tests. That said, I would expect some |
Signed-off-by: Venkatesh Kannan <[email protected]>
Trying to figure out how to test at the |
Signed-off-by: Venkatesh Kannan <[email protected]>
|
So I'm writing my tests in
I can push my current changes if you'd like to get the full picture. |
Hmm, I did not realize this would need to have the flag enabled :-/. |
Is this something I should keep looking at or should it be paused for now? Maybe until |
Hi @venkatesh2090 just to check my understanding here. The changes you're suggesting here, if the user hasn't enabled But to test this feature we need to enable a feature flag in MockKube3? |
Yes, that is right. I would have to enable that feature flag in MockKube to test this feature. |
I don't think there is an issue going ahead, since MockKube is just used for testing. However, I wonder whether many people would use this feature before it is GA in Kubernetes. Is it something you were hoping to use right away, or are you happy to wait for it to become GA @venkatesh2090 ? I'm afraid I'm not familiar enough with the MockKube3 tests to answer your other question. Tagging @strimzi/maintainers to see what others think. |
No that's fine. I don't need this feature. I just raised a PR because I saw an open issue 🙂. Feel free to tag me or take over this PR when the feature goes GA. |
That's great, we really value your contribution. Ok so I think we have two options. If you want to continue working on this you could switch up the tests to use Mockito instead of MockKube3. That way we don't need to worry about the feature flag. Or you can close this PR and we will reopen it and tag you once the feature is GA. If you are keen to pick up another task feel free to grab one, or you can drop a message in the the |
Thanks. I'll close it for now and do it properly when it is GA |
Type of change
Enhancement / new feature
Description
Currently, it is not possible to set the volumeAttributesClassName in the generated PVC using the persistent storage type. This enables that feature by adding a volumeAttributesClass field to the persistent storage that maps to the PVC.
Changes to the StorageDiff was required because it fails when a field is changed other than size and a few others.
Fixes #10462
Checklist
Please go through this checklist and make sure all applicable tasks have been done