Skip to content

Commit e6f59d7

Browse files
committed
roachprod,gcloud: return early in ListVolumes if disk mismatch
ListVolumes depends on the described and attached disk commands returning the same amount of disks in the same order, as there is not enough info in the responses to join them together. If one response contains more disks, e.g. if local SSDs are used, then the function will panic.
1 parent 4b6268f commit e6f59d7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/roachprod/vm/gce/gcloud.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,16 @@ func (p *Provider) ListVolumes(l *logger.Logger, v *vm.VM) ([]vm.Volume, error)
874874
}
875875
}
876876

877+
// Unfortunately the above responses contain no common identifier to join
878+
// on, so we must resort to indexing. This does not work if the number of
879+
// attached disks is different from the number of described volumes, i.e.
880+
// if the cluster is using local SSDs.
881+
if len(attachedDisks) != len(describedVolumes) {
882+
err := errors.Newf("expected to find the same number of attached disks (%d) as described volumes (%d)",
883+
len(attachedDisks), len(describedVolumes))
884+
return nil, errors.WithHint(err, "is the cluster using local SSD?")
885+
}
886+
877887
var volumes []vm.Volume
878888
for idx := range attachedDisks {
879889
attachedDisk := attachedDisks[idx]

0 commit comments

Comments
 (0)