Watch and sync changes to related resources#148
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
I think this is the completely wrong approach to solving this. This method has no way of handling label-selector-based related resources, for which the agent cannot possibly know that an objects belongs to the primary object. That's why in the original ticket I suggested that we need extra configuration, to allow the agent to inverse the relationship between primary and related object (i.e. so that it can tell, just from looking at a Secret, which primary object that Secret belongs to). This index would just grow and grow and grow over time and not even notice anything that's not an immediate reference. |
Summary
Previously, changes to related resources with
origin: kcp(e.g. aConfigMap created by a user in a kcp workspace) were ignored — only
changes to the primary object triggered reconciliation.
This adds:
RelatedObjectIndex: an in-memory reverse index mapping each kcp-siderelated object
(cluster, group, resource, namespace, name)back toits owning primary object. Uses a struct as the map key instead of
string concatenation.
resolved
origin: kcprelated objects are registered in the index.MultiClusterWatchper related resource type: when a related objectchanges in kcp, the watch handler looks it up in the index and enqueues
the owning primary object for reconciliation, which then syncs the
updated related object to the service cluster.
Note: the index is empty after an agent restart. It is repopulated
naturally as primary objects are reconciled.
What Type of PR Is This?
/kind feature
Related Issue(s)
Fixes #118
Release Notes