Skip to content

Watch and sync changes to related resources#148

Open
iakmc wants to merge 1 commit intokcp-dev:mainfrom
iakmc:related-kcp-resources-watch
Open

Watch and sync changes to related resources#148
iakmc wants to merge 1 commit intokcp-dev:mainfrom
iakmc:related-kcp-resources-watch

Conversation

@iakmc
Copy link

@iakmc iakmc commented Mar 12, 2026

Summary

Previously, changes to related resources with origin: kcp (e.g. a
ConfigMap 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-side
    related object (cluster, group, resource, namespace, name) back to
    its owning primary object. Uses a struct as the map key instead of
    string concatenation.
  • Index population: during reconciliation of the primary object, all
    resolved origin: kcp related objects are registered in the index.
  • MultiClusterWatch per related resource type: when a related object
    changes 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

NONE

@kcp-ci-bot kcp-ci-bot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. dco-signoff: yes Indicates the PR's author has signed the DCO. labels Mar 12, 2026
@kcp-ci-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign embik for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kcp-ci-bot kcp-ci-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 12, 2026
@xrstf
Copy link
Contributor

xrstf commented Mar 13, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. kind/feature Categorizes issue or PR as related to a new feature. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: SyncAgent does not detect relatedResource changes

3 participants