loft-sh / vcluster

vCluster - Create fully functional virtual Kubernetes clusters - Each vcluster runs inside a namespace of the underlying k8s cluster. It's cheaper than creating separate full-blown clusters and it offers better multi-tenancy and isolation than regular namespaces.
https://www.vcluster.com
Apache License 2.0
6.92k stars 426 forks source link

Prevent recreating virtual cluster resource during delete #2241

Closed lizardruss closed 4 weeks ago

lizardruss commented 1 month ago

What issue type does this pull request address? (keep at least one, remove the others) /kind bugfix

What does this pull request do? Which issues does it resolve? (use resolves #<issue_number> if possible) resolves ENG-4924

Please provide a short message that should be published in the vcluster release notes Fixed an issue where the vcluster syncer would mistakenly re-create a resource when reconciling the update event that adds the deletionTimestamp

What else do we need to know?

Scenario

The syncer incorrectly re-creates a resource while it's being deleted. The sequence of events observed:

This scenario occurs more frequently with pods, but the solution has been made generic in case it occurs with different resource kinds.

Solution

Add a PendingDelete event type to communicate that an update event occurred to a virtual resource being deleted. If the SyncToVirtual flow is reached by an event where the source == Virtual and the type == PendingDelete, then skip calling SyncToVirtual.

netlify[bot] commented 1 month ago

Deploy Preview for vcluster-docs canceled.

Name Link
Latest commit 6cdab637e489827ff7727a827a1ffafe151b5e73
Latest deploy log https://app.netlify.com/sites/vcluster-docs/deploys/67198d780587ce00080c68f9