mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
volumes: add capabilities to volume status (#25173)
Job authors need to be able to review what capabilities a dynamic host volume or CSI volume has so that they can set the correct access mode and attachment mode in their job. Add these to the CLI output of `volume status`. Ref: https://hashicorp.atlassian.net/browse/NET-12063
This commit is contained in:
3
.changelog/25173.txt
Normal file
3
.changelog/25173.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:improvement
|
||||
csi: Show volume capabilities in the volume status command
|
||||
```
|
||||
@@ -224,8 +224,13 @@ func (c *VolumeStatusCommand) formatCSIBasic(vol *api.CSIVolume) (string, error)
|
||||
full = append(full, topo)
|
||||
}
|
||||
|
||||
banner := "\n[bold]Capabilities[reset]"
|
||||
caps := formatCSIVolumeCapabilities(vol.RequestedCapabilities)
|
||||
full = append(full, banner)
|
||||
full = append(full, caps)
|
||||
|
||||
// Format the allocs
|
||||
banner := c.Colorize().Color("\n[bold]Allocations[reset]")
|
||||
banner = c.Colorize().Color("\n[bold]Allocations[reset]")
|
||||
allocs := formatAllocListStubs(vol.Allocations, c.verbose, c.length)
|
||||
full = append(full, banner)
|
||||
full = append(full, allocs)
|
||||
@@ -291,3 +296,12 @@ func csiVolMountOption(volume, request *api.CSIMountOptions) string {
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func formatCSIVolumeCapabilities(caps []*api.CSIVolumeCapability) string {
|
||||
lines := make([]string, len(caps)+1)
|
||||
lines[0] = "Access Mode|Attachment Mode"
|
||||
for i, cap := range caps {
|
||||
lines[i+1] = fmt.Sprintf("%s|%s", cap.AccessMode, cap.AttachmentMode)
|
||||
}
|
||||
return formatList(lines)
|
||||
}
|
||||
|
||||
@@ -151,8 +151,13 @@ func formatHostVolume(vol *api.HostVolume, opts formatOpts) (string, error) {
|
||||
|
||||
full := []string{formatKV(output)}
|
||||
|
||||
banner := "\n[bold]Capabilities[reset]"
|
||||
caps := formatHostVolumeCapabilities(vol.RequestedCapabilities)
|
||||
full = append(full, banner)
|
||||
full = append(full, caps)
|
||||
|
||||
// Format the allocs
|
||||
banner := "\n[bold]Allocations[reset]"
|
||||
banner = "\n[bold]Allocations[reset]"
|
||||
allocs := formatAllocListStubs(vol.Allocations, opts.verbose, opts.length)
|
||||
full = append(full, banner)
|
||||
full = append(full, allocs)
|
||||
@@ -196,3 +201,12 @@ func formatHostVolumes(vols []*api.HostVolumeStub, opts formatOpts) (string, err
|
||||
}
|
||||
return formatList(rows), nil
|
||||
}
|
||||
|
||||
func formatHostVolumeCapabilities(caps []*api.HostVolumeCapability) string {
|
||||
lines := make([]string, len(caps)+1)
|
||||
lines[0] = "Access Mode|Attachment Mode"
|
||||
for i, cap := range caps {
|
||||
lines[i+1] = fmt.Sprintf("%s|%s", cap.AccessMode, cap.AttachmentMode)
|
||||
}
|
||||
return formatList(lines)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user