Skip to content
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
3 changes: 1 addition & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import os
import platform
import subprocess
import sys
from pathlib import Path
from typing import Dict, List, Literal, Optional, Set, get_args

import psycopg2
Expand Down Expand Up @@ -106,6 +108,16 @@ class PostgresqlOperatorCharm(TypedCharmBase[CharmConfig]):
def __init__(self, *args):
super().__init__(*args)

# Support for disabling the operator.
disable_file = Path(f"{os.environ.get('CHARM_DIR')}/disable")
if disable_file.exists():
logger.warning(
f"\n\tDisable file `{disable_file.resolve()}` found, the charm will skip all events."
"\n\tTo resume normal operations, please remove the file."
)
self.unit.status = BlockedStatus("Disabled")
sys.exit(0)

self.peer_relation_app = DataPeer(
self,
relation_name=PEER,
Expand Down