Skip to content

Add SyncStatus field to RelatedResourceSpec#175

Open
iakmc wants to merge 2 commits into
kcp-dev:mainfrom
iakmc:sync-status-for-related-resources
Open

Add SyncStatus field to RelatedResourceSpec#175
iakmc wants to merge 2 commits into
kcp-dev:mainfrom
iakmc:sync-status-for-related-resources

Conversation

@iakmc

@iakmc iakmc commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a syncStatus field to RelatedResourceSpec. When set to true, the status subresource of a related object is synced in the same direction as its spec:

  • origin: kcp -> status flows kcp -> service cluster
  • origin: service -> status flows service cluster -> kcp

This is independent of the existing syncStatusBack behavior on primary resources (which always syncs status in the reverse direction).

Example

related:
  - identifier: subnet
    origin: kcp
    group: kcp.example.com
    version: v1
    resource: subnets
    syncStatus: true   # kcp status -> service cluster

Changes

  • sdk/apis/syncagent/v1alpha1/published_resource.go - new SyncStatus bool on RelatedResourceSpec; doc comment recommends configuring Watch when origin: service to ensure status changes trigger reconciliation
  • internal/sync/object_syncer.go - new syncStatusForward field and syncObjectStatusForward() method; called unconditionally from syncObjectContents() so a simultaneous spec+status change doesn't defer the status sync by one reconciliation cycle; includes a 404 guard that emits a Warning event instead of error-looping when the destination CRD has no status subresource
  • internal/sync/object_syncer_test.go - unit tests for syncObjectStatusForward() (5 sub-tests covering no-op conditions, happy path, and 404 guard) and syncObjectContents() status-runs-even-on-spec-requeue invariant
  • internal/sync/syncer_related.go - wires SyncStatus into objectSyncer: sets syncStatusForward and adds "status" to subresources
  • deploy/crd/kcp.io/syncagent.kcp.io_publishedresources.yaml - regenerated CRD
  • test/crds/subnet.yaml - new test CRD with status subresource
  • test/e2e/sync/related_status_test.go - three e2e tests

Testing

Unit tests (make test) — all pass, including 6 new sub-tests in TestSyncObjectStatusForward and TestSyncObjectContentsForwardStatusRunsEvenOnSpecRequeue

Focused e2e — three new tests covering the happy paths and the default-off behavior:

go test -tags e2e -run "TestSyncRelatedObjectStatus" ./test/e2e/sync/
--- PASS: TestSyncRelatedObjectStatusFromKcp     (29s)
--- PASS: TestSyncRelatedObjectStatusFromService (18s)
--- PASS: TestSyncRelatedObjectStatusNotSyncedByDefault (27s)

Full e2e (make test-e2e) — 38/39 pass; the one failure (TestAPIExportEndpointSliceDifferentCluster) is pre-existing and unrelated to this change.

What Type of PR Is This?

/kind feature

Related Issue(s)

Fixes #173

Release Notes

Status sync for related resources: set syncStatus: true on a RelatedResourceSpec to sync the status subresource in the same direction as the spec. For origin: kcp status flows kcp -> service cluster; for origin: service it flows service cluster -> kcp.

@kcp-ci-bot kcp-ci-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. 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 Jun 29, 2026
@kcp-ci-bot

Copy link
Copy Markdown
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jun 29, 2026
@iakmc iakmc force-pushed the sync-status-for-related-resources branch from cfd1dd0 to 64562ba Compare June 29, 2026 23:00
@kcp-ci-bot kcp-ci-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 29, 2026
@iakmc

iakmc commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

/test pull-api-syncagent-verify

iakmc added 2 commits June 30, 2026 12:06
Signed-off-by: Iskren <iskren@kubermatic.com>

some codeverify fixes

sdk changes

Signed-off-by: Iskren <iskren@kubermatic.com>
…atusForward

Signed-off-by: Iskren <iskren@kubermatic.com>
@iakmc iakmc force-pushed the sync-status-for-related-resources branch from 31a3e65 to 2d838c5 Compare June 30, 2026 09:06
return false, fmt.Errorf("failed to update destination object status: %w", err)
}

s.recordEvent(ctx, source, dest, corev1.EventTypeNormal, "ObjectStatusSynced", "The current object status has been synchronized to the destination.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This feels rather noisy, since status subresources tend to change frequently due to e.g. timestamps. I think it doesn't make sense to emit this event?

return false, nil
}

func (s *objectSyncer) syncObjectStatusForward(ctx context.Context, log *zap.SugaredLogger, source, dest syncSide) (requeue bool, err error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This only ever returns false for requeue and the call site doesn't use it, so I think it can safely be dropped.

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 Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: sync status of related resources

3 participants