Closed auria closed 3 years ago
Actually, this is expected behavior because the tls-certificates
interface layer manages that flag, setting it when the relation is joined and clearing it when the relation is not joined. If you try with a different flag which is not managed by the code, you should see the behavior you expect.
When I use
set_flag
from a reactive script, the created state will be persistent after Juju hooks are run. However, if I runcharms.reactive set_flag <state>
viajuju run -u unit/N
, theupdate-status
hook will finish clearing the created state.Please find below how I reproduced it:
layer.yaml
content:Once the test application is deployed, I run an initial test:
set_flag
from the CLI:sqlite> select * from kv; reactive.dispatch.removed_state|true reactive.dispatch.phase|"other" reactive.states.certificates.available|null reactive.state_watch|{"iteration": 0, "changes": [], "pending": ["certificates.available"]}
$ juju run -u testflags/0 hooks/update-status $ juju debug-log unit-testflags-0: 11:54:23 DEBUG juju.worker.uniter.remotestate got action change for testflags/0: [56] ok=true unit-testflags-0: 11:54:23 DEBUG juju.worker.uniter.operation running operation run action 56 for testflags/0 unit-testflags-0: 11:54:23 DEBUG juju.machinelock acquire machine lock for testflags/0 uniter (run action 56) unit-testflags-0: 11:54:23 DEBUG juju.machinelock machine lock acquired for testflags/0 uniter (run action 56) unit-testflags-0: 11:54:23 DEBUG juju.worker.uniter.operation preparing operation "run action 56" for testflags/0 unit-testflags-0: 11:54:23 DEBUG juju.worker.uniter.operation executing operation "run action 56" for testflags/0 unit-testflags-0: 11:54:23 DEBUG juju.worker.uniter [AGENT-STATUS] executing: running action juju-run unit-testflags-0: 11:54:23 DEBUG juju.worker.uniter.runner juju-run action is running unit-testflags-0: 11:54:23 DEBUG juju.worker.uniter.runner starting jujuc server {unix @/var/lib/juju/agents/unit-testflags-0/agent.socket}
unit-testflags-0: 11:54:23 DEBUG jujuc running hook tool "juju-log" for testflags/0-juju-run-3865382029819934043
unit-testflags-0: 11:54:23 INFO unit.testflags/0.juju-log Reactive main running for hook
unit-testflags-0: 11:54:23 DEBUG jujuc running hook tool "config-get" for testflags/0-juju-run-3865382029819934043
unit-testflags-0: 11:54:23 DEBUG jujuc running hook tool "relation-ids" for testflags/0-juju-run-3865382029819934043
unit-testflags-0: 11:54:23 DEBUG jujuc running hook tool "juju-log" for testflags/0-juju-run-3865382029819934043
unit-testflags-0: 11:54:23 DEBUG unit.testflags/0.juju-log tracer>
tracer: starting handler dispatch, 1 flags set
tracer: set flag certificates.available
unit-testflags-0: 11:54:23 DEBUG jujuc running hook tool "juju-log" for testflags/0-juju-run-3865382029819934043
unit-testflags-0: 11:54:23 DEBUG unit.testflags/0.juju-log tracer: hooks phase, 0 handlers queued
unit-testflags-0: 11:54:23 DEBUG jujuc running hook tool "juju-log" for testflags/0-juju-run-3865382029819934043
unit-testflags-0: 11:54:23 DEBUG unit.testflags/0.juju-log tracer>
tracer: main dispatch loop, 1 handlers queued
tracer: ++ queue handler hooks/relations/tls-certificates/requires.py:109:broken:certificates
unit-testflags-0: 11:54:23 DEBUG jujuc running hook tool "juju-log" for testflags/0-juju-run-3865382029819934043
unit-testflags-0: 11:54:23 INFO unit.testflags/0.juju-log Invoking reactive handler: hooks/relations/tls-certificates/requires.py:109:broken:certificates
unit-testflags-0: 11:54:23 DEBUG jujuc running hook tool "juju-log" for testflags/0-juju-run-3865382029819934043
unit-testflags-0: 11:54:23 DEBUG unit.testflags/0.juju-log tracer: cleared flag certificates.available
unit-testflags-0: 11:54:23 DEBUG jujuc running hook tool "juju-log" for testflags/0-juju-run-3865382029819934043
unit-testflags-0: 11:54:23 INFO unit.testflags/0.juju-log Assess status => Missing relations: certificates
unit-testflags-0: 11:54:23 DEBUG juju.worker.uniter.operation committing operation "run action 56" for testflags/0
unit-testflags-0: 11:54:23 DEBUG juju.machinelock machine lock released for testflags/0 uniter (run action 56)
unit-testflags-0: 11:54:23 DEBUG juju.worker.uniter.operation lock released for testflags/0
unit-testflags-0: 11:54:23 DEBUG juju.worker.uniter no operations in progress; waiting for changes
unit-testflags-0: 11:54:23 DEBUG juju.worker.uniter [AGENT-STATUS] idle:
$ juju run -u testflags/0 -- charms.reactive get_flags $
sqlite> select * from kv; reactive.dispatch.removed_state|true reactive.dispatch.phase|"other"