Skip to content

Commit

Permalink
Merge pull request #309 from defenseunicorns/fix-pod-and-node-views-i…
Browse files Browse the repository at this point in the history
…n-kube-system-ns

Fix pod and node views in kube system namespace.
  • Loading branch information
yuqiuw authored Apr 14, 2022
2 parents 1aa0c1c + 2939329 commit 23bc65b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
6 changes: 3 additions & 3 deletions client/src/components/nodeCpuChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export default function NodeCpuChart({items, metrics}: {items?: Node[], metrics?
function getNodeCpuTotals(items?: Node[], metrics?: _.Dictionary<Metrics>) {
if (!items || !metrics) return null;

const metricValues = Object.values(metrics);
const used = _.sumBy(metricValues, x => parseCpu(x.usage.cpu)) / TO_ONE_CPU;
const available = _.sumBy(items, x => parseCpu(x.status.capacity.cpu)) / TO_ONE_CPU;
const metricValues = Object.values(metrics) || [];

const used = _.sumBy(metricValues, x => parseCpu(_.get(x, 'usage.cpu'))) / TO_ONE_CPU;
const available = _.sumBy(items, x => parseCpu(_.get(x, 'status.capacity.cpu'))) / TO_ONE_CPU;
return {used, available};
}
6 changes: 3 additions & 3 deletions client/src/components/nodeRamChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export default function NodeRamChart({items, metrics}: {items?: Node[], metrics?
function getNodeRamTotals(items?: Node[], metrics?: _.Dictionary<Metrics>) {
if (!items || !metrics) return undefined;

const metricValues = Object.values(metrics);
const used = _.sumBy(metricValues, x => parseRam(x.usage.memory));
const available = _.sumBy(items, x => parseRam(x.status.capacity.memory));
const metricValues = Object.values(metrics) || [];

const used = _.sumBy(metricValues, x => parseRam(_.get(x, 'usage.memory')));
const available = _.sumBy(items, x => parseRam(_.get(x, 'status.capacity.memory')));
return {used, available};
}
12 changes: 7 additions & 5 deletions client/src/views/node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class NodeView extends Base<Props, State> {

<ChartsContainer>
<div className='charts_item'>
{item ? (
{item && item.status ? (
<span className='charts_number'>{getUptime(item)}</span>
) : (
<LoadingChart />
Expand All @@ -84,7 +84,8 @@ export default class NodeView extends Base<Props, State> {
</ChartsContainer>

<div className='contentPanel'>
{!item ? <Loading /> : (
{!item && <Loading />}
{item && item.status ? (
<div>
<MetadataFields item={item} />
<Field name='Kernel Version' value={item.status.nodeInfo.kernelVersion} />
Expand All @@ -96,12 +97,13 @@ export default class NodeView extends Base<Props, State> {
<Field name='Kube Proxy' value={item.status.nodeInfo.kubeProxyVersion} />
<Field name='Taints'>{getTaints(item)}</Field>
</div>
)}
) : null}
</div>

<div className='contentPanel_header'>Conditions</div>
<div className='contentPanel'>
{!item ? <Loading /> : (
{!item && <Loading />}
{item && item.status ? (
<table>
<thead>
<tr>
Expand All @@ -124,7 +126,7 @@ export default class NodeView extends Base<Props, State> {
))}
</tbody>
</table>
)}
) : null}
</div>

<div className='contentPanel_header'>Pods</div>
Expand Down
16 changes: 11 additions & 5 deletions client/src/views/pod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ export default class PodView extends Base<Props, State> {
const {item, metrics, events} = this.state || {};

const errors = getErrors(item);
const filteredEvents = filterByOwner(events, item);
// @ts-ignore
const filteredMetrics = getMetrics(item && [item], metrics && [metrics]);
let filteredEvents;
let filteredMetrics;

if (item?.metadata) {
filteredEvents = filterByOwner(events, item);
// @ts-ignore
filteredMetrics = getMetrics(item && [item], metrics && [metrics]);
}

return (
<div id='content'>
Expand Down Expand Up @@ -87,7 +92,8 @@ export default class PodView extends Base<Props, State> {
</ChartsContainer>

<div className='contentPanel'>
{!item ? <Loading /> : (
{!item && <Loading />}
{item && item.status ? (
<div>
<MetadataFields item={item} />
<Field name='Owned By'>
Expand Down Expand Up @@ -123,7 +129,7 @@ export default class PodView extends Base<Props, State> {
</Field>
<Field name='Selector'>{objectMap(item.spec.nodeSelector)}</Field>
</div>
)}
) : null}
</div>

<ContainersPanel spec={item && item.spec} />
Expand Down

0 comments on commit 23bc65b

Please sign in to comment.