Skip to content

Commit

Permalink
Ignore alias error in case alias is already existing (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp authored Oct 3, 2024
1 parent a8024fd commit ef94d6c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from charms.rolling_ops.v0.rollingops import RollingOpsManager, RunWithLock
from charms.tempo_k8s.v1.charm_tracing import trace_charm
from charms.tempo_k8s.v2.tracing import TracingEndpointRequirer
from ops import JujuVersion
from ops import JujuVersion, main
from ops.charm import (
ActionEvent,
HookEvent,
Expand All @@ -42,7 +42,6 @@
StartEvent,
)
from ops.framework import EventBase
from ops.main import main
from ops.model import (
ActiveStatus,
BlockedStatus,
Expand Down Expand Up @@ -883,8 +882,14 @@ def _on_install(self, event: InstallEvent) -> None:

cache = snap.SnapCache()
postgres_snap = cache[POSTGRESQL_SNAP_NAME]
postgres_snap.alias("patronictl")
postgres_snap.alias("psql")
try:
postgres_snap.alias("patronictl")
except snap.SnapError:
logger.warning("Unable to create patronictl alias")
try:
postgres_snap.alias("psql")
except snap.SnapError:
logger.warning("Unable to create psql alias")

# Create the user home directory for the snap_daemon user.
# This is needed due to https://bugs.launchpad.net/snapd/+bug/2011581.
Expand Down

0 comments on commit ef94d6c

Please sign in to comment.