Fix namespace deletion handling and add linked secret auto-sync#177
Draft
Fix namespace deletion handling and add linked secret auto-sync#177
Conversation
Co-authored-by: zakkg3 <25042095+zakkg3@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix namespaces deletion handling
Fix namespace deletion handling and add linked secret auto-sync
Mar 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Namespace deletions were not tracked by the operator, and updates to secrets referenced via
valueFromdid not trigger re-sync. This consolidates fixes from PR #159 and extends them with the auto-sync feature from PR #176.handlers.pynamespace_watcher: adds@kopf.on.deletedecorator andreasonparameter; handles bothcreate(sync secret into new namespace) anddelete(prune namespace fromsyncednsstatus and in-memory cache) events. Status is only patched when the namespace list actually changes.on_field_data: removes duplicated inline sync logic and the unusedmetaparameter — delegates directly tosync_secret.on_secret_update(new): watches allSecretupdates and re-syncs any ClusterSecret whosedata.valueFrom.secretKeyRefpoints to the changed secret:kubernetes_utils.pysync_secret: checks namespace existence upfront — returns early on 404, re-raises on other errors (handles race conditions at deletion time).rest.ApiException→exceptions.ApiExceptionindelete_secret,sync_secret, andget_custom_objects_by_kind.if/elifinto a single condition.Tests
test_on_field_data_ns_deleted— behaviour now covered bynamespace_watcher.reason="create"totest_ns_createcall to match updated signature.test_ns_deleteverifying deleted namespaces are pruned from both status and cache.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.