-
Notifications
You must be signed in to change notification settings - Fork 14
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
[DPE-2442] Add juju secrets support #242
Conversation
4ef75ad
to
b604378
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly nits :)
"""Helper function to get Juju secret.""" | ||
peer_data = self._peer_data(scope) | ||
|
||
if not peer_data.get(Config.Secrets.SECRET_INTERNAL_LABEL): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Peer data bag stores the Secret ID inside in SECRET_INTERNAL_LABEL
field.
The current code cannot retrieve the Secret object if we don't have the Secret ID (line 1126 below).
I think this part is going to be revoked in two weeks.
src/charm.py
Outdated
return self.secrets[scope][Config.Secrets.SECRET_LABEL].id | ||
|
||
def _juju_secrets_get(self, scope: Scopes) -> Optional[bool]: | ||
"""Helper function to get Juju secret.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function name can be better. in fact, it is just caching secret content into the internal dictionary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests should be consistent relying on the juju_has_secrets
autoreused fixture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
## Problem After implementing backups on K8s the libraries in each charm are out of sync. ## Solution Update the library code and update the charm to support these new changes ## Other changes Testing versions and requirements updates to solve depency issues in tests ## Future PRs The backup library has had substantial changes and so the old test suite is no longer supported. In a future PR these will be added. Failing TLS tests are resolved in #242 ## do NOT review these files - `lib/charms/mongodb/v0/helpers.py` - copy and paste from k8s charm - `lib/charms/mongodb/v0/mongodb_backups.py` - copy and paste from VM charm - `tests/unit/test_mongodb_backups.py` - removed as is now out of date, will be rewritten in a follow up PR
377ec57
to
e4200f1
Compare
Updated doc string Co-authored-by: Mia Altieri <[email protected]>
688f0e5
to
ea883c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work Dmitry :)
src/charm.py
Outdated
return self.secrets[scope][Config.Secrets.SECRET_LABEL].id | ||
|
||
def _juju_secrets_get(self, scope: Scopes) -> Optional[bool]: | ||
"""Helper function to get Juju secret.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like Judits docstring here, I think it explains the complexities that are going on. Unless you feel strongly about removing it.
src/charm.py
Outdated
return self.secrets[scope][Config.Secrets.SECRET_LABEL].id | ||
|
||
def _juju_secrets_get(self, scope: Scopes) -> Optional[bool]: | ||
"""Helper function to get Juju secret.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with myself and @MiaAltieri :-D
Could we pls use the more verbose (and actually correct 😅 ) docstring here?
I apologize for the original one, it's on me, I'll update it in k8s as well
Co-authored-by: Mia Altieri <[email protected]>
45456f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving under the condition to pls address outstanding issues in the following tickets:
https://warthogs.atlassian.net/browse/DPE-2609
https://warthogs.atlassian.net/browse/DPE-2610
https://warthogs.atlassian.net/browse/DPE-2611
https://warthogs.atlassian.net/browse/DPE-2612
|
||
secret_cache[key] = Config.Secrets.SECRET_DELETED_LABEL | ||
secret.set_content(secret_cache) | ||
logging.debug(f"Secret {scope}:{key}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we or improve the message here or remove it?
logging.debug(f"Secret {scope}:{key}") | |
logging.debug(f"Secret {scope}:{key} removed") |
Add support of juju secrets to the charm [DPE-2441](https://warthogs.atlassian.net/browse/DPE-2441) [DPE-2442](https://warthogs.atlassian.net/browse/DPE-2442) [DPE-2443](https://warthogs.atlassian.net/browse/DPE-2443) [DPE-2441]: https://warthogs.atlassian.net/browse/DPE-2441?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [DPE-2442]: https://warthogs.atlassian.net/browse/DPE-2442?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [DPE-2443]: https://warthogs.atlassian.net/browse/DPE-2443?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Dmitry Ratushnyy <[email protected]> Co-authored-by: Mia Altieri <[email protected]>
Issue
Add support of juju secrets to the charm
Related issues
DPE-2441
DPE-2442
DPE-2443