Skip to content

Commit

Permalink
feat(swarm): removed workaround support for mock staging/unstaging (#746
Browse files Browse the repository at this point in the history
)

With the merge of moby/swarmkit#3116 the mock
staging/unstaging is not needed anymore. It was introduced in our
csi-driver in this commit:
619fa5c.
Which is part of a large PR (squashed commit) that included experimental
support for Docker swarm.

See:
- #376 
- #382

---------
  • Loading branch information
lukasmetzner authored Oct 18, 2024
1 parent f908f5d commit 465ec21
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 45 deletions.
8 changes: 1 addition & 7 deletions deploy/docker-swarm/pkg/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
"value"
],
"value": "debug"
},
{
"name": "FORCE_STAGING_SUPPORT",
"description": "workaround: force staging support to make Docker 23.0.0 work without https://github.com/moby/swarmkit/pull/3116",
"settable": ["value"],
"value": "true"
}
],
"interface": {
Expand Down Expand Up @@ -65,4 +59,4 @@
"type": "host"
},
"propagatedmount": "/data/published"
}
}
53 changes: 15 additions & 38 deletions internal/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package driver
import (
"context"
"fmt"
"os"

proto "github.com/container-storage-interface/spec/lib/go/csi"
"github.com/go-kit/log"
Expand All @@ -22,11 +21,6 @@ type NodeService struct {
volumeMountService volumes.MountService
volumeResizeService volumes.ResizeService
volumeStatsService volumes.StatsService
// enable volume staging api to workaround
// docker CSI support not working properly
// if a plugin does not support staging
// see https://github.com/moby/swarmkit/pull/3116
forceVolumeStaging bool
}

func NewNodeService(
Expand All @@ -44,20 +38,17 @@ func NewNodeService(
volumeMountService: volumeMountService,
volumeResizeService: volumeResizeService,
volumeStatsService: volumeStatsService,
forceVolumeStaging: os.Getenv("FORCE_STAGING_SUPPORT") == "true",
}
}

const encryptionPassphraseKey = "encryption-passphrase"

func (s *NodeService) NodeStageVolume(_ context.Context, _ *proto.NodeStageVolumeRequest) (*proto.NodeStageVolumeResponse, error) {
// while we dont do anything here, Swarm 23.0.1 might require this
return &proto.NodeStageVolumeResponse{}, nil
return nil, status.Error(codes.Unimplemented, "not supported")
}

func (s *NodeService) NodeUnstageVolume(_ context.Context, _ *proto.NodeUnstageVolumeRequest) (*proto.NodeUnstageVolumeResponse, error) {
// while we dont do anything here, Swarm 23.0.1 might require this
return &proto.NodeUnstageVolumeResponse{}, nil
return nil, status.Error(codes.Unimplemented, "not supported")
}

func (s *NodeService) NodePublishVolume(_ context.Context, req *proto.NodePublishVolumeRequest) (*proto.NodePublishVolumeResponse, error) {
Expand Down Expand Up @@ -159,38 +150,24 @@ func (s *NodeService) NodeGetVolumeStats(_ context.Context, req *proto.NodeGetVo
}

func (s *NodeService) NodeGetCapabilities(_ context.Context, _ *proto.NodeGetCapabilitiesRequest) (*proto.NodeGetCapabilitiesResponse, error) {
capabilities := []*proto.NodeServiceCapability{
{
Type: &proto.NodeServiceCapability_Rpc{
Rpc: &proto.NodeServiceCapability_RPC{
Type: proto.NodeServiceCapability_RPC_EXPAND_VOLUME,
return &proto.NodeGetCapabilitiesResponse{
Capabilities: []*proto.NodeServiceCapability{
{
Type: &proto.NodeServiceCapability_Rpc{
Rpc: &proto.NodeServiceCapability_RPC{
Type: proto.NodeServiceCapability_RPC_EXPAND_VOLUME,
},
},
},
},
{
Type: &proto.NodeServiceCapability_Rpc{
Rpc: &proto.NodeServiceCapability_RPC{
Type: proto.NodeServiceCapability_RPC_GET_VOLUME_STATS,
{
Type: &proto.NodeServiceCapability_Rpc{
Rpc: &proto.NodeServiceCapability_RPC{
Type: proto.NodeServiceCapability_RPC_GET_VOLUME_STATS,
},
},
},
},
}

if s.forceVolumeStaging {
capabilities = append(capabilities, &proto.NodeServiceCapability{
Type: &proto.NodeServiceCapability_Rpc{
Rpc: &proto.NodeServiceCapability_RPC{
Type: proto.NodeServiceCapability_RPC_STAGE_UNSTAGE_VOLUME,
},
},
})
}

resp := &proto.NodeGetCapabilitiesResponse{
Capabilities: capabilities,
}

return resp, nil
}, nil
}

func (s *NodeService) NodeGetInfo(_ context.Context, _ *proto.NodeGetInfoRequest) (*proto.NodeGetInfoResponse, error) {
Expand Down

0 comments on commit 465ec21

Please sign in to comment.