Skip to content

Commit

Permalink
revert TLS changes + update TLS to show failures (#340)
Browse files Browse the repository at this point in the history
## Issue
Current TLS options result in the charm not being functional
TLS tests pass even though the charm is not functional

## Solution
Revert options
Update TLS code to prevent the tests from succeeding when the charm is
in-fact broken
  • Loading branch information
MiaAltieri committed Jan 23, 2024
1 parent 36c0612 commit 3652eed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
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()

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

0 comments on commit 3652eed

Please sign in to comment.