From 5eefc9d9f2208186dbd6e93719c6a54e8fc7c367 Mon Sep 17 00:00:00 2001 From: Pedro Guimaraes Date: Mon, 29 Apr 2024 22:48:45 +0200 Subject: [PATCH] Fixes for intermediary upgrade charm --- .github/workflows/release.yaml | 2 +- charmcraft.yaml | 2 +- src/opensearch.py | 2 +- src/upgrade.py | 15 ++++++++------- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 374b9d10e..cb6998e6e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -40,7 +40,7 @@ jobs: - build uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v13.1.1 with: - channel: experimental/upgrade/edge + channel: 2/edge/experimental artifact-prefix: ${{ needs.build.outputs.artifact-prefix }} secrets: charmhub-token: ${{ secrets.CHARMHUB_TOKEN }} diff --git a/charmcraft.yaml b/charmcraft.yaml index 23f603b2c..eca99623a 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -18,7 +18,7 @@ parts: echo 'ERROR: Use "tox run -e build-dev" instead of calling "charmcraft pack" directly' >&2 exit 1 fi - charm-strict-dependencies: true +# charm-strict-dependencies: true charm-entrypoint: src/charm.py prime: - charm_version diff --git a/src/opensearch.py b/src/opensearch.py index d4ade92dc..7f6778cdb 100644 --- a/src/opensearch.py +++ b/src/opensearch.py @@ -134,7 +134,7 @@ def _build_paths(self) -> Paths: conf=f"{self._SNAP_DATA}/etc/opensearch", data=f"{self._SNAP_COMMON}/var/lib/opensearch", logs=f"{self._SNAP_COMMON}/var/log/opensearch", - jdk=f"{self._SNAP}/usr/lib/jvm/java-21-openjdk-amd64", + jdk=f"{self._SNAP}/usr/lib/jvm/java-17-openjdk-amd64", tmp=f"{self._SNAP_COMMON}/usr/share/tmp", bin=f"{self._SNAP}/usr/share/opensearch/bin", ) diff --git a/src/upgrade.py b/src/upgrade.py index 49202645c..1862b500e 100644 --- a/src/upgrade.py +++ b/src/upgrade.py @@ -70,6 +70,7 @@ def __init__(self, charm_: ops.CharmBase) -> None: if not relations: raise PeerRelationNotReady assert len(relations) == 1 + self._charm = charm_ self._peer_relation = relations[0] self._unit: ops.Unit = charm_.unit self._unit_databag = self._peer_relation.data[self._unit] @@ -267,25 +268,25 @@ def pre_upgrade_check(self) -> None: resolution = None try: - if self.charm.health.apply() != HealthColors.GREEN: + if self._charm.health.apply() != HealthColors.GREEN: cause = f"Cluster not healthy: expected 'green', but '{self.health.apply()}' found instead" resolution = "Ensure cluster is healthy before upgrading" online_nodes = ClusterTopology.nodes( - self.charm.opensearch, + self._charm.opensearch, True, - hosts=self.charm.alt_hosts, - only_this_juju_app=self.charm.app.name, + hosts=self._charm.alt_hosts, + only_this_juju_app=self._charm.app.name, ) - if len(online_nodes) != self.charm.app.planned_units(): + if len(online_nodes) != self._charm.app.planned_units(): cause = "Not all units are online" resolution = "Ensure all units are online in the cluster" - if self.charm.check_if_starting(): + if self._charm.check_if_starting(): cause = "Cluster is starting" resolution = "Ensure cluster has finished its (re)start cycle before proceeding" - if not self.charm.backup.is_idle(): + if not self._charm.backup.is_idle(): cause = "Backup is in progress" resolution = "Ensure backup is completed before upgrading"