charmed-kubernetes / pytest-operator

Apache License 2.0
6 stars 13 forks source link

Exception thrown by juju prevents test model to be deleted during teardown #84

Open Mehdi-Bendriss opened 1 year ago

Mehdi-Bendriss commented 1 year ago

Context:

I have an integration test that deletes a kubernetes pod using either the kubectl command or lightkube (the issue happens with both) as follows

# Deleting the primary pod using kubectl
k8s_client = AsyncClient(namespace=ops_test.model_name)
await k8s_client.delete(Pod, name=replica_name)

The test suite passes successfully.

Issue:

During the pytest-operator's teardown operation, the following exception is thrown inconsistently :

INFO     pytest_operator.plugin:plugin.py:477 Juju error logs:
controller-0: 14:09:52 ERROR juju.worker.caasapplicationprovisioner.runner exited "mongodb-k8s": Operation cannot be fulfilled on pods "mongodb-k8s-0": the object has been modified; please apply your changes to the latest version and try again

And this results in the model created by the pytest-operator, not to be deleted and to be stuck on the destroying status until being force deleted manually.

Environment: