Skip to content

Commit

Permalink
Merge pull request #1221 from spadgett/no-volumes
Browse files Browse the repository at this point in the history
Fix runtime error when pod has no volumes
  • Loading branch information
openshift-merge-robot committed Feb 25, 2019
2 parents f5ece42 + 4119b14 commit a0b75bc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
46 changes: 34 additions & 12 deletions frontend/public/components/pod.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -180,17 +198,21 @@ export const PodResourceSummary = ({pod}) => (
export const PodVolumeTable = ({heading, pod}) => (
<React.Fragment>
{heading && <SectionHeading text={heading} />}
<div className="co-m-table-grid co-m-table-grid--bordered">
<div className="row co-m-table-grid__head">
<div className="col-sm-3 col-xs-4">Name</div>
<div className="col-sm-3 col-xs-4">Type</div>
<div className="col-sm-3 hidden-xs">Permissions</div>
<div className="col-sm-3 col-xs-4">Utilized By</div>
</div>
<div className="co-m-table-grid__body">
{getVolumeMountsByPermissions(pod).map((v, i) => <Volume key={i} pod={pod} volume={v} />)}
</div>
</div>
{_.isEmpty(pod.spec.volumes)
? <EmptyBox label="Volumes" />
: (
<div className="co-m-table-grid co-m-table-grid--bordered">
<div className="row co-m-table-grid__head">
<div className="col-sm-3 col-xs-4">Name</div>
<div className="col-sm-3 col-xs-4">Type</div>
<div className="col-sm-3 hidden-xs">Permissions</div>
<div className="col-sm-3 col-xs-4">Utilized By</div>
</div>
<div className="co-m-table-grid__body">
{getVolumeMountsByPermissions(pod).map((v, i) => <Volume key={i} pod={pod} volume={v} />)}
</div>
</div>
)}
</React.Fragment>
);

Expand Down
2 changes: 1 addition & 1 deletion frontend/public/module/k8s/pods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}, {});
Expand Down

0 comments on commit a0b75bc

Please sign in to comment.