-
Notifications
You must be signed in to change notification settings - Fork 8
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 - 6153] - Propagate the security index intitialized through the peercluster relation #517
base: 2/edge
Are you sure you want to change the base?
[DPE - 6153] - Propagate the security index intitialized through the peercluster relation #517
Conversation
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.
Thank you @skourta for investigating and bringing up this solution for the issue. I think it is a valid approach and helps to set the security_index_initialized
more consistently on the peer-cluster applications.
There are only some minor things that need to be adjusted from my point of view. Good Job!
if data.security_index_initialised: | ||
self.charm.peers_data.put(Scope.APP, "security_index_initialised", True) |
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 seems to be happening twice: here and in _set_security_conf
. Is this wanted?
I noticed when deploying that the PeerClusterRequirers
are updating their opensearch-peers
app relation data with security_index_initialised: "True"
, but the PeerClusterProvider
does not. I believe we should add this to the _on_peer_cluster_relation_changed
method on the Provider side:
...
if self._get_security_index_initialised():
self.charm.peers_data.put(Scope.APP, "security_index_initialised", True)
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.
Correct me if I am wrong. All providers other than the main orchestrator are also requirers of the main orchestrator, correct? That is why I didn't add it for the provider side. The main orchestrator will pick it up and propagate it to the others. The only place the flag might be missing would be the peer databag of the main orchestrator if it was not the one that initialized it. Should we add it there as well for consistency?
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.
Yes that is correct.
The only place the flag might be missing would be the peer databag of the main orchestrator if it was not the one that initialized it.
This is what I meant with my comment, sorry for not being exact enough.
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.
Understood. I will add it.
# check all other clusters if they have initialised the security index | ||
all_relation_ids = [ | ||
rel.id for rel in self.charm.model.relations[self.relation_name] if len(rel.units) > 0 | ||
] | ||
|
||
for rel_id in all_relation_ids: | ||
if self.get_from_rel("security_index_initialised", rel_id=rel_id, remote_app=True): | ||
return True |
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 think this is correctly done.
logger.debug( | ||
f"is_leader: {self.unit.is_leader()}, security_index_initialised: {self.peers_data.get(Scope.APP, 'security_index_initialised')}, roles: {self.opensearch_peer_cm.deployment_desc().config.roles}, start: {self.opensearch_peer_cm.deployment_desc().start}" | ||
) |
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.
Please make this a multi-line-statement for better readability.
@@ -403,6 +403,7 @@ def cleanup(): | |||
# when "data" node joins -> start cluster-manager via _on_peer_cluster_relation_changed | |||
# cluster-manager notifies "data" node via refresh of peer cluster relation data | |||
# "data" node starts and initializes security index | |||
logger.info(f"Deployment description at on start: {deployment_desc}") |
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 log level here should be debug.
Fixes #516
Summary
lib/charms/opensearch/v0/models.py
: Added a new attributesecurity_index_initialised
to thePeerClusterRelData
class to track the initialization status of the security index.lib/charms/opensearch/v0/opensearch_base_charm.py
: Added a new methodput_or_update_security_index_initialized
to set the security index initialization flag and notify the main orchestrator. This method is called in_post_start_init
to replace the direct setting of the flag. [1] [2]lib/charms/opensearch/v0/opensearch_relation_peer_cluster.py
: Added a method_get_security_index_initialised
to check the initialization status across clusters and a methodset_security_index_initialised
to update the status in the unit data bag. These methods are used to ensure consistent handling of the security index initialization. [1] [2]lib/charms/opensearch/v0/opensearch_relation_peer_cluster.py
: Updated methods_rel_data
,_on_peer_cluster_relation_changed
, and_set_security_conf
to incorporate the newsecurity_index_initialised
attribute and ensure the status is correctly propagated and logged. [1] [2] [3]