Skip to content

Commit

Permalink
Fixes for intermediary upgrade charm
Browse files Browse the repository at this point in the history
  • Loading branch information
phvalguima committed Apr 29, 2024
1 parent ca4b949 commit 5eefc9d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- build
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
with:
channel: experimental/upgrade/edge
channel: 2/edge/experimental
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
secrets:
charmhub-token: ${{ secrets.CHARMHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down
15 changes: 8 additions & 7 deletions src/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit 5eefc9d

Please sign in to comment.