Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[taskManager plugin status] Do not emit empty status to status Observables #171012

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading