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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

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

tymuraheiev added 3 commits January 22, 2025 00:47
…mespaces' was missing before they updates

Removed unnecessary cache checking - it always will be empty for 'resume' and 'create' events
@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.

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