Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

volume status: default type to show both DHV and CSI volumes #25185

Merged
merged 3 commits into from
Feb 24, 2025

Conversation

tgross
Copy link
Member

@tgross tgross commented Feb 21, 2025

The -type option for volume status is a UX papercut because for many clusters there will be only one sort of volume in use. Update the CLI so that the default behavior is to query CSI and/or DHV.

This behavior is subtly different when the user provides an ID or not. If the user doesn't provide an ID, we query both CSI and DHV and show both tables. If the user provides an ID, we query DHV first and then CSI, and show only the appropriate volume. Because DHV IDs are UUIDs, we're sure we won't have collisions between the two. We only show errors if both queries return an error.

Fixes: https://hashicorp.atlassian.net/browse/NET-12214


Example outputs

Neither CSI or dynamic host volumes
$ nomad volume status -type host
Dynamic Host Volumes
No dynamic host volumes

$ nomad volume status -type csi
Container Storage Interface
No CSI volumes

$ nomad volume status
Dynamic Host Volumes
No dynamic host volumes

Container Storage Interface
No CSI volumes

$ nomad volume status -type csi not-existing
Error listing CSI volumes: No volumes with prefix or ID "not-existing" found

$ nomad volume status -type host not-existing
Error listing host volumes: no volumes with prefix or ID "not-existing" found

$ nomad volume status not-existing
Error listing host volumes: no volumes with prefix or ID "not-existing" found
Error listing CSI volumes: No volumes with prefix or ID "not-existing" found
Only dynamic host volumes
$ nomad volume status -type host
Dynamic Host Volumes
ID        Name             Namespace  Plugin ID            Node ID   Node Pool  State
070dc8ca  internal-plugin  default    mkdir                c3c27514  default    ready
7ce38017  external-plugin  default    example-plugin-mkfs  c3c27514  default    ready

$ nomad volume status -type csi
Container Storage Interface
No CSI volumes

$ nomad volume status
Dynamic Host Volumes
ID        Name             Namespace  Plugin ID            Node ID   Node Pool  State
070dc8ca  internal-plugin  default    mkdir                c3c27514  default    ready
7ce38017  external-plugin  default    example-plugin-mkfs  c3c27514  default    ready

Container Storage Interface
No CSI volumes

$ nomad volume status -type csi 070d
Error listing CSI volumes: No volumes with prefix or ID "070d" found

# identical for nomad volume status -type csi 070d
$ nomad volume status 070d
ID        = 070dc8ca-cc20-5638-b032-cc7d032d99d6
Name      = internal-plugin
Namespace = default
Plugin ID = mkdir
Node ID   = c3c27514-3869-f3a1-f5b6-c79fb1761c26
Node Pool = default
Capacity  = 0 B
State     = ready
Host Path = /run/nomad/dev/data/host_volumes/070dc8ca-cc20-5638-b032-cc7d032d99d6

Capabilities
Access Mode         Attachment Mode
single-node-writer  file-system

Allocations
ID        Node ID   Task Group  Version  Desired  Status   Created    Modified
49d51b88  c3c27514  g           0        run      running  1m54s ago  1m43s ago
Both CSI and dynamic host volumes
$ nomad volume status
Dynamic Host Volumes
ID        Name             Namespace  Plugin ID            Node ID   Node Pool  State
070dc8ca  internal-plugin  default    mkdir                c3c27514  default    ready
7ce38017  external-plugin  default    example-plugin-mkfs  c3c27514  default    ready

Container Storage Interface
ID              Name            Namespace  Plugin ID         Schedulable  Access Mode
test-volume[0]  test-volume[0]  default    hostpath-plugin0  true         single-node-reader-only
test-volume[1]  test-volume[1]  default    hostpath-plugin0  true         single-node-reader-only

$ nomad volume status -verbose
Dynamic Host Volumes
ID                                    Name             Namespace  Plugin ID            Node ID                               Node Pool  State
070dc8ca-cc20-5638-b032-cc7d032d99d6  internal-plugin  default    mkdir                c3c27514-3869-f3a1-f5b6-c79fb1761c26  default    ready
7ce38017-1c5f-d76c-2c3b-3e37c1f7c110  external-plugin  default    example-plugin-mkfs  c3c27514-3869-f3a1-f5b6-c79fb1761c26  default    ready

Container Storage Interface
ID              Name            Namespace  Plugin ID         Schedulable  Access Mode
test-volume[0]  test-volume[0]  default    hostpath-plugin0  true         single-node-reader-only
test-volume[1]  test-volume[1]  default    hostpath-plugin0  true         single-node-reader-only

External ID                           Condition  Nodes
134b54af-f08d-11ef-b160-1a227be3fda2  OK         node-0
13457a45-f08d-11ef-b160-1a227be3fda2  OK         node-0

$ nomad volume status -type csi
Container Storage Interface
ID              Name            Namespace  Plugin ID         Schedulable  Access Mode
test-volume[0]  test-volume[0]  default    hostpath-plugin0  true         single-node-reader-only
test-volume[1]  test-volume[1]  default    hostpath-plugin0  true         single-node-reader-only

$ nomad volume status -type host 'test-volume[0]'
Error listing host volumes: no volumes with prefix or ID "test-volume[0]" found

$ nomad volume status 'test-volume[0]'
ID                   = test-volume[0]
Name                 = test-volume[0]
Namespace            = default
External ID          = 13457a45-f08d-11ef-b160-1a227be3fda2
Plugin ID            = hostpath-plugin0
Provider             = csi-hostpath
Version              = v1.9.0
Capacity             = 977 KiB
Schedulable          = true
Controllers Healthy  = 1
Controllers Expected = 1
Nodes Healthy        = 1
Nodes Expected       = 1
Access Mode          = single-node-reader-only
Attachment Mode      = file-system
Mount Options        = flags: [REDACTED]

Topologies
Topology  Segments
01        topology.hostpath.csi/node=node-0

Capabilities
Access Mode              Attachment Mode
single-node-reader-only  file-system
single-node-writer       file-system

Allocations
ID        Node ID   Task Group  Version  Desired  Status   Created   Modified
0565d599  c3c27514  cache       0        run      running  1m7s ago  54s ago

The `-type` option for `volume status` is a UX papercut because for many
clusters there will be only one sort of volume in use. Update the CLI so that
the default behavior is to query CSI and/or DHV.

This behavior is subtly different when the user provides an ID or not. If the
user doesn't provide an ID, we query both CSI and DHV and show both tables. If
the user provides an ID, we query DHV first and then CSI, and show only the
appropriate volume. Because DHV IDs are UUIDs, we're sure we won't have
collisions between the two. We only show errors if both queries return an error.

Fixes: https://hashicorp.atlassian.net/browse/NET-12214
gulducat
gulducat previously approved these changes Feb 21, 2025
Copy link
Member

@gulducat gulducat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great! very nice QOL improvement. I just have a couple little nits to pick.

Copy link
Member

@gulducat gulducat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@tgross tgross merged commit 4cdfa19 into main Feb 24, 2025
33 checks passed
@tgross tgross deleted the dhv-volume-status-type branch February 24, 2025 16:38
tgross added a commit that referenced this pull request Feb 26, 2025
In #25185 we changed the output of `volume status` to include both DHV and CSI
volumes by default. When the E2E test parses the output, it's not expecting the
new section header.

Ref: #25185
tgross added a commit that referenced this pull request Feb 26, 2025
In #25185 we changed the output of `volume status` to include both DHV and CSI
volumes by default. When the E2E test parses the output, it's not expecting the
new section header.

Ref: #25185
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants