-
Notifications
You must be signed in to change notification settings - Fork 26
[MISC] Always check databag #533
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,9 +294,7 @@ def get_secret(self, scope: Scopes, key: str) -> Optional[str]: | |
return None | ||
secret_key = self._translate_field_to_secret_key(key) | ||
# Old translation in databag is to be taken | ||
if key != secret_key and ( | ||
result := self.peer_relation_data(scope).fetch_my_relation_field(peers.id, key) | ||
): | ||
if result := self.peer_relation_data(scope).fetch_my_relation_field(peers.id, key): | ||
return result | ||
|
||
return self.peer_relation_data(scope).get_secret(peers.id, secret_key) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm..... This line WAS supposed to be checking the databag. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well... Having said all that... It becomes a conceptual question. Should the lib's (I consider the current situation a bug on my side, as my original intent was along the lines of the latter. However once we are at this point, I think the question is valid regarding policy.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my mind, we'd expect that lib's IMO, the issue here may be fixed with Dragomir changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC we added those checks here, so that we don't have to deal with translation etc. in the lib. Do we want to push that back to the lib? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it can be kept here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So. We should deal with the translarion. Just like in MySQL: https://github.com/canonical/mysql-k8s-operator/blob/main/lib/charms/mysql/v0/mysql.py#L742-L745 We should check for the new key (using lib The current "fix" is covering up for the bug on the libs side. IT's not the way the code should be wrtiten ideally. Huh I don't know if I made my point clear 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm okay with going the way you commented if it avoids hiding the bug. |
||
|
@@ -312,10 +310,7 @@ def set_secret(self, scope: Scopes, key: str, value: Optional[str]) -> Optional[ | |
peers = self.model.get_relation(PEER) | ||
secret_key = self._translate_field_to_secret_key(key) | ||
# Old translation in databag is to be deleted | ||
if key != secret_key and self.peer_relation_data(scope).fetch_my_relation_field( | ||
peers.id, key | ||
): | ||
self.peer_relation_data(scope).delete_relation_data(peers.id, [key]) | ||
self.peer_relation_data(scope).delete_relation_data(peers.id, [key]) | ||
self.peer_relation_data(scope).set_secret(peers.id, secret_key, value) | ||
|
||
def remove_secret(self, scope: Scopes, key: str) -> None: | ||
|
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.
If key == secret_key we ignored that peer data value
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'm a bit confused: If key == secret_key, then this means we should check inside the secret, not the databag (wasn't this the original intention of this code?). Then how come we can have key == secret_key and still have to check the databag? Doesn´t this mean something went wrong when setting the secret in the first place? Sorry I think I never understood this workflow properly 😬
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 suppose the bug itself is not clear to me.
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.
Migrating from Juju 2 to Juju 3 would switch the charm from trying to use secrets, but all the values are still in the peer databag. The issue here is that we only check if the
key
andsecret_key
are different, but the data would still be in the peer databag even if the key is the same (no translation needed).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.
Thanks for the explanation. Looks like a specific edge case for which we didn´t have any tests.