Skip to content

sync: support configurable deletion propagation - #180

Merged
kcp-ci-bot merged 2 commits into
kcp-dev:mainfrom
sudo-amine:feature/deletion-propagation-policy
Aug 19, 2026
Merged

sync: support configurable deletion propagation#180
kcp-ci-bot merged 2 commits into
kcp-dev:mainfrom
sudo-amine:feature/deletion-propagation-policy

Conversation

@sudo-amine

@sudo-amine sudo-amine commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Today the Sync Agent always deletes a service-cluster copy with background propagation when its kcp source object is deleted. There is no way for a user to request foreground or orphan deletion for an individual object.

This PR lets the kcp source object opt into a different policy via an annotation:

kubectl annotate <resource> <name> \
  syncagent.kcp.io/deletion-propagation-policy=foreground
  • Supported values: background, foreground, orphan.
  • Missing or unsupported values fall back to background (unchanged default behavior).
  • The annotation is not copied to the service-cluster object — it only ever lives on the kcp source.

For related resources, the policy is resolved per-object:

  • kcp-origin related resources read the policy from their own annotation, same as the primary object.
  • service-origin related resources are unaffected and keep using background.

Design rationale

A few alternatives were considered and rejected:

  • Inferring the policy from the kcp DELETE request itself. Kubernetes does not persist DeleteOptions.PropagationPolicy on the object, so there is nothing durable for the Agent to read back later. A deterministic handshake would need changes to kcp's generic storage deletion path to capture and persist that option — coupling low-level kcp storage behavior to an Agent-specific protocol, plus finalizer rollout/lifecycle work on existing objects.
  • Capturing the policy via an admission webhook. Adds cluster-level configuration, permissions, and deployment/ownership concerns, especially awkward when multiple agents share the same API source.
  • Adding the policy as a field on PublishedResource. Would require an API change, and PublishedResource applies to every object of a kind — a poor fit for a policy that needs to vary per individual object.

The annotation is intentionally narrow and explicit: it stores the policy on the source object where it stays observable until cleanup, requires no API/storage/admission changes, and leaves the existing finalizer lifecycle untouched.

What Type of PR Is This?

/kind feature

Related Issue(s)

Fixes #174

Release Notes

Kcp source objects can now opt into `foreground` or `orphan` deletion propagation for their service-cluster copy via the `syncagent.kcp.io/deletion-propagation-policy` annotation. Defaults to `background` (unchanged).

@kcp-ci-bot kcp-ci-bot added 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. dco-signoff: yes Indicates the PR's author has signed the DCO. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 16, 2026
@kcp-ci-bot

Copy link
Copy Markdown
Contributor

Hi @sudo-amine. Thanks for your PR.

I'm waiting for a kcp-dev member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kcp-ci-bot kcp-ci-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 16, 2026
@sudo-amine
sudo-amine force-pushed the feature/deletion-propagation-policy branch 2 times, most recently from 86b6229 to 27965d3 Compare July 16, 2026 19:49

@mjudeikis mjudeikis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks ok to me, but I would like @xrstf to check it as he knows this way way better

@mjudeikis

Copy link
Copy Markdown
Contributor

/ok-to-test

@kcp-ci-bot kcp-ci-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 21, 2026
Use an annotation on kcp source objects to select the propagation policy for
deleting service-cluster copies.

Keep background propagation as the default and resolve kcp-origin related
resources from their own annotations.

Signed-off-by: Amine HADRI <amine.hadri.mba@gmail.com>
@sudo-amine
sudo-amine force-pushed the feature/deletion-propagation-policy branch from 27965d3 to a42b8b7 Compare August 17, 2026 21:33
@kcp-ci-bot kcp-ci-bot added dco-signoff: no Indicates the PR's author has not signed the DCO. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. dco-signoff: yes Indicates the PR's author has signed the DCO. labels Aug 17, 2026
golangci-lint's predeclared linter flags local variables named copy
since it shadows the builtin. Rename to copyObj to fix the lint job.

Signed-off-by: Amine HADRI <amine.hadri.mba@gmail.com>
@sudo-amine
sudo-amine force-pushed the feature/deletion-propagation-policy branch from 1609776 to dc31167 Compare August 18, 2026 09:11
@kcp-ci-bot kcp-ci-bot added dco-signoff: yes Indicates the PR's author has signed the DCO. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed dco-signoff: no Indicates the PR's author has not signed the DCO. release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Aug 18, 2026
@xrstf

xrstf commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

/approve
/lgtm

@kcp-ci-bot kcp-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 19, 2026
@kcp-ci-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: xrstf

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

The pull request process is described 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

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: d1d2155f6dbe435ffc93167c234f9202e9a163d1

@kcp-ci-bot kcp-ci-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 19, 2026
@kcp-ci-bot
kcp-ci-bot merged commit ff4bf82 into kcp-dev:main Aug 19, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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: support foreground deletion propagation policy

4 participants