Skip to content

Commit

Permalink
fit: no use of updating two libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu1nness committed Sep 11, 2024
1 parent 46ec71a commit 32cc3c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 9 additions & 1 deletion lib/charms/mongodb/v0/upgrade_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import poetry.core.constraints.version as poetry_version
from charms.mongodb.v0.mongo import MongoConfiguration
from charms.mongodb.v1.helpers import unit_number
from charms.mongodb.v1.mongodb import FailedToMovePrimaryError, MongoDBConnection
from charms.mongodb.v1.mongos import MongosConnection
from ops import ActionEvent, BlockedStatus, MaintenanceStatus, StatusBase, Unit
Expand Down Expand Up @@ -47,6 +46,15 @@
PRECHECK_ACTION_NAME = "pre-upgrade-check"


# BEGIN: Helper functions
def unit_number(unit_: Unit) -> int:
"""Get unit number."""
return int(unit_.name.split("/")[-1])


# END: Helper functions


# BEGIN: Exceptions
class StatusException(Exception):
"""Exception with ops status."""
Expand Down
8 changes: 1 addition & 7 deletions lib/charms/mongodb/v1/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from typing import List, Mapping

from charms.mongodb.v1.mongodb import MongoConfiguration
from ops import Unit
from ops.model import ActiveStatus, MaintenanceStatus, StatusBase, WaitingStatus

from config import Config
Expand All @@ -24,7 +23,7 @@

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

# path to store mongodb ketFile
KEY_FILE = "keyFile"
Expand Down Expand Up @@ -343,8 +342,3 @@ def safe_exec(
except subprocess.CalledProcessError as err:
logger.error(f"cmd failed - {err.cmd}, {err.stdout}, {err.stderr}")
raise


def unit_number(unit_: Unit) -> int:
"""Get unit number."""
return int(unit_.name.split("/")[-1])

0 comments on commit 32cc3c8

Please sign in to comment.