Skip to content

Commit

Permalink
Merge pull request #9799 from m-czernek/move-health-check
Browse files Browse the repository at this point in the history
[health-check] Move sources to python dir
  • Loading branch information
ycedres authored Feb 20, 2025
2 parents 596f436 + 650cfee commit 77bb8d4
Show file tree
Hide file tree
Showing 29 changed files with 53 additions and 61 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ datasources:
timeout: '120'
editable: true

- name: Prometheus
type: prometheus
access: proxy
orgId: 1
url: http://uyuni-health-check-prometheus:9090
editable: false

- name: infinity-ds
type: yesoreyeram-infinity-datasource
orgId: 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Module that contains podman-related functionality"""

from typing import List
from uyuni_health_check import config
from uyuni_health_check.utils import run_command, console
from health_check import config
from health_check.utils import run_command, console


def podman(cmd: List[str], verbose=False, raise_exc=True) -> List:
Expand Down Expand Up @@ -95,9 +95,9 @@ def clean_containers(verbose=False):

def create_podman_network(verbose=False):
"""
Create uyuni-health-check pod where we run the containers
Create health-check pod where we run the containers
:param server: the Uyuni server to create the pod on or localhost
:param server: the server to create the pod on or localhost
"""
console.log("[bold]Creating podman network")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Module that manages the supportconfig exporter container"""

from uyuni_health_check import config
from uyuni_health_check.utils import console
from uyuni_health_check.containers.manager import (
from health_check import config
from health_check.utils import console
from health_check.containers.manager import (
image_exists,
build_image,
podman,
Expand All @@ -14,7 +14,7 @@ def prepare_exporter(supportconfig_path: str, verbose: bool):
"""
Build the exporter image and deploy it on the server
:param server: the Uyuni server to deploy the exporter on
:param server: the server to deploy the exporter on
"""
exporter_name = config.load_prop("exporter.container_name")
image = config.load_prop("exporter.image")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,18 @@ def parse_shared_buffers_to_mem_ratio(self, memory: int):
return

shared_buffers = int(shared_buffers)
match buffer_unit.lower():
case "kb":
... # conversion done
case "mb":
shared_buffers *= 1024
case "gb":
shared_buffers *= 1024 * 1024
case _:
print(f"Error when parsing shared buffer unit: {buffer_unit}")
return

buffer_unit = buffer_unit.lower()
if buffer_unit == "kb":
... # conversion done
elif buffer_unit == "mb":
shared_buffers *= 1024
elif buffer_unit == "gb":
shared_buffers *= 1024 * 1024
else:
print(f"Error when parsing shared buffer unit: {buffer_unit}")
return

self.shared_buffers_to_mem_ratio = round(shared_buffers / memory, 2)

def parse_prefork_c_params(self):
Expand Down Expand Up @@ -229,19 +231,19 @@ def _check_vol_params(self, mount: str, min_size_gb: int, fs: Dict) -> Dict:
else:
size, unit = float(size[:-1]), size[-1:]

match unit.lower():
case "k":
size /= 1024 * 1024
case "m":
size /= 1024
case "g":
... # already in GB
case "t":
size *= 1024
case "n/a":
... # no unit
case _:
print(f"Error when parsing shared buffer unit: {unit}")
unit = unit.lower()
if unit == "k":
size /= 1024 * 1024
elif unit == "m":
size /= 1024
elif unit == "g":
... # already in GB
elif unit == "t":
size *= 1024
elif unit == "n/a":
... # no unit
else:
print(f"Error when parsing shared buffer unit: {unit}")

res["too_small"] = 1 if min_size_gb > size else 0
return res
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""A module that manages the Grafana container"""

import json
from uyuni_health_check import config
from uyuni_health_check.utils import console
from uyuni_health_check.containers.manager import (
from health_check import config
from health_check.utils import console
from health_check.containers.manager import (
build_image,
image_exists,
container_is_running,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import os
import requests
import zipfile
import re
import time
from uyuni_health_check import config
from uyuni_health_check.utils import HealthException, console
from uyuni_health_check.containers.manager import (
from health_check import config
from health_check.utils import console
from health_check.containers.manager import (
build_image,
image_exists,
container_is_running,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import os
from rich.markdown import Markdown

from uyuni_health_check.grafana.grafana_manager import prepare_grafana
import uyuni_health_check.utils as utils
from uyuni_health_check.utils import console, HealthException
from uyuni_health_check.loki.loki_manager import run_loki
from uyuni_health_check.exporters import exporter
from uyuni_health_check.containers.manager import (
from health_check.grafana.grafana_manager import prepare_grafana
import health_check.utils as utils
from health_check.utils import console, HealthException
from health_check.loki.loki_manager import run_loki
from health_check.exporters import exporter
from health_check.containers.manager import (
create_podman_network,
clean_containers,
)
Expand Down Expand Up @@ -62,7 +62,7 @@ def cli(ctx: click.Context, supportconfig_path: str, verbose: bool):
@click.pass_context
def run(ctx: click.Context, from_datetime: str, to_datetime: str, since: int):
"""
Start execution of Uyuni Health Check
Start execution of Health Check
Build the necessary containers, deploy them, get the metrics and display them
Expand Down Expand Up @@ -101,7 +101,7 @@ def clean(ctx: click.Context):


def main():
console.print(Markdown("# Uyuni Health Check"))
console.print(Markdown("# Health Check"))
cli() # pylint: disable=no-value-for-parameter


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ def _handle_text_from_process(verbose: bool, *objs: str):


def _check_retcode(retcode: int):
match retcode:
case 0:
... # success
case 127:
raise OSError("Command not found; podman is required")
case _:
raise HealthException("An error happened while running Podman")
if retcode == 0:
... # success
elif retcode == 127:
raise OSError("Command not found; podman is required")
else:
raise HealthException("An error happened while running Podman")


class HealthException(Exception):
Expand Down

0 comments on commit 77bb8d4

Please sign in to comment.