-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Issue 4394 - custom filter for user labels #4791
Issue 4394 - custom filter for user labels #4791
Conversation
…sources Signed-off-by: Kate Chernousova <[email protected]>
Signed-off-by: Kate Chernousova <[email protected]>
Signed-off-by: Kate Chernousova <[email protected]>
Can one of the admins verify this patch? |
Signed-off-by: Kate Chernousova <[email protected]>
@echernous We discussed this today at the Strimzi Community Call. The outcome was that this should be preferably controlled by an environment variable in the operator deployments and not through an annotation like you have it. |
Thanks @scholzj, I will make the change and test it today, will let you know how it goes |
Signed-off-by: Kate Chernousova <[email protected]>
@scholzj I applied the change and moved the filtering into fromResource so user specified regex won't affect non-CR labels, and the default exclusion pattern testing is covered in testFromResourceWithLabels |
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.
Left few nits. Maybe you could also add the new variable to the docs: https://github.com/strimzi/strimzi-kafka-operator/blob/main/documentation/modules/operators/ref-operator-cluster.adoc
operator-common/src/main/java/io/strimzi/operator/common/model/Labels.java
Outdated
Show resolved
Hide resolved
operator-common/src/main/java/io/strimzi/operator/common/model/Labels.java
Outdated
Show resolved
Hide resolved
operator-common/src/test/java/io/strimzi/operator/common/model/LabelsTest.java
Show resolved
Hide resolved
Signed-off-by: Kate Chernousova <[email protected]>
Hey @scholzj, thanks for the review, I fixed the filtering using matcher and updated the doc |
operator-common/src/main/java/io/strimzi/operator/common/model/Labels.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Kate Chernousova <[email protected]>
/azp run regression |
Commenter does not have sufficient privileges for PR 4791 in repo strimzi/strimzi-kafka-operator |
/azp run regression |
Azure Pipelines successfully started running 1 pipeline(s). |
@echernous Can you look at the regression test failures? It looks like |
Hi @scholzj , I ran the test locally and no issues found, also checked that it doesn't use the changed labels method. Pls could you trigger it again to see how it goes? Thank you! Here are some logs (removed some long output): |
Ok, I restarted it, so lets see if it helps. |
Signed-off-by: Kate Chernousova <[email protected]>
@scholzj , sorry I didn't run the test properly last time, now should be fixed. As statefulset labels specified under template are not being filtered anymore the test was failing. |
/azp run regression |
Azure Pipelines successfully started running 1 pipeline(s). |
Wait, so ... what was the problem? It looks like you just changed the test, but that means something changed in the code and it behaves differently now with the default settings? |
Yes, it doesn't filter labels under template sections anymore (it still will throw an exception if labels start with strimzi domain), The current implementation
After this change
Additionally kubernetes resources will have custom configured labels using templates which are filtered by:
The |
So does that impact all templates? Or only the PVC template? I wonder if this new behaviour is ok for us or not ... it is a change from how it behaved before. @strimzi/maintainers WDYT? |
Hi @scholzj , yes, it will affect all templates. However, I believe impact on labels that are assigned through templates would be minimum as only |
so maybe the default regex for the filter should be empty? In that case, the behaviour should remain as it was if I understand correctly |
@Frawless No, if I understood it correctly, the previous behavior was that these were always filtered out? And now they are used regardless the regex? |
In that case, we should keep the behavior I think. Like always extend the regex with this default value for kube-specific labels. |
In this change the regex doesn't affect labels in templates as they are custom labels specified per resource, there is no propagation to multiple resources so no need to filter (users can just remove unwanted label from template configuration). The regex is applied to Kafka metadata labels to control which labels should be applied to its subresources. |
Type of change
Description
Addresses the following issue #4394
This change allows strimzi users to control which parent CR labels they want to be used in subresources by setting the "STRIMZI_LABELS_EXCLUSION_PATTERN" environment variable (strimzi cluster operator deployment) with an exclusion regex pattern as its value, for example:
The exclusion pattern will only be used to filter labels when parent CR labels are being assigned to its subresources. Strimzi or templates metadata such as spec.kafka.template.pod.metadata.labels labels won't be affected.
Default exclusion pattern is "^app.kubernetes.io/(?!part-of).*" which matches previously configured filtering to minimise impact.
Checklist