csi: volumes use `Schedulable` rather than `Healthy` (#7250)
* structs: add ControllerRequired, volume.Name, no plug.Type * structs: Healthy -> Schedulable * state_store: Healthy -> Schedulable * api: add ControllerRequired to api data types * api: copy csi structs changes * nomad/structs/csi: include name and external id * api/csi: include Name and ExternalID * nomad/structs/csi: comments for the 3 ids
This commit is contained in:
parent
a4784ef258
commit
369b0e54b9
19
api/csi.go
19
api/csi.go
|
@ -81,6 +81,8 @@ const (
|
||||||
type CSIVolume struct {
|
type CSIVolume struct {
|
||||||
ID string
|
ID string
|
||||||
Namespace string
|
Namespace string
|
||||||
|
Name string
|
||||||
|
ExternalID string
|
||||||
Topologies []*CSITopology
|
Topologies []*CSITopology
|
||||||
AccessMode CSIVolumeAccessMode
|
AccessMode CSIVolumeAccessMode
|
||||||
AttachmentMode CSIVolumeAttachmentMode
|
AttachmentMode CSIVolumeAttachmentMode
|
||||||
|
@ -88,11 +90,9 @@ type CSIVolume struct {
|
||||||
// Combine structs.{Read,Write,Past}Allocs
|
// Combine structs.{Read,Write,Past}Allocs
|
||||||
Allocations []*AllocationListStub
|
Allocations []*AllocationListStub
|
||||||
|
|
||||||
// Healthy is true iff all the denormalized plugin health fields are true, and the
|
Schedulable bool
|
||||||
// volume has not been marked for garbage collection
|
|
||||||
Healthy bool
|
|
||||||
VolumeGC time.Time
|
|
||||||
PluginID string
|
PluginID string
|
||||||
|
ControllerRequired bool
|
||||||
ControllersHealthy int
|
ControllersHealthy int
|
||||||
ControllersExpected int
|
ControllersExpected int
|
||||||
NodesHealthy int
|
NodesHealthy int
|
||||||
|
@ -121,15 +121,14 @@ func (v CSIVolumeIndexSort) Swap(i, j int) {
|
||||||
type CSIVolumeListStub struct {
|
type CSIVolumeListStub struct {
|
||||||
ID string
|
ID string
|
||||||
Namespace string
|
Namespace string
|
||||||
|
Name string
|
||||||
|
ExternalID string
|
||||||
Topologies []*CSITopology
|
Topologies []*CSITopology
|
||||||
AccessMode CSIVolumeAccessMode
|
AccessMode CSIVolumeAccessMode
|
||||||
AttachmentMode CSIVolumeAttachmentMode
|
AttachmentMode CSIVolumeAttachmentMode
|
||||||
|
Schedulable bool
|
||||||
// Healthy is true iff all the denormalized plugin health fields are true, and the
|
|
||||||
// volume has not been marked for garbage collection
|
|
||||||
Healthy bool
|
|
||||||
VolumeGC time.Time
|
|
||||||
PluginID string
|
PluginID string
|
||||||
|
ControllerRequired bool
|
||||||
ControllersHealthy int
|
ControllersHealthy int
|
||||||
ControllersExpected int
|
ControllersExpected int
|
||||||
NodesHealthy int
|
NodesHealthy int
|
||||||
|
@ -157,6 +156,7 @@ type CSIPlugins struct {
|
||||||
|
|
||||||
type CSIPlugin struct {
|
type CSIPlugin struct {
|
||||||
ID string
|
ID string
|
||||||
|
ControllerRequired bool
|
||||||
// Map Node.ID to CSIInfo fingerprint results
|
// Map Node.ID to CSIInfo fingerprint results
|
||||||
Controllers map[string]*CSIInfo
|
Controllers map[string]*CSIInfo
|
||||||
Nodes map[string]*CSIInfo
|
Nodes map[string]*CSIInfo
|
||||||
|
@ -168,6 +168,7 @@ type CSIPlugin struct {
|
||||||
|
|
||||||
type CSIPluginListStub struct {
|
type CSIPluginListStub struct {
|
||||||
ID string
|
ID string
|
||||||
|
ControllerRequired bool
|
||||||
ControllersHealthy int
|
ControllersHealthy int
|
||||||
ControllersExpected int
|
ControllersExpected int
|
||||||
NodesHealthy int
|
NodesHealthy int
|
||||||
|
|
|
@ -1783,7 +1783,7 @@ func (s *StateStore) CSIVolumeDenormalizePlugins(ws memdb.WatchSet, vol *structs
|
||||||
if plug == nil {
|
if plug == nil {
|
||||||
vol.ControllersHealthy = 0
|
vol.ControllersHealthy = 0
|
||||||
vol.NodesHealthy = 0
|
vol.NodesHealthy = 0
|
||||||
vol.Healthy = false
|
vol.Schedulable = false
|
||||||
return vol, nil
|
return vol, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1795,9 +1795,9 @@ func (s *StateStore) CSIVolumeDenormalizePlugins(ws memdb.WatchSet, vol *structs
|
||||||
vol.ControllersExpected = len(plug.Controllers)
|
vol.ControllersExpected = len(plug.Controllers)
|
||||||
vol.NodesExpected = len(plug.Nodes)
|
vol.NodesExpected = len(plug.Nodes)
|
||||||
|
|
||||||
vol.Healthy = vol.NodesHealthy > 0
|
vol.Schedulable = vol.NodesHealthy > 0
|
||||||
if vol.ControllerRequired {
|
if vol.ControllerRequired {
|
||||||
vol.Healthy = vol.ControllersHealthy > 0 && vol.Healthy
|
vol.Schedulable = vol.ControllersHealthy > 0 && vol.Schedulable
|
||||||
}
|
}
|
||||||
|
|
||||||
return vol, nil
|
return vol, nil
|
||||||
|
|
|
@ -2837,7 +2837,7 @@ func TestStateStore_CSIVolume(t *testing.T) {
|
||||||
v0.ID = id0
|
v0.ID = id0
|
||||||
v0.Namespace = "default"
|
v0.Namespace = "default"
|
||||||
v0.PluginID = "minnie"
|
v0.PluginID = "minnie"
|
||||||
v0.Healthy = true
|
v0.Schedulable = true
|
||||||
v0.AccessMode = structs.CSIVolumeAccessModeMultiNodeSingleWriter
|
v0.AccessMode = structs.CSIVolumeAccessModeMultiNodeSingleWriter
|
||||||
v0.AttachmentMode = structs.CSIVolumeAttachmentModeFilesystem
|
v0.AttachmentMode = structs.CSIVolumeAttachmentModeFilesystem
|
||||||
|
|
||||||
|
@ -2846,7 +2846,7 @@ func TestStateStore_CSIVolume(t *testing.T) {
|
||||||
v1.ID = id1
|
v1.ID = id1
|
||||||
v1.Namespace = "default"
|
v1.Namespace = "default"
|
||||||
v1.PluginID = "adam"
|
v1.PluginID = "adam"
|
||||||
v1.Healthy = true
|
v1.Schedulable = true
|
||||||
v1.AccessMode = structs.CSIVolumeAccessModeMultiNodeSingleWriter
|
v1.AccessMode = structs.CSIVolumeAccessModeMultiNodeSingleWriter
|
||||||
v1.AttachmentMode = structs.CSIVolumeAttachmentModeFilesystem
|
v1.AttachmentMode = structs.CSIVolumeAttachmentModeFilesystem
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,12 @@ func ValidCSIVolumeWriteAccessMode(accessMode CSIVolumeAccessMode) bool {
|
||||||
|
|
||||||
// CSIVolume is the full representation of a CSI Volume
|
// CSIVolume is the full representation of a CSI Volume
|
||||||
type CSIVolume struct {
|
type CSIVolume struct {
|
||||||
|
// ID is a namespace unique URL safe identifier for the volume
|
||||||
ID string
|
ID string
|
||||||
|
// Name is a display name for the volume, not required to be unique
|
||||||
|
Name string
|
||||||
|
// ExternalID identifies the volume for the CSI interface, may be URL unsafe
|
||||||
|
ExternalID string
|
||||||
Namespace string
|
Namespace string
|
||||||
Topologies []*CSITopology
|
Topologies []*CSITopology
|
||||||
AccessMode CSIVolumeAccessMode
|
AccessMode CSIVolumeAccessMode
|
||||||
|
@ -147,10 +152,9 @@ type CSIVolume struct {
|
||||||
ReadAllocs map[string]*Allocation
|
ReadAllocs map[string]*Allocation
|
||||||
WriteAllocs map[string]*Allocation
|
WriteAllocs map[string]*Allocation
|
||||||
|
|
||||||
// Healthy is true if all the denormalized plugin health fields are true, and the
|
// Schedulable is true if all the denormalized plugin health fields are true, and the
|
||||||
// volume has not been marked for garbage collection
|
// volume has not been marked for garbage collection
|
||||||
Healthy bool
|
Schedulable bool
|
||||||
VolumeGC time.Time
|
|
||||||
PluginID string
|
PluginID string
|
||||||
ControllerRequired bool
|
ControllerRequired bool
|
||||||
ControllersHealthy int
|
ControllersHealthy int
|
||||||
|
@ -167,13 +171,14 @@ type CSIVolume struct {
|
||||||
type CSIVolListStub struct {
|
type CSIVolListStub struct {
|
||||||
ID string
|
ID string
|
||||||
Namespace string
|
Namespace string
|
||||||
|
Name string
|
||||||
|
ExternalID string
|
||||||
Topologies []*CSITopology
|
Topologies []*CSITopology
|
||||||
AccessMode CSIVolumeAccessMode
|
AccessMode CSIVolumeAccessMode
|
||||||
AttachmentMode CSIVolumeAttachmentMode
|
AttachmentMode CSIVolumeAttachmentMode
|
||||||
CurrentReaders int
|
CurrentReaders int
|
||||||
CurrentWriters int
|
CurrentWriters int
|
||||||
Healthy bool
|
Schedulable bool
|
||||||
VolumeGC time.Time
|
|
||||||
PluginID string
|
PluginID string
|
||||||
ControllersHealthy int
|
ControllersHealthy int
|
||||||
ControllersExpected int
|
ControllersExpected int
|
||||||
|
@ -208,13 +213,14 @@ func (v *CSIVolume) Stub() *CSIVolListStub {
|
||||||
stub := CSIVolListStub{
|
stub := CSIVolListStub{
|
||||||
ID: v.ID,
|
ID: v.ID,
|
||||||
Namespace: v.Namespace,
|
Namespace: v.Namespace,
|
||||||
|
Name: v.Name,
|
||||||
|
ExternalID: v.ExternalID,
|
||||||
Topologies: v.Topologies,
|
Topologies: v.Topologies,
|
||||||
AccessMode: v.AccessMode,
|
AccessMode: v.AccessMode,
|
||||||
AttachmentMode: v.AttachmentMode,
|
AttachmentMode: v.AttachmentMode,
|
||||||
CurrentReaders: len(v.ReadAllocs),
|
CurrentReaders: len(v.ReadAllocs),
|
||||||
CurrentWriters: len(v.WriteAllocs),
|
CurrentWriters: len(v.WriteAllocs),
|
||||||
Healthy: v.Healthy,
|
Schedulable: v.Schedulable,
|
||||||
VolumeGC: v.VolumeGC,
|
|
||||||
PluginID: v.PluginID,
|
PluginID: v.PluginID,
|
||||||
ControllersHealthy: v.ControllersHealthy,
|
ControllersHealthy: v.ControllersHealthy,
|
||||||
NodesHealthy: v.NodesHealthy,
|
NodesHealthy: v.NodesHealthy,
|
||||||
|
@ -227,7 +233,7 @@ func (v *CSIVolume) Stub() *CSIVolListStub {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *CSIVolume) CanReadOnly() bool {
|
func (v *CSIVolume) CanReadOnly() bool {
|
||||||
if !v.Healthy {
|
if !v.Schedulable {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +241,7 @@ func (v *CSIVolume) CanReadOnly() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *CSIVolume) CanWrite() bool {
|
func (v *CSIVolume) CanWrite() bool {
|
||||||
if !v.Healthy {
|
if !v.Schedulable {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,6 +561,7 @@ func (p *CSIPlugin) DeleteNode(nodeID string) {
|
||||||
|
|
||||||
type CSIPluginListStub struct {
|
type CSIPluginListStub struct {
|
||||||
ID string
|
ID string
|
||||||
|
ControllerRequired bool
|
||||||
ControllersHealthy int
|
ControllersHealthy int
|
||||||
ControllersExpected int
|
ControllersExpected int
|
||||||
NodesHealthy int
|
NodesHealthy int
|
||||||
|
@ -566,6 +573,7 @@ type CSIPluginListStub struct {
|
||||||
func (p *CSIPlugin) Stub() *CSIPluginListStub {
|
func (p *CSIPlugin) Stub() *CSIPluginListStub {
|
||||||
return &CSIPluginListStub{
|
return &CSIPluginListStub{
|
||||||
ID: p.ID,
|
ID: p.ID,
|
||||||
|
ControllerRequired: p.ControllerRequired,
|
||||||
ControllersHealthy: p.ControllersHealthy,
|
ControllersHealthy: p.ControllersHealthy,
|
||||||
ControllersExpected: len(p.Controllers),
|
ControllersExpected: len(p.Controllers),
|
||||||
NodesHealthy: p.NodesHealthy,
|
NodesHealthy: p.NodesHealthy,
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
func TestCSIVolumeClaim(t *testing.T) {
|
func TestCSIVolumeClaim(t *testing.T) {
|
||||||
vol := NewCSIVolume("", 0)
|
vol := NewCSIVolume("", 0)
|
||||||
vol.AccessMode = CSIVolumeAccessModeMultiNodeSingleWriter
|
vol.AccessMode = CSIVolumeAccessModeMultiNodeSingleWriter
|
||||||
vol.Healthy = true
|
vol.Schedulable = true
|
||||||
|
|
||||||
alloc := &Allocation{ID: "al"}
|
alloc := &Allocation{ID: "al"}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue