Juju secrets not found in scale down event after removing application
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Fix Released
|
High
|
Ian Booth |
Bug Description
Juju version: 3.1.5-genericli
lxd version: 5.0.2
Juju agent version: 3.1.5
The MySQL charm relies on the scale down events to correctly shut down, which in turn requires access to the secrets in these events. We run into the following exception (which indicates secrets are not found) after running `juju remove-application mysql` but not after `juju remove-unit mysql/1`. When are juju secrets removed after a `remove-
Steps to reproduce:
```
$ git clone <email address hidden>
$ charmcraft pack
$ juju add-model dev
$ juju deploy -n 1 ./secrets-
$ juju run secrets/0 --wait=0s set-secret key=test-key value=test-value
Running operation 1 with 1 task
- task 2 on unit-secrets-0
Waiting for task 2...
$ juju run secrets/0 --wait=0s get-secrets
Running operation 3 with 1 task
- task 4 on unit-secrets-0
Waiting for task 4...
secrets:
test-key: test-value
$ juju remove-application secrets
will remove application secrets
- will remove unit secrets/0
- will remove storage database/0
```
Error trace:
```
machine-0: 14:20:41 INFO juju.downloader download complete ("local:
machine-0: 14:20:41 INFO juju.downloader download verified ("local:
machine-0: 14:20:44 INFO juju.container.lxd Availability zone will be empty for this container manager
machine-0: 14:20:45 INFO juju.worker.
unit-secrets-0: 14:20:50 INFO juju.worker.uniter hooks are retried true
unit-secrets-0: 14:20:51 INFO juju.worker.
unit-secrets-0: 14:20:51 INFO juju.worker.
unit-secrets-0: 14:20:51 INFO unit.secrets/
unit-secrets-0: 14:20:51 INFO juju.worker.
unit-secrets-0: 14:20:52 INFO juju.worker.
unit-secrets-0: 14:20:52 INFO juju.worker.uniter found queued "leader-elected" hook
unit-secrets-0: 14:20:52 INFO juju.worker.
unit-secrets-0: 14:20:53 INFO juju.worker.
unit-secrets-0: 14:20:53 INFO juju.worker.uniter found queued "start" hook
unit-secrets-0: 14:20:53 INFO unit.secrets/
unit-secrets-0: 14:20:53 INFO juju.worker.
unit-secrets-0: 14:21:18 INFO unit.secrets/
unit-secrets-0: 14:21:19 INFO juju.worker.
unit-secrets-0: 14:21:27 INFO unit.secrets/
machine-0: 14:21:41 INFO juju.worker.
unit-secrets-0: 14:21:41 WARNING juju.worker.
unit-secrets-0: 14:21:41 INFO unit.secrets/
unit-secrets-0: 14:21:41 ERROR unit.secrets/
Traceback (most recent call last):
File "/var/lib/
result = subprocess.
File "/usr/lib/
raise CalledProcessEr
subprocess.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lib/
result = self._run(
File "/var/lib/
raise ModelError(
ops.model.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/var/lib/
content = self._backend.
File "/var/lib/
raise SecretNotFoundE
ops.model.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lib/
result = subprocess.
File "/usr/lib/
raise CalledProcessEr
subprocess.
s 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lib/
return self._run(*args, return_
File "/var/lib/
raise ModelError(
ops.model.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/var/lib/
ops.
File "/var/lib/
return main(charm_class, use_juju_
File "/var/lib/
_emit_
File "/var/lib/
event_
File "/var/lib/
framework.
File "/var/lib/
self.
File "/var/lib/
custom_
File "/var/lib/
secrets = self.get_secrets()
File "/var/lib/
secret = self.model.
File "/var/lib/
info = self._backend.
File "/var/lib/
result = self._run_
File "/var/lib/
raise SecretNotFoundE
ops.model.
unit-secrets-0: 14:21:41 ERROR juju.worker.
```
Changed in juju: | |
status: | Triaged → In Progress |
Changed in juju: | |
status: | Fix Committed → Fix Released |
Secrets are currently removed when an application has finished the transition to life=Dying. This is also when things like status history are removed.
Based on this bug, we should defer secret removal until the after the application has transitioned to Dead.