Skip to content

Cleanup Grace Period

Deleting a SveltosCluster normally removes it right away: unlike a ClusterAPI Cluster, there is no infrastructure provider holding a finalizer on it, so nothing keeps the object around during teardown.

That is fine for the SveltosCluster object itself, but it also means nothing else gets a chance to react while it still exists. In particular, the event-driven cleanup pattern that lets you run a Job in the management cluster while a cluster is deleting depends on the cluster object still being there, with a deletionTimestamp, long enough to be evaluated.

SveltosCluster.Spec.CleanupGracePeriod closes that gap. When set, Sveltos holds its own finalizer on the SveltosCluster for that long after deletion is requested, before actually removing it:

apiVersion: lib.projectsveltos.io/v1beta1
kind: SveltosCluster
metadata:
  name: prod-cluster
  namespace: civo
spec:
  cleanupGracePeriod: 10m

With this set, deleting prod-cluster keeps the SveltosCluster present (with metadata.deletionTimestamp set) for 10 minutes before Sveltos removes it, instead of disappearing immediately.

Note

This field is optional and nil by default. If it is not set, a SveltosCluster is removed immediately on deletion, exactly as before this field existed.

By itself, this only delays removal; it does not run any cleanup. Pair it with an EventSource/EventTrigger using includeDeletingResources: true against this SveltosCluster to actually act during that window. See Event Driven Cleanup on Cluster Deletion.