Skip to content
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

revert TLS changes + update TLS to show failures #340

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/charms/mongodb/v0/mongodb_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import socket
from typing import List, Optional, Tuple

from charms.mongodb.v0.mongodb import MongoDBConnection
from charms.tls_certificates_interface.v1.tls_certificates import (
CertificateAvailableEvent,
CertificateExpiringEvent,
Expand All @@ -22,7 +23,7 @@
)
from ops.charm import ActionEvent, RelationBrokenEvent, RelationJoinedEvent
from ops.framework import Object
from ops.model import ActiveStatus, MaintenanceStatus, Unit
from ops.model import ActiveStatus, MaintenanceStatus, Unit, WaitingStatus

from config import Config

Expand All @@ -39,7 +40,7 @@

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 6
LIBPATCH = 7

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -195,7 +196,12 @@ def _on_certificate_available(self, event: CertificateAvailableEvent) -> None:
self.charm.push_tls_certificate_to_workload()
self.charm.unit.status = MaintenanceStatus("enabling TLS")
self.charm.restart_mongod_service()
self.charm.unit.status = ActiveStatus()

with MongoDBConnection(self.charm.mongodb_config) as mongo:
if not mongo.is_ready:
self.charm.unit.status = WaitingStatus("Waiting for MongoDB to start")
else:
self.charm.unit.status = ActiveStatus()
MiaAltieri marked this conversation as resolved.
Show resolved Hide resolved

def _waiting_for_certs(self):
"""Returns a boolean indicating whether additional certs are needed."""
Expand Down
5 changes: 3 additions & 2 deletions lib/charms/mongodb/v1/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 2
LIBPATCH = 3

# path to store mongodb ketFile
KEY_FILE = "keyFile"
Expand Down Expand Up @@ -174,7 +174,7 @@ def get_mongod_args(
f"--tlsCAFile={full_conf_dir}/{TLS_EXT_CA_FILE}",
f"--tlsCertificateKeyFile={full_conf_dir}/{TLS_EXT_PEM_FILE}",
# allow non-TLS connections
"--tlsMode=requireTLS",
"--tlsMode=preferTLS",
"--tlsDisabledProtocols=TLS1_0,TLS1_1",
]
)
Expand All @@ -184,6 +184,7 @@ def get_mongod_args(
cmd.extend(
[
"--clusterAuthMode=x509",
"--tlsAllowInvalidCertificates",
f"--tlsClusterCAFile={full_conf_dir}/{TLS_INT_CA_FILE}",
f"--tlsClusterFile={full_conf_dir}/{TLS_INT_PEM_FILE}",
]
Expand Down