Skip to content

Add lib/healthmonitoring: shared join of health reports and ClusterSummaries - #2039

Merged
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:health-monitoring-lib
Oct 16, 2026
Merged

gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:health-monitoring-lib

Conversation

@gianlucam76

Copy link
Copy Markdown
Member

Add a small package that joins the HealthCheckReports of one cluster with the ClusterSummaries owning the HealthChecks behind them, and returns the health state per profile, the cluster state, and a flat list of unhealthy resources.

Why it lives here: the report carries no reference to a ClusterSummary, so the link can only be made by a join (generated HealthCheck labels/annotations, plus the checks a ClusterProfile lists). ui-backend (cluster list and "Unhealthy resources" view) and sveltosctl (new show command) both need that join. It cannot live in libsveltos (it needs the ClusterSummary type and the label constants, and addon-controller imports libsveltos), and both consumers already import addon-controller. A single implementation keeps the cluster badge, the per-profile badge and the detail list from diverging.

The package is pure: no client, no locks. Callers build the inputs from their own caches or from Lists (NewSummaryInput, NewReportInput, GeneratedCheckOwner).

  • Evaluate: per-profile state (NoData, Healthy, worst status), cluster state, resources deduplicated (worst status wins, shared checks list all their profiles), unclaimed reports (no owning profile) keep the HealthCheck name, sorted worst first.
  • Listed healthChecks are honored for a ClusterProfile only, as in the controller.
  • status.agentFailureMessage is not considered yet.

…mmaries

Add a small package that joins the HealthCheckReports of one cluster with the
ClusterSummaries owning the HealthChecks behind them, and returns the health state
per profile, the cluster state, and a flat list of unhealthy resources.

Why it lives here: the report carries no reference to a ClusterSummary, so the link
can only be made by a join (generated HealthCheck labels/annotations, plus the checks
a ClusterProfile lists). ui-backend (cluster list and "Unhealthy resources" view) and
sveltosctl (new `show` command) both need that join. It cannot live in libsveltos
(it needs the ClusterSummary type and the label constants, and addon-controller
imports libsveltos), and both consumers already import addon-controller. A single
implementation keeps the cluster badge, the per-profile badge and the detail list
from diverging.

The package is pure: no client, no locks. Callers build the inputs from their own
caches or from Lists (NewSummaryInput, NewReportInput, GeneratedCheckOwner).

- Evaluate: per-profile state (NoData, Healthy, worst status), cluster state, resources
  deduplicated (worst status wins, shared checks list all their profiles), unclaimed
  reports (no owning profile) keep the HealthCheck name, sorted worst first.
- Listed healthChecks are honored for a ClusterProfile only, as in the controller.
- status.agentFailureMessage is not considered yet.
@gianlucam76
gianlucam76 merged commit 6af08d7 into projectsveltos:main Oct 16, 2026
12 checks passed
@gianlucam76
gianlucam76 deleted the health-monitoring-lib branch October 16, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant