Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Means to wait for an app to really be removed #656

Closed
sed-i opened this issue Mar 23, 2022 · 1 comment · Fixed by #665
Closed

Means to wait for an app to really be removed #656

sed-i opened this issue Mar 23, 2022 · 1 comment · Fixed by #665
Labels
priority/low low priority

Comments

@sed-i
Copy link
Contributor

sed-i commented Mar 23, 2022

Awaiting Application.remove does not guarantee the application is "fully" removed: when I try to deploy the same app after it is removed, I get juju.errors.JujuError: ['cannot add application "related-app": application already exists'].

Currently I use this pattern:

    await ops_test.model.applications[related_app.name].remove()
    # Block until it is really gone. Added after an itest failed when tried to redeploy:
    # juju.errors.JujuError: ['cannot add application "related-app": application already exists']
    await ops_test.model.block_until(lambda: related_app.name not in ops_test.model.applications)

It would be handy if, for example, Application.remove took a bool flag such as wait_for_removal.

@cderici
Copy link
Contributor

cderici commented Mar 23, 2022

I feel like this might be useful for more than just the remove, thanks for the suggestion!

@cderici cderici added the priority/low low priority label Mar 23, 2022
cderici added a commit to cderici/python-libjuju that referenced this issue Apr 6, 2022
jujubot added a commit that referenced this issue Apr 19, 2022
#665

#### Description

This is to make life easier by allowing the following pattern:

```python
 await ops_test.model.applications[related_app.name].remove()
 # Block until it is really gone. Added after an itest failed when tried to redeploy:
 # juju.errors.JujuError: ['cannot add application "related-app": application already exists']
 await ops_test.model.block_until(lambda: related_app.name not in ops_test.model.applications)
```

to be written as:

```python
 await ops_test.model.remove_application(related_app.name, block_until_done=True)
```


Fixes #656 

#### QA Steps

```sh
tox -e integration -- tests/integration/test_application.py::test_app_remove_wait_flag
```

#### Notes & Discussion

Another option would be to do `await ops_test.model.applications[related_app.name].remove(block_until_done=True)`, however, then it gets weird to ask the `app.model` to `block_until` the `app.name` is no longer in `model.applications` while the `app` object is being torn down.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/low low priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants