Add Swarm Cluster Volume support#41982
Conversation
|
Related swarm kit branch (not fully up to date); https://github.com/docker/swarmkit/compare/feature-volumes |
|
@dperny can you share instruction how to test this with some CSI plugin? |
|
no updates in 7mo. Ouch. |
698d976 to
954cede
Compare
0c67329 to
383cb01
Compare
383cb01 to
346be51
Compare
|
I'm unclear why these integration tests are failing. |
|
This PR is ready for review. There is one major outstanding issue: Currently, there is no checking to ensure there is no duplication between local and cluster volume names. That is, if a local volume already exists with a given name, a cluster volume can be created with the same name, and visa versa. This problem is not an easy fix. If we simply check to see if a volume already exists, we run the risk of a race. We cannot mitigate this with locking, because the nature of swarm and cluster volumes means we would have to acquire a lock on the cluster to avoid other nodes making API calls to create cluster volumes. Otherwise, this should be the first final form of this PR, finally. |
|
To mount a cluster volume, do we need to specify the scope? Something like: |
|
Now i'm going to have to navigate the little issue of, all the CSI drivers of interest to me come with helm charts, and or instructions for installation on K8s. |
|
@chrisbecke This is actually, funny enough, also my problem. Basically, I've had to extract binaries from the images used by Kube or build those binaries from scratch and then build a Swarm CSI compatible Docker Plugin configuration. It's completely possible and doesn't require any changes in the CSI drivers, but I do have to start over from just the binaries. It doesn't help that many of these binaries lack documentation of what the actual binary does and what arguments it takes, as opposed to the args taken by the helm charts. On the bright side, I already work scoped out for documenting this process for plugin developers and super users. |
346be51 to
81b0e1e
Compare
6c14d43 to
2dde77e
Compare
| "gotest.tools/v3/assert" | ||
| ) | ||
|
|
||
| // TODO(dperny): write tests |
thaJeztah
left a comment
There was a problem hiding this comment.
almost there (I think!) found some issues / suggestions; let me push one more PR against your branch
| type ClusterBackend interface { | ||
| GetVolume(nameOrID string) (volume.Volume, error) | ||
| GetVolumes(options volume.ListOptions) ([]*volume.Volume, error) | ||
| CreateVolume(volume volume.CreateOptions) (*volume.Volume, error) | ||
| RemoveVolume(nameOrID string, force bool) error | ||
| UpdateVolume(nameOrID string, version uint64, volume volume.UpdateOptions) error | ||
| IsManager() bool | ||
| } |
There was a problem hiding this comment.
In a follow-up, perhaps we should look if we can unify the interface with the (non-cluster) Backend above; there appears to be an overlap (but slightly different signatures); if we unify both, possibly ClusterBackend could be Backend plus <cluster-specific methods>, like;
type ClusterBackend interface {
Backend
Update(nameOrID string, version uint64, volume volume.UpdateOptions) error
IsManager() bool
}Not a show-stopper though; the ClusterBackend is considered an internal interface (only to decouple internal code from the API), so we should be able to make (breaking) changes in future.
| const ( | ||
| // clusterVolumesVersion defines the API version that swarm cluster volume | ||
| // functionality was introduced. avoids the use of magic numbers. | ||
| clusterVolumesVersion = "1.42" |
There was a problem hiding this comment.
I was eyeing this const for a bit (was wondering if just putting 1.42 inline everywhere would be equally descriptive without having to look up the value of the const, but it's used in quite some places, so I guess it makes sense to have a const for this.
api/types/volume/cluster_volume.go
Outdated
| // CapacityBytes is the capacity of the volume in bytes. A value of 0 | ||
| // indicates that the capacity is unknown. | ||
| CapacityBytes int `json:",omitempty"` |
There was a problem hiding this comment.
I was looking at this, and initially wondering
- "should this be an
uint/uint64if we don't use negative values - would be consistent with
CapacityRange(which usesuint64) - ^^ could this be an issue? (are
CapacityRangeandCapacityBytescompared with each-other?)
it looks like the SwarmKit API type does use an int64, so changing this type to the same would prevent having to do some type-juggling;
moby/vendor/github.com/moby/swarmkit/v2/api/types.pb.go
Lines 4253 to 4255 in 1c12910
Looking slightly further, it looks like the SwarmKit API does do some conversion to an uint64;
moby/vendor/github.com/moby/swarmkit/v2/api/types.pb.go
Lines 12860 to 12868 in 1c12910
And looking even further, it seems that for CapacityRange we do the exact oposite; the Swarm API uses int64 but the moby type here uses uint64;
moby/vendor/github.com/moby/swarmkit/v2/api/types.pb.go
Lines 4303 to 4310 in 1c12910
Perhaps we should align them, so that we don't have to do the type-juggling on conversion 🤔
|
Opened dperny#2 |
|
As to #41982 (comment) above (
The error that would be returned wouldn't be very "friendly" though; I see @dperny merged my PR dperny#2, so now the Docker API uses As we no longer can depend on I'm curious though;
|
|
Maybe someone can put together a plugin (even if it's just for demo purposes) and push to dockerhub so everyone can give it a try? |
Adds code to support Cluster Volumes in Swarm using CSI drivers. Signed-off-by: Drew Erny <derny@mirantis.com>
|
CI is green, but there's a merge conflict now in version-history.md, due to #39812 being merged (saw that one coming); let me do a quick rebase |
a6e8e9e to
240a9fc
Compare
|
Very nice! 🥳 |
| #### Force-Removing Volumes | ||
|
|
||
| There are cases where a Volume can get caught in a state where Swarm cannot | ||
| verify their removal. In these cases, |
There was a problem hiding this comment.
Just saw that this sentence / paragraph is incomplete.
At the risk of being completely off-topic - a functional plugin that worked would be amazing. There is little as perplexing to new adopters of clustered containerization as the lack of persistent volume support and having a default plugin that provided clustered persistent volumes working in an expected way would alleviate a lot of the confusion. And, perhaps ensure that in 3 years time, Mirantis extend their support for our favorite orchestrator yet further... |
I've been trying to repackage the seaweedfs csi plugin for k8s to try out but I've been running into issues getting the plugin to connect to the running seaweedfs stack. An example would be great. |
|
Weighing in here as well. I am looking into repackaging https://github.com/hetznercloud/csi-driver for Docker, but right now I am lacking a place to start - Mostly a quick pointer as to how to load a plugin especially since 22.06 is in beta right now? I think that would already go a long way. |
|
Is anyone able to provide documentation for the community on repackaging CSI drivers for Docker / Docker Swarm? 🤔 |
|
@s4ke afaiu PR which you want follow is docker/cli#3662 Hopefully it gets included to next beta version. |
|
FYI. I have build some example scripts and guidance to https://github.com/olljanat/csi-plugins-for-docker-swarm about how to make existing CSI plugins working with Swarm which those who following this discussion might find useful. |
This is a preliminary, draft pull request for Swarm Cluster Volume Support. Though it is a long way off from being ready for merging, because of the size and scope of it, it is best to start review now.
This is more-or-less an implementation of the proposal in #39624.
Please give special attention to the API changes. I welcome any alternative suggestions for how to structure the API.
Closes #31923
Closes #39624