Skip to content

Commit

Permalink
[taskManager plugin status] Do not emit empty status to status Obse…
Browse files Browse the repository at this point in the history
…rvables (#171012)

## Summary

Improvement over #169447, see
[related comment](#171012).
  • Loading branch information
gsoldevila authored Nov 14, 2023
1 parent cedaa3f commit 33ba491
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function ({ getService }: FtrProviderContext) {
describe('Core Context Providers', () => {
let event: Event<Record<string, unknown>>;
before(async () => {
let i = 2;
let i = 1;
do {
// Wait until we get a GREEN "status_changed" event. At that point all the context providers should be set up.
const events = await ebtServerHelper.getEvents(i, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ describe('calculateHealthStatus', () => {
true,
logger
)
).toEqual({ status: HealthStatus.Warning, reason: `no health stats available` });
).toEqual({ status: HealthStatus.Uninitialized, reason: `no health stats available` });
});

test('should return error status if any stat has status error', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function calculateHealthStatus(

// if stats are empty, return a warning
if (isEmpty(summarizedStats.stats)) {
return { status: HealthStatus.Warning, reason: `no health stats available` };
return { status: HealthStatus.Uninitialized, reason: `no health stats available` };
}

// if "hot" health stats are any more stale than monitored_stats_required_freshness
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface MonitoringStats {
}

export enum HealthStatus {
Uninitialized = 'uninitialized',
OK = 'OK',
Warning = 'warn',
Error = 'error',
Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugins/task_manager/server/routes/health.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '@kbn/core/server';
import { IClusterClient, DocLinksServiceSetup } from '@kbn/core/server';
import { Observable, Subject } from 'rxjs';
import { tap, map } from 'rxjs/operators';
import { tap, map, filter } from 'rxjs/operators';
import { throttleTime } from 'rxjs/operators';
import { UsageCounter } from '@kbn/usage-collection-plugin/server';
import { Logger, ServiceStatus, ServiceStatusLevels } from '@kbn/core/server';
Expand Down Expand Up @@ -114,7 +114,8 @@ export function healthRoute(params: HealthRouteParams): {
}),
// Only calculate the summarized stats (calculates all running averages and evaluates state)
// when needed by throttling down to the requiredHotStatsFreshness
map((stats) => withServiceStatus(getHealthStatus(stats)))
map((stats) => withServiceStatus(getHealthStatus(stats))),
filter(([monitoredHealth]) => monitoredHealth.status !== HealthStatus.Uninitialized)
)
.subscribe(([monitoredHealth, serviceStatus]) => {
serviceStatus$.next(serviceStatus);
Expand Down

0 comments on commit 33ba491

Please sign in to comment.