Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Workload Summary Pod/Container Ring Chart Fixes
Browse files Browse the repository at this point in the history
- fix expanded pod status when there are terminated containers
- in container ready/not ready count ignore containers that were terminated succesfully
- sort pod status labels in pod status ring chart to reduce values switching
  • Loading branch information
richard-cox committed Jun 12, 2020
1 parent fc197cd commit da6eb12
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,9 @@ export class KubernetesPodExpandedStatusHelper {
reason = state.waiting.reason;
} else if (!!state.terminated) {
reason = state.terminated.reason;
} else if (!!state.terminated) {
if (state.terminated.signal !== 0) {
if (!!state.terminated.signal && state.terminated.signal !== 0) {
reason = `Signal:${state.terminated.signal}`;
} else {
} else if (!!state.terminated.exitCode && state.terminated.exitCode !== 0) {
reason = `ExitCode:${state.terminated.exitCode}`;
}
} else if (!!container.ready && !!state.running) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';

import { kubeEntityCatalog } from '../../../kubernetes-entity-catalog';
import { KubernetesPod } from '../../../store/kube.types';
import { ContainerStateCollection, KubernetesPod } from '../../../store/kube.types';
import { getHelmReleaseDetailsFromGuid } from '../../store/workloads-entity-factory';
import {
HelmRelease,
Expand Down Expand Up @@ -85,7 +85,7 @@ export class HelmReleaseHelperService {
this.releaseTitle
).currentPage$.pipe(
filter(pods => !!pods),
map(this.mapPods)
map(pods => this.mapPods(pods))
);
}

Expand All @@ -110,11 +110,13 @@ export class HelmReleaseHelperService {
} else {
podPhases[status]++;
}

if (pod.status.containerStatuses) {
pod.status.containerStatuses.forEach(containerStatus => {
if (containerStatus.state.running) {
const isReady = this.isContainerReady(containerStatus.state);
if (isReady === true) {
containers.ready.value++;
} else {
} else if (isReady === false) {
containers.notReady.value++;
}
});
Expand All @@ -129,4 +131,17 @@ export class HelmReleaseHelperService {
containersChartData: Object.values(containers)
};
}

private isContainerReady(state: ContainerStateCollection = {}): Boolean {
console.log(state);
if (state.running) {
return true;
} else if (!!state.waiting) {
return false;
} else if (!!state.terminated) {
// Assume a failed state is not ready (covers completed init states), discard success state
return state.terminated.exitCode === 0 ? null : false
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { RouterNav } from 'frontend/packages/store/src/actions/router.actions';
import { HideSnackBar, ShowSnackBar } from 'frontend/packages/store/src/actions/snackBar.actions';
import { AppState } from 'frontend/packages/store/src/app-state';
import { combineLatest, Observable, ReplaySubject } from 'rxjs';
import { filter, first, map, publishReplay, refCount, startWith } from 'rxjs/operators';
import { distinctUntilChanged, filter, first, map, publishReplay, refCount, startWith } from 'rxjs/operators';

import { endpointsEntityRequestDataSelector } from '../../../../../../../../store/src/selectors/endpoint.selectors';
import { HelmReleaseChartData, HelmReleaseResource } from '../../../workload.types';
Expand Down Expand Up @@ -103,7 +103,15 @@ export class HelmReleaseSummaryTabComponent implements OnDestroy {
startWith(true)
);

this.chartData$ = this.helmReleaseHelper.fetchReleaseChartStats();
this.chartData$ = this.helmReleaseHelper.fetchReleaseChartStats().pipe(
distinctUntilChanged(),
map(chartData => ({
...chartData,
containersChartData: chartData.containersChartData.sort((a, b) => a.name.localeCompare(b.name)),
podsChartData: chartData.podsChartData.sort((a, b) => a.name.localeCompare(b.name))
})
)
);

this.resources$ = this.helmReleaseHelper.fetchReleaseGraph().pipe(
map((graph: any) => {
Expand Down

0 comments on commit da6eb12

Please sign in to comment.