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

Add uniter support for running the secret-changed hook #14457

Merged
merged 1 commit into from
Aug 12, 2022

Conversation

wallyworld
Copy link
Member

@wallyworld wallyworld commented Aug 12, 2022

This PR adds the support for running the secret-changed hook. Two new secrets manager api calls are added to allow the uniter to watch for secret changes and to ask for the most recent revision info.
The secrets resolved and local/remote state is updated to manage the known revision info.

Checklist

  • Code style: imports ordered, good names, simple structure, etc
  • Comments saying why design decisions were made
  • Go unit tests, with comments saying what you're testing
  • Integration tests, with comments saying what you're testing
  • doc.go added or updated in changed packages

QA steps

bootstrap and deploy the ubuntu charm
create a secret, eg

juju exec --unit ubuntu/0 "secret-add foo-bar
secret-get secret:cbqqf59esa1idj8gu59g

deploy a second charm with a secret-changed hook, eg

$ cat hooks/secret-changed 
#!/bin/bash
echo "secret-changed"
juju-log "secret-changed uri=$JUJU_SECRET_URI label=$JUJU_SECRET_LABEL"
exit 0

get the secret value

juju exec --unit consumer/0 "secret-get secret:cbqqf59esa1idj8gu59g --label baz"
foo=bar

check the logs - no secret changed hook
update the secret
juju exec --unit ubuntu/0 "secret-update secret:cbqqf59esa1idj8gu59g foo=bar2"

check the logs

INFO juju.worker.uniter.operation ran "secret-changed" hook (via explicit, bespoke hook script)
INFO unit.consumer/0.juju-log secret-changed uri=secret:cbqqf59esa1idj8gu59g label=baz

Copy link
Member

@ycliuhw ycliuhw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ty
Just a few suggestions

api/agent/secretsmanager/client.go Outdated Show resolved Hide resolved
api/agent/secretsmanager/client.go Show resolved Hide resolved
@wallyworld
Copy link
Member Author

/merge

@wallyworld
Copy link
Member Author

/merge

@jujubot jujubot merged commit 2906f39 into juju:develop Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants