Add SyncStatus field to RelatedResourceSpec#175
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 |
cfd1dd0 to
64562ba
Compare
|
/test pull-api-syncagent-verify |
64562ba to
31a3e65
Compare
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>
31a3e65 to
2d838c5
Compare
| 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.") |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
This only ever returns false for requeue and the call site doesn't use it, so I think it can safely be dropped.
Summary
Adds a
syncStatusfield toRelatedResourceSpec. When set totrue, the status subresource of a related object is synced in the same direction as its spec:origin: kcp-> status flows kcp -> service clusterorigin: service-> status flows service cluster -> kcpThis is independent of the existing
syncStatusBackbehavior on primary resources (which always syncs status in the reverse direction).Example
Changes
sdk/apis/syncagent/v1alpha1/published_resource.go- newSyncStatus boolonRelatedResourceSpec; doc comment recommends configuringWatchwhenorigin: serviceto ensure status changes trigger reconciliationinternal/sync/object_syncer.go- newsyncStatusForwardfield andsyncObjectStatusForward()method; called unconditionally fromsyncObjectContents()so a simultaneous spec+status change doesn't defer the status sync by one reconciliation cycle; includes a 404 guard that emits aWarningevent instead of error-looping when the destination CRD has no status subresourceinternal/sync/object_syncer_test.go- unit tests forsyncObjectStatusForward()(5 sub-tests covering no-op conditions, happy path, and 404 guard) andsyncObjectContents()status-runs-even-on-spec-requeue invariantinternal/sync/syncer_related.go- wiresSyncStatusintoobjectSyncer: setssyncStatusForwardand adds"status"tosubresourcesdeploy/crd/kcp.io/syncagent.kcp.io_publishedresources.yaml- regenerated CRDtest/crds/subnet.yaml- new test CRD with status subresourcetest/e2e/sync/related_status_test.go- three e2e testsTesting
Unit tests (
make test) — all pass, including 6 new sub-tests inTestSyncObjectStatusForwardandTestSyncObjectContentsForwardStatusRunsEvenOnSpecRequeueFocused e2e — three new tests covering the happy paths and the default-off behavior:
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