Skip to content

Commit

Permalink
Fixed jdk path (#141)
Browse files Browse the repository at this point in the history
## Issue
The new version of the snap relies on the jdk of the snap environment
instead of the one bundled by OpenSearch.
This PR replaces the path of the JDK by the correct one
  • Loading branch information
Mehdi-Bendriss authored Oct 19, 2023
1 parent 898ea1e commit e0ec52d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/charms/opensearch/v0/opensearch_distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
OpenSearchStartTimeoutError,
)
from charms.opensearch.v0.opensearch_internal_data import Scope
from tenacity import retry, stop_after_attempt, wait_fixed

# The unique Charmhub library identifier, never change it
LIBID = "7145c219467d43beb9c566ab4a72c454"
Expand Down Expand Up @@ -317,6 +318,7 @@ def write_file(self, path: str, data: str, override: bool = True):
f.write(data)

@staticmethod
@retry(stop=stop_after_attempt(3), wait=wait_fixed(0.5), reraise=True)
def _run_cmd(command: str, args: str = None, stdin: str = None) -> str:
"""Run command.
Expand Down Expand Up @@ -362,6 +364,7 @@ def _build_paths(self) -> Paths:
def _set_env_variables(self):
"""Set the necessary environment variables."""
os.environ["OPENSEARCH_HOME"] = self.paths.home
os.environ["JAVA_HOME"] = self.paths.jdk
os.environ["OPENSEARCH_JAVA_HOME"] = self.paths.jdk
os.environ["OPENSEARCH_PATH_CONF"] = self.paths.conf
os.environ["OPENSEARCH_TMPDIR"] = self.paths.tmp
Expand Down
2 changes: 1 addition & 1 deletion src/opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,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/share/opensearch/jdk",
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

0 comments on commit e0ec52d

Please sign in to comment.