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

Fix for 'avoidNamespaces' field updates #157

Merged
merged 6 commits into from
Feb 7, 2025

Conversation

tr-aheiev
Copy link

This is simple fix for issue 93. It adds an additional '@kopf.on.field' decorator for update events on 'avoidNamespaces' field. After this PR all tests are passed successfully.

@@ -50,8 +50,9 @@ def on_delete(
logger.debug(f'csec {uid} deleted from memory ok')


@kopf.on.field('clustersecret.io', 'v1', 'clustersecrets', field='avoidNamespaces')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you think we could have a conformance test ensuring this change work as expected ?

Copy link
Author

@tr-aheiev tr-aheiev Jan 21, 2025

Choose a reason for hiding this comment

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

Do you think we could have a conformance test ensuring this change work as expected ?

Yes, we can have some test. I will check current tests and try to add something there.

@tr-aheiev
Copy link
Author

While writing test for 'avoidNamespaces' I found a big bug. If the 'ClusterSecret' object previously did not contain 'matchNamespace' or 'avoidNamespaces' fields, the 'on_fields_avoid_or_match_namespace' function would ignore the event. It was the same before my changes, but I will rewrite the logic and then will update this PR

@tr-aheiev tr-aheiev force-pushed the fix-avoidnamespaces-changes branch from 01c0bb0 to e4489b4 Compare January 21, 2025 22:54
@tr-aheiev
Copy link
Author

Code updated.
I fixed problem with events when 'ClusterSecret' previously did not contain 'matchNamespace' or 'avoidNamespaces' fields - simply by checking the operation type instead of old version of the field.
I refactored the 'validate_namespace_secrets' function in tests. Not sure that here the place for those changes, but without them next commit with test for 'avoidNamespaces' will not work - there need to check that secret is missing in exact namespace, but current 'validate_namespace_secrets' can only check that secret exists in any namespace or exists in particular namespaces.

@tr-aheiev tr-aheiev force-pushed the fix-avoidnamespaces-changes branch from e4489b4 to 3e1fadc Compare February 6, 2025 22:19
@tr-aheiev
Copy link
Author

Another update to last changes in master and bumped helm chart version to pass the tests.

Copy link
Collaborator

@axel7083 axel7083 left a comment

Choose a reason for hiding this comment

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

LGTM, clean code, waiting for the tests to be ✅

@axel7083
Copy link
Collaborator

axel7083 commented Feb 7, 2025

All tests are ✅ merging

@axel7083 axel7083 merged commit 676e6a0 into zakkg3:master Feb 7, 2025
14 checks passed
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.

2 participants