Skip to content

feature request: add support for providing propagationPolicy (i.e orphan) when deleting immutable resources #603

@mdnfiras

Description

@mdnfiras

When setting the kustomize.toolkit.fluxcd.io/force: enabled label for statefulsets, flux will delete the statefulset if it detects an immutable field error. This will delete all the statefulset's pods as a result due to kubernetes garbage collection.

As a workaround, an admission webhook can mutate pods' metadata.ownerReferences to be empty during pod creation, but admission webhooks are risky: if they fail (service is down, or throwing unhandled exceptions) they block the creation of pods, and if set to be ignored upon failure then we would risk flux deleting a statefulset and its pods all at once.

I think that a proper solution would be to add support to set the propagationPolicy of the deleteOptions in the delete request that flux makes. This can be set for example through an annotation like kustomize.toolkit.fluxcd.io/propagationPolicy: orphan in the same resource that has kustomize.toolkit.fluxcd.io/force: enabled:

  • if the label kustomize.toolkit.fluxcd.io/force: enabled is set, then the annotation kustomize.toolkit.fluxcd.io/propagationPolicy is checked
  • if the annotation kustomize.toolkit.fluxcd.io/propagationPolicy does not exist, the default policy is used, which is background
  • if the annotation kustomize.toolkit.fluxcd.io/propagationPolicy is set to background, foreground or orphan then this value will be used in the delete request
  • if the annotation kustomize.toolkit.fluxcd.io/propagationPolicy is set to anything other than those values, the controller can throw an error during reconciliation dry-run.

what do you think about this feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions