-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds the following functionality to the etcd-operator: - automatically create an internal admin user (`root` as per [etcd standard](https://etcd.io/docs/v3.5/op-guide/authentication/rbac/#special-users-and-roles)) - always enable authentication in the etcd cluster on startup - methods `add_user()`, `update_password()` and `enable_auth()` in the `EtcdClient` class - a configuration option `system-users` with which users can configure a secret_id. The corresponding secret has to be granted to the etcd application and has to include the password as key `root=...`. - unit and integration test coverage for the above mentioned
- Loading branch information
Showing
13 changed files
with
474 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
options: | ||
system-users: | ||
type: secret | ||
description: | | ||
Configure the internal system user and it's password. The password will | ||
be auto-generated if this option is not set. It is for internal use only | ||
and SHOULD NOT be used by applications. This needs to be a Juju Secret URI pointing | ||
to a secret that contains the following content: `root: <password>`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
"""Charm-specific exceptions.""" | ||
|
||
|
||
class RaftLeaderNotFoundError(Exception): | ||
"""Custom Exception if there is no current Raft leader.""" | ||
|
||
|
||
class EtcdUserManagementError(Exception): | ||
"""Custom Exception if user could not be added or updated in etcd cluster.""" | ||
|
||
|
||
class EtcdAuthNotEnabledError(Exception): | ||
"""Custom Exception if authentication could not be enabled in the etcd cluster.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
"""Utility functions related to secrets.""" | ||
|
||
import logging | ||
|
||
from ops.model import ModelError, SecretNotFoundError | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def get_secret_from_id(model, secret_id: str) -> dict[str, str] | None: | ||
"""Resolve the given id of a Juju secret and return the content as a dict.""" | ||
try: | ||
secret_content = model.get_secret(id=secret_id).get_content(refresh=True) | ||
except SecretNotFoundError: | ||
raise SecretNotFoundError(f"The secret '{secret_id}' does not exist.") | ||
except ModelError: | ||
raise | ||
|
||
return secret_content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.