Skip to content

Commit

Permalink
csi: remove redundant schedulable check in FreeWriteClaims
Browse files Browse the repository at this point in the history
If a volume has been created but not yet claimed, its capabilities
will be checked in `WriteSchedulable` at both scheduling time and
claim time. We don't need to also check them in the `FreeWriteClaims`
method.
  • Loading branch information
tgross committed Feb 23, 2022
1 parent 85fb42f commit 3aedd9b
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions nomad/structs/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,24 +422,13 @@ func (v *CSIVolume) HasFreeWriteClaims() bool {
// which is checked in WriteSchedulable
return true
case CSIVolumeAccessModeUnknown:
// this volume was created but not yet claimed, so we check what it's
// capable of, not what it's been assigned
if len(v.RequestedCapabilities) == 0 {
// COMPAT: a volume that was registered before 1.1.0 and has not
// had a change in claims could have no requested caps. It will
// get corrected on the first claim.
return true
}
for _, cap := range v.RequestedCapabilities {
switch cap.AccessMode {
case CSIVolumeAccessModeSingleNodeWriter, CSIVolumeAccessModeMultiNodeSingleWriter:
return len(v.WriteClaims) == 0
case CSIVolumeAccessModeMultiNodeMultiWriter:
return true
}
}
// This volume was created but not yet claimed, so its
// capabilities have been checked in WriteSchedulable
return true
default:
// Reader modes never have free write claims
return false
}
return false
}

// InUse tests whether any allocations are actively using the volume
Expand Down

0 comments on commit 3aedd9b

Please sign in to comment.