Repository navigation
Conversation
Mehdi-Bendriss
left a comment
There was a problem hiding this comment.
Thanks Shams, left some small comments and questions
|
|
||
| return None | ||
|
|
||
| def _set_credentials_incorrect_status(self, failed: bool) -> None: |
There was a problem hiding this comment.
nit, missing docstrings
| message="Waiting for settings from backup integrator", | ||
| short_message="Waiting for backup settings", |
There was a problem hiding this comment.
nit, backup => object storage
| # s3-integrator legacy-lib adds copy of our request to a "data" field | ||
| # before filling connection info (its not part of the connection info) | ||
| info = self.s3_requirer.get_storage_connection_info(self.s3_relation) or {} | ||
| info.pop("data", None) |
There was a problem hiding this comment.
what does this field represent and why do we remove it?
There was a problem hiding this comment.
I believe it's for internal bookkeeping, the relation data looks like this for the first few hooks:
{}
{ "data": "{}"}
{ "data": "{\"requested-secrets\": \"[\\\"access-key\\\", \\\"secret-key\\\"]\"}" }
{
"bucket": "opensearch-bucket",
"data": "{\"bucket\": \"relation-42\", \"requested-secrets\": \"[\\\"access-key\\\", \\\"secret-key\\\"]\", \"version\": \"1\"}",
"endpoint": "9200",
...
}
We remove it to be able to check if the connection info is empty, it's the only key we get before we get the actual configuration. Upstream drops it the same way in their v1 provider tests to compare connection info for backwards compatibility
| def get_endpoint_protocol(endpoint: str) -> str: | ||
| """Returns the protocol based on the endpoint.""" | ||
| if not endpoint: | ||
| if not isinstance(endpoint, str) or not endpoint: |
There was a problem hiding this comment.
when not None, when would this be anything but string?
There was a problem hiding this comment.
Yes, s3 v1 publishes raw strings and the requirer lib json decodes them so we can get things that aren't strings. Setting endpoint=9200 caused a hook failure for example.
| self.charm.snapshots_manager.read_snapshots_data_from_peer_cluster() | ||
| ) | ||
| except OpenSearchSnapshotsPeerClusterDataConflictError: | ||
| return None |
There was a problem hiding this comment.
we should perhaps log that we're ignoring this due to ongoing conflict
| interpolated=True, | ||
| ) | ||
|
|
||
| def _clear_relation_data_incomplete_status(self) -> None: |
There was a problem hiding this comment.
nit, missing docstrings
| except OpenSearchObjectStorageConfigValidationError: | ||
| except OpenSearchObjectStorageConfigValidationError as e: | ||
| if e.missing_fields: | ||
| return "Object storage configuration missing fields." |
There was a problem hiding this comment.
Let's add the list of missing fields in the message for clarity
| self.missing_fields: list[str] = ( | ||
| [field.strip() for msg in msgs for field in msg.split(":", 1)[1].split(",")] | ||
| if all("Missing field" in msg for msg in msgs) | ||
| else [] | ||
| ) |
There was a problem hiding this comment.
nit: "Missing fields" . I personally don't like relying on str since it can be error prone I documented a bit on this and seems we can use PydanticCustomError which is more structured and can give you data access. I never used it so to be confirmed
| # connection_info may be empty for a few hooks before being filled | ||
| # if its empty on recompute then we consider it unconfigured | ||
| if not connection_info: | ||
| if recompute or cached_non_running_statuses( |
There was a problem hiding this comment.
I am not sure we should rely on recompute like this. Because it can be fired at any time with running status-detail or just jhack ffwd (which sets the refresh to less time)
Fixes #215
Description of issue or feature:
SnapshotsManager.get_statuseswas callingvalidate_storage_configon every hook.Backup relation data missing or incomplete.status was displayed immediately, followed byBackup configuration error: bad credentialsbefore clearing itself. This is because the connection info empty during the first hooks, and later s3-integrator's legacy lib adds adatafield (which is a copy of our request) which the charm was mistaking for invalid connection_infoBackup configuration error: bad credentialswas being shown when it should beBackup relation data missing or incompleteSome uncaught exceptions were causing hook failures:
ValueErrorOpenSearchSnapshotsPeerClusterDataConflictErrorSolution:
datafield and add a newBACKUP_WAITING_FOR_CONNECTION_INFOstatus which is displayed when first relating to a backup integrator while the connection info is empty. If connection_info is still missing when recompute=True its considered an incomplete configuration (commit 2)commits 6 and 7 are removing statuses on relation-removal and adding the missing fields message to the backup actions
How was this change tested?