From 4119b1411f47f43fae603b5d2c03616536794f76 Mon Sep 17 00:00:00 2001 From: Samuel Padgett Date: Mon, 25 Feb 2019 12:14:03 -0500 Subject: [PATCH] Fix runtime error when pod has no volumes --- frontend/public/components/pod.jsx | 46 ++++++++++++++++++++++-------- frontend/public/module/k8s/pods.ts | 2 +- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/frontend/public/components/pod.jsx b/frontend/public/components/pod.jsx index 77b5bfaad2a..64e7d6b0b79 100644 --- a/frontend/public/components/pod.jsx +++ b/frontend/public/components/pod.jsx @@ -6,7 +6,25 @@ import { getVolumeType, getVolumeLocation, getVolumeMountPermissions, getVolumeM import { getContainerState, getContainerStatus } from '../module/k8s/docker'; import { ResourceEventStream } from './events'; import { ColHead, DetailsPage, List, ListHeader, ListPage, ResourceRow } from './factory'; -import { SectionHeading, Kebab, LabelList, navFactory, NodeLink, ResourceKebab, ResourceIcon, ResourceLink, ResourceSummary, ScrollToTopOnMount, Selector, Timestamp, VolumeIcon, units, AsyncComponent, StatusIcon } from './utils'; +import { + AsyncComponent, + EmptyBox, + Kebab, + LabelList, + NodeLink, + ResourceIcon, + ResourceKebab, + ResourceLink, + ResourceSummary, + ScrollToTopOnMount, + SectionHeading, + Selector, + StatusIcon, + Timestamp, + VolumeIcon, + navFactory, + units, +} from './utils'; import { PodLogs } from './pod-logs'; import { Line, requirePrometheus } from './graphs'; import { breadcrumbsForOwnerRefs } from './utils/breadcrumbs'; @@ -180,17 +198,21 @@ export const PodResourceSummary = ({pod}) => ( export const PodVolumeTable = ({heading, pod}) => ( {heading && } -
-
-
Name
-
Type
-
Permissions
-
Utilized By
-
-
- {getVolumeMountsByPermissions(pod).map((v, i) => )} -
-
+ {_.isEmpty(pod.spec.volumes) + ? + : ( +
+
+
Name
+
Type
+
Permissions
+
Utilized By
+
+
+ {getVolumeMountsByPermissions(pod).map((v, i) => )} +
+
+ )}
); diff --git a/frontend/public/module/k8s/pods.ts b/frontend/public/module/k8s/pods.ts index b27e0cdddcd..730987366e3 100644 --- a/frontend/public/module/k8s/pods.ts +++ b/frontend/public/module/k8s/pods.ts @@ -151,7 +151,7 @@ export const getVolumeMountsByPermissions = pod => { return []; } - const volumes = pod.spec.volumes.reduce((p, v) => { + const volumes = (pod.spec.volumes || []).reduce((p, v) => { p[v.name] = v; return p; }, {});