From 2c9cad26be076582c624bc241e55e9b90bbd23ad Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Thu, 23 Jul 2020 16:24:06 -0400 Subject: [PATCH] csi: avoid panic in CLI for failed node attachment cleanup If the node API returns an attached volume that doesn't belong to an alloc (because it's failed to clean up properly), `nomad node status` will panic when rendering the response. --- command/node_status.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/command/node_status.go b/command/node_status.go index cb882acd3eb9..c7f449238ccc 100644 --- a/command/node_status.go +++ b/command/node_status.go @@ -563,8 +563,10 @@ func (c *NodeStatusCommand) outputNodeCSIVolumeInfo(client *api.Client, node *ap volumes := map[string]*api.CSIVolumeListStub{} vs, _ := client.Nodes().CSIVolumes(node.ID, nil) for _, v := range vs { - n := requests[v.ID].Name - volumes[n] = v + n, ok := requests[v.ID] + if ok { + volumes[n.Name] = v + } } // Output the volumes in name order