Skip to content

Ansible: how to prevent CR deletion on finalizer playbook failure #2546

@tomsucho

Description

@tomsucho

Type of question

how to implement a specific feature

Question

What did you do?
When deleting a Custom Resource(CR) object the relevant playbook is executed (as per my finalizer dict config in watches.yml) however the CR is deleted from k8s no matter what happens in the playbook i.e. even if it fails. This causes inconsistent state, in which CR is no longer present in k8s, but the underlaying/related resources which live outside of the cluster are not really cleaned up properly. I was hoping that if the playbook fails, then the finalizer is not going to be removed, which will keep the resource object in k8s. If that would be the case, then I could use k8_status from the playbook to flag to end user that deletion and related cleanup actions didn't succeed and the user would be able to manually clean up things and then edit the resource and remove the finalizer manually for the delete process to complete. Could you please advise how to achieve this?
BTW> I'm using "manageStatus: False"

What did you expect to see?
CR not deleted from k8s in case finalizer linked playbook fails

What did you see instead? Under which circumstances?
CR is deleted from k8s no matter that finalizer linked playbook failed to complete all its actions

Environment

  • operator-sdk version:
    quay.io/operator-framework/ansible-operator:v0.15.1

    insert release or Git SHA here

  • Kubernetes version information:

    insert output of kubectl version here

  • Kubernetes cluster kind:

Additional context
Add any other context about the question here.

Metadata

Metadata

Labels

language/ansibleIssue is related to an Ansible operator projecttriage/supportIndicates an issue that is a support question.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions