-
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
base: main
Are you sure you want to change the base?
Add support for volumeAttributesClassName on persistent storage #11210
Conversation
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.
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/StorageDiff.java
Outdated
Show resolved
Hide resolved
1b96399 to
9882466
Compare
| 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.
|
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: workerI 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. |
| 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 |
Trying to figure out how to test at the |
|
|
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 |
|
VolumeAttributesClass has gone GA since Kubernetes 1.34 and this is a feature that we'd really like so that we could codify higher IOPS/throughput for our Kafka volumes rather than having to make manual modifications to them. It would be really appreciated @venkatesh2090 if you had some time to revive this PR 🙏 |
|
Sure @andyspiers. I will take a look over the weekend. |
While the first point I brought up isn't relevant anymore, I am still looking for solution to test this. I can see that |
4edae04 to
aba8369
Compare
Signed-off-by: Venkatesh Kannan <[email protected]>
Signed-off-by: Venkatesh Kannan <[email protected]>
Signed-off-by: Venkatesh Kannan <[email protected]>
Signed-off-by: Venkatesh Kannan <[email protected]>
Signed-off-by: Venkatesh Kannan <[email protected]>
Signed-off-by: Venkatesh Kannan <[email protected]>
Signed-off-by: Venkatesh Kannan <[email protected]>
Signed-off-by: Venkatesh Kannan <[email protected]>
aba8369 to
27816f1
Compare
Signed-off-by: Venkatesh Kannan <[email protected]>
Signed-off-by: Venkatesh Kannan <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11210 +/- ##
============================================
+ Coverage 74.78% 74.80% +0.01%
- Complexity 6615 6620 +5
============================================
Files 376 377 +1
Lines 25325 25352 +27
Branches 3389 3392 +3
============================================
+ Hits 18939 18964 +25
- Misses 5000 5001 +1
- Partials 1386 1387 +1
🚀 New features to boost your workflow:
|
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 re-opening the PR. I left one nit. There are now CRDs used for testing in the api module resources as well, which you do not seem to have updated here. You might need to rebase and rebuild at least the api module to have them updated.
api/src/main/java/io/strimzi/api/kafka/model/kafka/PersistentClaimStorage.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Venkatesh Kannan <[email protected]>
Signed-off-by: Venkatesh Kannan <[email protected]>
c39c746 to
3c73c6f
Compare
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 code looks good. I will run the system tests once the build completes. Maybe you can add some simple test for the MockPvcController to MockKube3ControllersMockTest?
Signed-off-by: Venkatesh Kannan <[email protected]>
|
/azp run regression |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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