vendor: github.com/moby/swarmkit/v2 v2.0.0-20230302163403-80a528a86877
- fix docker service create doesn't work when network and generic-resource are both attached - Fix removing tasks when a jobs service is removed - CSI: Allow NodePublishVolume even when plugin does not support staging full diff:904c221ac2...80a528a868
Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit088aff1620
) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
d77ac3d8cc
commit
3bd2fc8d62
9 changed files with 101 additions and 115 deletions
|
@ -54,7 +54,7 @@ require (
|
|||
github.com/moby/locker v1.0.1
|
||||
github.com/moby/patternmatcher v0.5.0
|
||||
github.com/moby/pubsub v1.0.0
|
||||
github.com/moby/swarmkit/v2 v2.0.0-20230119195359-904c221ac281
|
||||
github.com/moby/swarmkit/v2 v2.0.0-20230302163403-80a528a86877
|
||||
github.com/moby/sys/mount v0.3.3
|
||||
github.com/moby/sys/mountinfo v0.6.2
|
||||
github.com/moby/sys/sequential v0.5.0
|
||||
|
|
|
@ -739,8 +739,8 @@ github.com/moby/patternmatcher v0.5.0 h1:YCZgJOeULcxLw1Q+sVR636pmS7sPEn1Qo2iAN6M
|
|||
github.com/moby/patternmatcher v0.5.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
|
||||
github.com/moby/pubsub v1.0.0 h1:jkp/imWsmJz2f6LyFsk7EkVeN2HxR/HTTOY8kHrsxfA=
|
||||
github.com/moby/pubsub v1.0.0/go.mod h1:bXSO+3h5MNXXCaEG+6/NlAIk7MMZbySZlnB+cUQhKKc=
|
||||
github.com/moby/swarmkit/v2 v2.0.0-20230119195359-904c221ac281 h1:E0LdO1cZEXmXrLoojCqEvVCk4cNLWSVotoDbWUmNa8g=
|
||||
github.com/moby/swarmkit/v2 v2.0.0-20230119195359-904c221ac281/go.mod h1:jIgi55SqNJvlQ74bK35NXKWz6JCTexx5h69d0btP2AM=
|
||||
github.com/moby/swarmkit/v2 v2.0.0-20230302163403-80a528a86877 h1:YJcIjSuBnXbYer03qePA2LbgM/CrQ/hquzcUH3W7soU=
|
||||
github.com/moby/swarmkit/v2 v2.0.0-20230302163403-80a528a86877/go.mod h1:08T6Kf5YJuIVS/RqADGxruH+8hh33zwjQETAxlvmke8=
|
||||
github.com/moby/sys/mount v0.3.3 h1:fX1SVkXFJ47XWDoeFW4Sq7PdQJnV2QIDZAqjNqgEjUs=
|
||||
github.com/moby/sys/mount v0.3.3/go.mod h1:PBaEorSNTLG5t/+4EgukEQVlAvVEc6ZjTySwKdqp5K0=
|
||||
github.com/moby/sys/mountinfo v0.4.0/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A=
|
||||
|
|
74
vendor/github.com/moby/swarmkit/v2/agent/csi/plugin/plugin.go
generated
vendored
74
vendor/github.com/moby/swarmkit/v2/agent/csi/plugin/plugin.go
generated
vendored
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/moby/swarmkit/v2/api"
|
||||
"github.com/moby/swarmkit/v2/internal/csi/capability"
|
||||
"github.com/moby/swarmkit/v2/log"
|
||||
)
|
||||
|
||||
|
@ -208,10 +209,9 @@ func (np *nodePlugin) NodeStageVolume(ctx context.Context, req *api.VolumeAssign
|
|||
}
|
||||
|
||||
stagingTarget := stagePath(req)
|
||||
|
||||
// Check arguments
|
||||
if len(req.VolumeID) == 0 {
|
||||
return status.Error(codes.InvalidArgument, "VolumeID missing in request")
|
||||
err := capability.CheckArguments(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := np.Client(ctx)
|
||||
|
@ -223,7 +223,7 @@ func (np *nodePlugin) NodeStageVolume(ctx context.Context, req *api.VolumeAssign
|
|||
VolumeId: req.VolumeID,
|
||||
StagingTargetPath: stagingTarget,
|
||||
Secrets: np.makeSecrets(req),
|
||||
VolumeCapability: makeCapability(req.AccessMode),
|
||||
VolumeCapability: capability.MakeCapability(req.AccessMode),
|
||||
VolumeContext: req.VolumeContext,
|
||||
PublishContext: req.PublishContext,
|
||||
})
|
||||
|
@ -286,9 +286,9 @@ func (np *nodePlugin) NodeUnstageVolume(ctx context.Context, req *api.VolumeAssi
|
|||
}
|
||||
|
||||
func (np *nodePlugin) NodePublishVolume(ctx context.Context, req *api.VolumeAssignment) error {
|
||||
// Check arguments
|
||||
if len(req.VolumeID) == 0 {
|
||||
return status.Error(codes.InvalidArgument, "Volume ID missing in request")
|
||||
err := capability.CheckArguments(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
np.mu.Lock()
|
||||
|
@ -296,14 +296,15 @@ func (np *nodePlugin) NodePublishVolume(ctx context.Context, req *api.VolumeAssi
|
|||
|
||||
publishTarget := publishPath(req)
|
||||
|
||||
// some volumes do not require staging. we can check this by checkign the
|
||||
// staging variable, or we can just see if there is a staging path in the
|
||||
// map.
|
||||
// Some volumes plugins require staging; we track this with a boolean, which
|
||||
// also implies a staging path in the path map. If the plugin is marked as
|
||||
// requiring staging but does not have a staging path in the map, that is an
|
||||
// error.
|
||||
var stagingPath string
|
||||
if vs, ok := np.volumeMap[req.ID]; ok {
|
||||
stagingPath = vs.stagingPath
|
||||
} else {
|
||||
return status.Error(codes.FailedPrecondition, "volume not staged")
|
||||
} else if np.staging {
|
||||
return status.Error(codes.FailedPrecondition, "volume requires staging but was not staged")
|
||||
}
|
||||
|
||||
c, err := np.Client(ctx)
|
||||
|
@ -315,7 +316,7 @@ func (np *nodePlugin) NodePublishVolume(ctx context.Context, req *api.VolumeAssi
|
|||
VolumeId: req.VolumeID,
|
||||
TargetPath: publishTarget,
|
||||
StagingTargetPath: stagingPath,
|
||||
VolumeCapability: makeCapability(req.AccessMode),
|
||||
VolumeCapability: capability.MakeCapability(req.AccessMode),
|
||||
Secrets: np.makeSecrets(req),
|
||||
VolumeContext: req.VolumeContext,
|
||||
PublishContext: req.PublishContext,
|
||||
|
@ -399,51 +400,6 @@ func makeNodeInfo(csiNodeInfo *csi.NodeGetInfoResponse) *api.NodeCSIInfo {
|
|||
}
|
||||
}
|
||||
|
||||
func makeCapability(am *api.VolumeAccessMode) *csi.VolumeCapability {
|
||||
var mode csi.VolumeCapability_AccessMode_Mode
|
||||
switch am.Scope {
|
||||
case api.VolumeScopeSingleNode:
|
||||
switch am.Sharing {
|
||||
case api.VolumeSharingNone, api.VolumeSharingOneWriter, api.VolumeSharingAll:
|
||||
mode = csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER
|
||||
case api.VolumeSharingReadOnly:
|
||||
mode = csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY
|
||||
}
|
||||
case api.VolumeScopeMultiNode:
|
||||
switch am.Sharing {
|
||||
case api.VolumeSharingReadOnly:
|
||||
mode = csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY
|
||||
case api.VolumeSharingOneWriter:
|
||||
mode = csi.VolumeCapability_AccessMode_MULTI_NODE_SINGLE_WRITER
|
||||
case api.VolumeSharingAll:
|
||||
mode = csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER
|
||||
}
|
||||
}
|
||||
|
||||
capability := &csi.VolumeCapability{
|
||||
AccessMode: &csi.VolumeCapability_AccessMode{
|
||||
Mode: mode,
|
||||
},
|
||||
}
|
||||
|
||||
if block := am.GetBlock(); block != nil {
|
||||
capability.AccessType = &csi.VolumeCapability_Block{
|
||||
// Block type is empty.
|
||||
Block: &csi.VolumeCapability_BlockVolume{},
|
||||
}
|
||||
}
|
||||
|
||||
if mount := am.GetMount(); mount != nil {
|
||||
capability.AccessType = &csi.VolumeCapability_Mount{
|
||||
Mount: &csi.VolumeCapability_MountVolume{
|
||||
FsType: mount.FsType,
|
||||
MountFlags: mount.MountFlags,
|
||||
},
|
||||
}
|
||||
}
|
||||
return capability
|
||||
}
|
||||
|
||||
// stagePath returns the staging path for a given volume assignment
|
||||
func stagePath(v *api.VolumeAssignment) string {
|
||||
// this really just exists so we use the same trick to determine staging
|
||||
|
|
64
vendor/github.com/moby/swarmkit/v2/internal/csi/capability/capability.go
generated
vendored
Normal file
64
vendor/github.com/moby/swarmkit/v2/internal/csi/capability/capability.go
generated
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
package capability
|
||||
|
||||
import (
|
||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||
"github.com/moby/swarmkit/v2/api"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func CheckArguments(req *api.VolumeAssignment) error {
|
||||
if len(req.VolumeID) == 0 {
|
||||
return status.Error(codes.InvalidArgument, "Volume ID missing in request")
|
||||
}
|
||||
if req.AccessMode == nil {
|
||||
return status.Error(codes.InvalidArgument, "AccessMode missing in request")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func MakeCapability(am *api.VolumeAccessMode) *csi.VolumeCapability {
|
||||
var mode csi.VolumeCapability_AccessMode_Mode
|
||||
switch am.Scope {
|
||||
case api.VolumeScopeSingleNode:
|
||||
switch am.Sharing {
|
||||
case api.VolumeSharingNone, api.VolumeSharingOneWriter, api.VolumeSharingAll:
|
||||
mode = csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER
|
||||
case api.VolumeSharingReadOnly:
|
||||
mode = csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY
|
||||
}
|
||||
case api.VolumeScopeMultiNode:
|
||||
switch am.Sharing {
|
||||
case api.VolumeSharingReadOnly:
|
||||
mode = csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY
|
||||
case api.VolumeSharingOneWriter:
|
||||
mode = csi.VolumeCapability_AccessMode_MULTI_NODE_SINGLE_WRITER
|
||||
case api.VolumeSharingAll:
|
||||
mode = csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER
|
||||
}
|
||||
}
|
||||
|
||||
capability := &csi.VolumeCapability{
|
||||
AccessMode: &csi.VolumeCapability_AccessMode{
|
||||
Mode: mode,
|
||||
},
|
||||
}
|
||||
|
||||
if block := am.GetBlock(); block != nil {
|
||||
capability.AccessType = &csi.VolumeCapability_Block{
|
||||
// Block type is empty.
|
||||
Block: &csi.VolumeCapability_BlockVolume{},
|
||||
}
|
||||
}
|
||||
|
||||
if mount := am.GetMount(); mount != nil {
|
||||
capability.AccessType = &csi.VolumeCapability_Mount{
|
||||
Mount: &csi.VolumeCapability_MountVolume{
|
||||
FsType: mount.FsType,
|
||||
MountFlags: mount.MountFlags,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return capability
|
||||
}
|
46
vendor/github.com/moby/swarmkit/v2/manager/csi/convert.go
generated
vendored
46
vendor/github.com/moby/swarmkit/v2/manager/csi/convert.go
generated
vendored
|
@ -45,52 +45,6 @@ func makeTopology(t *api.Topology) *csi.Topology {
|
|||
}
|
||||
}
|
||||
|
||||
func makeCapability(am *api.VolumeAccessMode) *csi.VolumeCapability {
|
||||
var mode csi.VolumeCapability_AccessMode_Mode
|
||||
switch am.Scope {
|
||||
case api.VolumeScopeSingleNode:
|
||||
switch am.Sharing {
|
||||
case api.VolumeSharingNone, api.VolumeSharingOneWriter, api.VolumeSharingAll:
|
||||
mode = csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER
|
||||
case api.VolumeSharingReadOnly:
|
||||
mode = csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY
|
||||
}
|
||||
case api.VolumeScopeMultiNode:
|
||||
switch am.Sharing {
|
||||
case api.VolumeSharingReadOnly:
|
||||
mode = csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY
|
||||
case api.VolumeSharingOneWriter:
|
||||
mode = csi.VolumeCapability_AccessMode_MULTI_NODE_SINGLE_WRITER
|
||||
case api.VolumeSharingAll:
|
||||
mode = csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER
|
||||
}
|
||||
}
|
||||
|
||||
capability := &csi.VolumeCapability{
|
||||
AccessMode: &csi.VolumeCapability_AccessMode{
|
||||
Mode: mode,
|
||||
},
|
||||
}
|
||||
|
||||
if block := am.GetBlock(); block != nil {
|
||||
capability.AccessType = &csi.VolumeCapability_Block{
|
||||
// Block type is empty.
|
||||
Block: &csi.VolumeCapability_BlockVolume{},
|
||||
}
|
||||
}
|
||||
|
||||
if mount := am.GetMount(); mount != nil {
|
||||
capability.AccessType = &csi.VolumeCapability_Mount{
|
||||
Mount: &csi.VolumeCapability_MountVolume{
|
||||
FsType: mount.FsType,
|
||||
MountFlags: mount.MountFlags,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return capability
|
||||
}
|
||||
|
||||
// makeCapcityRange converts the swarmkit CapacityRange object to the
|
||||
// equivalent CSI object
|
||||
func makeCapacityRange(cr *api.CapacityRange) *csi.CapacityRange {
|
||||
|
|
5
vendor/github.com/moby/swarmkit/v2/manager/csi/plugin.go
generated
vendored
5
vendor/github.com/moby/swarmkit/v2/manager/csi/plugin.go
generated
vendored
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/moby/swarmkit/v2/api"
|
||||
"github.com/moby/swarmkit/v2/internal/csi/capability"
|
||||
)
|
||||
|
||||
// Plugin is the interface for a CSI controller plugin.
|
||||
|
@ -275,7 +276,7 @@ func (p *plugin) makeCreateVolume(v *api.Volume) *csi.CreateVolumeRequest {
|
|||
Name: v.Spec.Annotations.Name,
|
||||
Parameters: v.Spec.Driver.Options,
|
||||
VolumeCapabilities: []*csi.VolumeCapability{
|
||||
makeCapability(v.Spec.AccessMode),
|
||||
capability.MakeCapability(v.Spec.AccessMode),
|
||||
},
|
||||
Secrets: secrets,
|
||||
AccessibilityRequirements: makeTopologyRequirement(v.Spec.AccessibilityRequirements),
|
||||
|
@ -307,7 +308,7 @@ func (p *plugin) makeControllerPublishVolumeRequest(v *api.Volume, nodeID string
|
|||
}
|
||||
|
||||
secrets := p.makeSecrets(v)
|
||||
capability := makeCapability(v.Spec.AccessMode)
|
||||
capability := capability.MakeCapability(v.Spec.AccessMode)
|
||||
capability.AccessType = &csi.VolumeCapability_Mount{
|
||||
Mount: &csi.VolumeCapability_MountVolume{},
|
||||
}
|
||||
|
|
|
@ -174,17 +174,22 @@ loop:
|
|||
removeTasks[t.ID] = t
|
||||
continue
|
||||
}
|
||||
|
||||
available.MemoryBytes -= t.Spec.Resources.Reservations.MemoryBytes
|
||||
available.NanoCPUs -= t.Spec.Resources.Reservations.NanoCPUs
|
||||
}
|
||||
|
||||
// Ensure that the task assigned to the node
|
||||
// still satisfies the available generic resources
|
||||
if t.AssignedGenericResources != nil {
|
||||
for _, ta := range t.AssignedGenericResources {
|
||||
// Type change or no longer available
|
||||
if genericresource.HasResource(ta, available.Generic) {
|
||||
if !genericresource.HasResource(ta, available.Generic) {
|
||||
removeTasks[t.ID] = t
|
||||
break loop
|
||||
}
|
||||
}
|
||||
|
||||
available.MemoryBytes -= t.Spec.Resources.Reservations.MemoryBytes
|
||||
available.NanoCPUs -= t.Spec.Resources.Reservations.NanoCPUs
|
||||
|
||||
genericresource.ClaimResources(&available.Generic,
|
||||
&fakeStore, t.AssignedGenericResources)
|
||||
}
|
||||
|
|
5
vendor/github.com/moby/swarmkit/v2/manager/orchestrator/jobs/orchestrator.go
generated
vendored
5
vendor/github.com/moby/swarmkit/v2/manager/orchestrator/jobs/orchestrator.go
generated
vendored
|
@ -201,6 +201,11 @@ func (o *Orchestrator) handleEvent(ctx context.Context, event events.Event) {
|
|||
service = ev.Service
|
||||
case api.EventUpdateService:
|
||||
service = ev.Service
|
||||
case api.EventDeleteService:
|
||||
if orchestrator.IsReplicatedJob(ev.Service) || orchestrator.IsGlobalJob(ev.Service) {
|
||||
orchestrator.SetServiceTasksRemove(ctx, o.store, ev.Service)
|
||||
o.restartSupervisor.ClearServiceHistory(ev.Service.ID)
|
||||
}
|
||||
case api.EventUpdateTask:
|
||||
task = ev.Task
|
||||
}
|
||||
|
|
3
vendor/modules.txt
vendored
3
vendor/modules.txt
vendored
|
@ -611,7 +611,7 @@ github.com/moby/patternmatcher
|
|||
# github.com/moby/pubsub v1.0.0
|
||||
## explicit; go 1.19
|
||||
github.com/moby/pubsub
|
||||
# github.com/moby/swarmkit/v2 v2.0.0-20230119195359-904c221ac281
|
||||
# github.com/moby/swarmkit/v2 v2.0.0-20230302163403-80a528a86877
|
||||
## explicit; go 1.18
|
||||
github.com/moby/swarmkit/v2/agent
|
||||
github.com/moby/swarmkit/v2/agent/configs
|
||||
|
@ -631,6 +631,7 @@ github.com/moby/swarmkit/v2/ca/keyutils
|
|||
github.com/moby/swarmkit/v2/ca/pkcs8
|
||||
github.com/moby/swarmkit/v2/connectionbroker
|
||||
github.com/moby/swarmkit/v2/identity
|
||||
github.com/moby/swarmkit/v2/internal/csi/capability
|
||||
github.com/moby/swarmkit/v2/ioutils
|
||||
github.com/moby/swarmkit/v2/log
|
||||
github.com/moby/swarmkit/v2/manager
|
||||
|
|
Loading…
Reference in a new issue