Skip to content

Commit

Permalink
robotmk: Added some checking for scheduler status
Browse files Browse the repository at this point in the history
CMK-15055

Change-Id: I06947a25bc61baafbb1bd56f0198056300b68fd4
  • Loading branch information
racicLuka committed Nov 9, 2023
1 parent 8a28e9e commit 263592b
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion cmk/base/plugins/agent_based/robotmk_scheduler_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,58 @@ def discover_scheduler_status(
yield Service()


def _check_environment_build_state_failures(
suite_name: str,
failure: EnvironmentBuildStatusErrorNonZeroExit
| EnvironmentBuildStatusErrorTimeout
| EnviromentBuildStatusErrorMessage,
) -> CheckResult:
details = None

if isinstance(failure, EnviromentBuildStatusErrorMessage):
summary = "Error during environment build."
details = failure.Error

if isinstance(
failure, (EnvironmentBuildStatusErrorNonZeroExit, EnvironmentBuildStatusErrorTimeout)
):
summary = f"{failure.value} during environment build."

yield Result(state=State.CRIT, summary=f"{summary} for suite {suite_name}", details=details)


def _check_scheduler_status_errors(
section_robotmk_config: Config | ConfigReadingError | None,
section_robotmk_rcc_setup_failures: RCCSetupFailures | None,
section_robotmk_environment_build_states: EnvironmentBuildStatuses | None,
) -> CheckResult:
if isinstance(section_robotmk_config, ConfigReadingError):
yield Result(
state=State.CRIT,
summary="Error while reading config file.",
details=f"{section_robotmk_config.ReadingError}",
)

if section_robotmk_rcc_setup_failures:
yield Result(
state=State.CRIT,
summary="Failures during RCC setup.",
details=";".join(
list(section_robotmk_rcc_setup_failures.telemetry_disabling)
+ list(section_robotmk_rcc_setup_failures.shared_holotree)
+ list(section_robotmk_rcc_setup_failures.holotree_init)
),
)

if section_robotmk_environment_build_states:
for suite_name, failure in section_robotmk_environment_build_states.root.items():
if isinstance(failure, EnvironmentBuildStatusFailure):
yield from _check_environment_build_state_failures(
suite_name=suite_name,
failure=failure.Failure,
)


def check_scheduler_status(
section_robotmk_config: Config | ConfigReadingError | None,
section_robotmk_rcc_setup_failures: RCCSetupFailures | None,
Expand All @@ -211,7 +263,17 @@ def check_scheduler_status(
) -> CheckResult:
if not section_robotmk_config:
return
# TODO: Determine the conditions for the status

if list(
errors := _check_scheduler_status_errors(
section_robotmk_config,
section_robotmk_rcc_setup_failures,
section_robotmk_environment_build_states,
)
):
yield from errors
return

yield Result(state=State.OK, summary="The Scheduler status is OK")


Expand Down

0 comments on commit 263592b

Please sign in to comment.