-
Notifications
You must be signed in to change notification settings - Fork 10
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-3587] Old secret field translations (issue #140) #141
base: main
Are you sure you want to change the base?
Conversation
238018b
to
05bde73
Compare
05bde73
to
ba1c965
Compare
return self._fetch_relation_data_with_secrets( | ||
self.component, self.secret_fields, relation, fields | ||
) | ||
|
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.
This function is not needed for DataPeer
, cleaning it up
secret_fields_passed = set(self.secret_fields) & set(fields) | ||
for field in secret_fields_passed: | ||
if self._fetch_relation_data_without_secrets(self.component, relation, [field]): | ||
self._delete_relation_data_without_secrets(self.component, relation, [field]) |
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 above function got "re-grouped" to the suited block, with mild modifications
logger.error( | ||
"Non-existing secret %s was attempted to be removed.", | ||
", ".join(non_existent), | ||
) |
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 checks above are now moved to aonther 'backwards compatiblity' (bc) function
self._secrets.pop(label) | ||
else: | ||
logging.error("Non-existing Juju Secret was attempted to be removed %s", 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.
The two changes above are a small but important bugfix. Used at secret deletion below.
Problem
This PR is targeting the issue where we have to use different secret fields than what we had in the databag.
Typically
ca
(short) orauth_cfg
(_
not permitted) are currently "manyally" translated on the charm's side.The difference between old/new names typically causes an issue for rolling upgrades. Currently PG charms and soon upcoming Zookeeper would be impacted by this issue.
After a LOT of thinking, the lib seemed to be the right place to hold this logic, as it's already handling the rest of the backwards compatibility functionalities (typically for rolling upgrades). The current code is already following through changes like moving sensitive data from databag to secrets, or to move from a secret URI (stored in databag) to secret labels. Since the translation problem is strongly related to the former, the logic should go to the lib. Even though I'm not happy about this extra complexity at all :-/
Implementation
I chose to take a mapping as a parameter, as this should cover existing use-cases. The other option would have been to add a user-defined translation function, however that feels a lot less safe (i.e. introducting bugs on secrets!!!) than a straightforward mapping. Note that the current scheme is easily extendible to take both options.
POC (Pgbouncer)
The POC of this working with Pgbouncer (one of the main requestors of the feature) can be found here: canonical/pgbouncer-operator#149
Let me know what you think.