Skip to content

Commit

Permalink
Add initial uptime metrics (#2609)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcmcand authored Aug 30, 2024
2 parents 400f0d0 + 5aea0c5 commit 498e569
Show file tree
Hide file tree
Showing 17 changed files with 965 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ nebari-config.yaml

# Integration tests deployments
_test_deploy

# ignore downloaded helm charts
**/template/charts
2 changes: 2 additions & 0 deletions src/_nebari/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
CURRENT_RELEASE = "2024.7.1"

HELM_VERSION = "v3.15.3"
KUSTOMIZE_VERSION = "5.4.3"
# NOTE: Terraform cannot be upgraded further due to Hashicorp licensing changes
# implemented in August 2023.
# https://www.hashicorp.com/license-faq
Expand Down
71 changes: 71 additions & 0 deletions src/_nebari/provider/helm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import logging
import os
import subprocess
import tempfile
from pathlib import Path

from _nebari import constants
from _nebari.utils import run_subprocess_cmd

logger = logging.getLogger(__name__)


class HelmException(Exception):
pass


def download_helm_binary(version=constants.HELM_VERSION) -> Path:
filename_directory = Path(tempfile.gettempdir()) / "helm" / version
filename_path = filename_directory / "helm"

if not filename_directory.is_dir():
filename_directory.mkdir(parents=True)

if not filename_path.is_file():
logger.info(
"downloading and extracting Helm binary version %s to path=%s",
constants.HELM_VERSION,
filename_path,
)
old_path = os.environ.get("PATH")
new_path = f"{filename_directory}:{old_path}"
install_script = subprocess.run(
[
"curl",
"-s",
"https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3",
],
stdout=subprocess.PIPE,
check=True,
)
subprocess.run(
[
"bash",
"-s",
"--",
"-v",
constants.HELM_VERSION,
"--no-sudo",
],
input=install_script.stdout,
check=True,
env={"HELM_INSTALL_DIR": str(filename_directory), "PATH": new_path},
)

filename_path.chmod(0o555)
return filename_path


def run_helm_subprocess(processargs, **kwargs) -> None:
helm_path = download_helm_binary()
logger.info("helm at %s", helm_path)
if run_subprocess_cmd([helm_path] + processargs, **kwargs):
raise HelmException("Helm returned an error")


def version() -> str:
helm_path = download_helm_binary()
logger.info("checking helm=%s version", helm_path)

version_output = subprocess.check_output([helm_path, "version"]).decode("utf-8")
return version_output
Loading

0 comments on commit 498e569

Please sign in to comment.