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

HostVolumePlugin interface and two implementations #24497

Merged
merged 9 commits into from
Nov 20, 2024

Conversation

gulducat
Copy link
Member

@gulducat gulducat commented Nov 19, 2024

This is functional end-to-end from CLI to Client, provided you place the example-host-volume plugin script in /opt/nomad/hostvolumeplugins/ on the client node, or use the "mkdir" internal plugin.

I have not tried this on MacOS or Windows, only my Linux laptop. Perhaps @pkazmierczak can test it on Mac for us? 🙂

There are many TODOs around, and no unit tests are present. Testing what's here is up next on my todo list, provided the overall shape of the interface here looks good to y'all.

Ref: #24479


The _test-plugin.sh script was convenient for me sprucing up the example plugin, and gave me two ideas for future:

  • a similar nomad CLI subcommand might be neat to include, to ease plugin development for users
  • the dir that will contain these plugins could skip files that start with _ (or . or something) for library files
    • this could encourage big complicated bash monsters, though, so maybe not

Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

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

LGTM once a few minor issues are resolved. Nice work on the plugin shell scripts!

client/hostvolumemanager/host_volume_plugin.go Outdated Show resolved Hide resolved
nomad/structs/csi.go Outdated Show resolved Hide resolved
@@ -501,6 +501,7 @@ func (v *HostVolume) deleteVolume(vol *structs.HostVolume) error {
method := "ClientHostVolume.Delete"
cReq := &cstructs.ClientHostVolumeDeleteRequest{
ID: vol.ID,
PluginID: vol.PluginID,
Copy link
Member

Choose a reason for hiding this comment

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

I suspect that once we have state tracking on the client we can slim down this RPC and drop PluginID and HostPath, but obviously fine for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

might need Parameters too. I can conceive of plugins that use the params in a call to some other system, or who knows.

demo/hostvolume/host.volume.hcl Outdated Show resolved Hide resolved
demo/hostvolume/host.volume.hcl Outdated Show resolved Hide resolved
client/hostvolumemanager/host_volume_plugin.go Outdated Show resolved Hide resolved
client/hostvolumemanager/host_volumes.go Outdated Show resolved Hide resolved
client/hostvolumemanager/host_volume_plugin.go Outdated Show resolved Hide resolved
client/hostvolumemanager/host_volume_plugin.go Outdated Show resolved Hide resolved
demo/hostvolume/example-host-volume Outdated Show resolved Hide resolved
tgross and others added 5 commits November 20, 2024 10:52
* mkdir: HostVolumePluginMkdir: just creates a directory
* example-host-volume: HostVolumePluginExternal:
  mkfs and mount loopback
send json PARAMETERS env var instead
@tgross
Copy link
Member

tgross commented Nov 20, 2024

@gulducat if you want to push testing into it's own PR that feels reasonable for a large PR on something so "side-effect-y" but we should probably add the package to the list in ci/test-core.json to make the linter happy?

@gulducat
Copy link
Member Author

I've started writing tests, but I'm also happy to open another PR for it, so we can all collectively use this purportedly-functional thing in the meantime 😜

@gulducat gulducat merged this pull request into dynamic-host-volumes Nov 20, 2024
18 checks passed
@gulducat gulducat deleted the dhv-plugins branch November 20, 2024 22:03
tgross added a commit that referenced this pull request Nov 20, 2024
* mkdir: HostVolumePluginMkdir: just creates a directory
* example-host-volume: HostVolumePluginExternal:
  plugin script that does mkfs and mount loopback

Co-authored-by: Tim Gross <[email protected]>
tgross added a commit that referenced this pull request Dec 2, 2024
* mkdir: HostVolumePluginMkdir: just creates a directory
* example-host-volume: HostVolumePluginExternal:
  plugin script that does mkfs and mount loopback

Co-authored-by: Tim Gross <[email protected]>
tgross added a commit that referenced this pull request Dec 3, 2024
* mkdir: HostVolumePluginMkdir: just creates a directory
* example-host-volume: HostVolumePluginExternal:
  plugin script that does mkfs and mount loopback

Co-authored-by: Tim Gross <[email protected]>
tgross added a commit that referenced this pull request Dec 9, 2024
* mkdir: HostVolumePluginMkdir: just creates a directory
* example-host-volume: HostVolumePluginExternal:
  plugin script that does mkfs and mount loopback

Co-authored-by: Tim Gross <[email protected]>
tgross added a commit that referenced this pull request Dec 13, 2024
* mkdir: HostVolumePluginMkdir: just creates a directory
* example-host-volume: HostVolumePluginExternal:
  plugin script that does mkfs and mount loopback

Co-authored-by: Tim Gross <[email protected]>
gulducat added a commit that referenced this pull request Dec 18, 2024
Instead of a plugin `version` subcommand that responds with a string
(established in #24497), respond to a `fingerprint` command with a data
structure that we may extend in the future (such as plugin capabilities,
like size constraint support?). In the immediate term, it's still just the
version: `{"version": "0.0.1"}`

In addition to leaving the door open for future expansion, I think it will
also avoid false positives detecting executables that just happen to
respond to a `version` command.

This also reverses the ordering of the fingerprint string parts
from `plugins.host_volume.version.mkdir` (which aligned with CNI)
to `plugins.host_volume.mkdir.version` (makes more sense to me)
tgross added a commit that referenced this pull request Dec 19, 2024
* mkdir: HostVolumePluginMkdir: just creates a directory
* example-host-volume: HostVolumePluginExternal:
  plugin script that does mkfs and mount loopback

Co-authored-by: Tim Gross <[email protected]>
tgross pushed a commit that referenced this pull request Dec 19, 2024
Instead of a plugin `version` subcommand that responds with a string
(established in #24497), respond to a `fingerprint` command with a data
structure that we may extend in the future (such as plugin capabilities,
like size constraint support?). In the immediate term, it's still just the
version: `{"version": "0.0.1"}`

In addition to leaving the door open for future expansion, I think it will
also avoid false positives detecting executables that just happen to
respond to a `version` command.

This also reverses the ordering of the fingerprint string parts
from `plugins.host_volume.version.mkdir` (which aligned with CNI)
to `plugins.host_volume.mkdir.version` (makes more sense to me)
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