compile
This commit is contained in:
parent
77697d3433
commit
1155c60704
4
Makefile
4
Makefile
@ -4,9 +4,11 @@ REGISTRY_NAME=seaweedfs
|
|||||||
IMAGE_NAME=csi
|
IMAGE_NAME=csi
|
||||||
VERSION ?= dev
|
VERSION ?= dev
|
||||||
IMAGE_TAG=$(REGISTRY_NAME)/$(IMAGE_NAME):$(VERSION)
|
IMAGE_TAG=$(REGISTRY_NAME)/$(IMAGE_NAME):$(VERSION)
|
||||||
|
COMMIT ?= $(shell git rev-parse --short HEAD)
|
||||||
|
LDFLAGS ?= -X github.com/seaweedfs/seaweedfs-csi-driver/pkg/driver.gitCommit=${COMMIT}
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o _output/seaweedfs-csi-driver ./cmd/seaweedfs-csi-driver/main.go
|
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '$(LDFLAGS)' -o _output/seaweedfs-csi-driver ./cmd/seaweedfs-csi-driver/main.go
|
||||||
container: build
|
container: build
|
||||||
docker build -t $(IMAGE_TAG) -f cmd/seaweedfs-csi-driver/Dockerfile .
|
docker build -t $(IMAGE_TAG) -f cmd/seaweedfs-csi-driver/Dockerfile .
|
||||||
push: container
|
push: container
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||||
"github.com/golang/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
)
|
)
|
||||||
@ -59,7 +59,7 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
|||||||
return &csi.CreateVolumeResponse{
|
return &csi.CreateVolumeResponse{
|
||||||
Volume: &csi.Volume{
|
Volume: &csi.Volume{
|
||||||
VolumeId: volumeId,
|
VolumeId: volumeId,
|
||||||
CapacityBytes: 0, // seaweedFsVolumeCount * 1024 * 1024 * 30,
|
CapacityBytes: capacity, // 0, // seaweedFsVolumeCount * 1024 * 1024 * 30,
|
||||||
VolumeContext: params,
|
VolumeContext: params,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@ -125,12 +125,17 @@ func (cs *ControllerServer) ValidateVolumeCapabilities(ctx context.Context, req
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
volCaps := req.GetVolumeCapabilities()
|
||||||
|
if len(volCaps) == 0 {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "Volume capabilities not provided")
|
||||||
|
}
|
||||||
|
var confirmed *csi.ValidateVolumeCapabilitiesResponse_Confirmed
|
||||||
|
if isValidVolumeCapabilities(cs.Driver.vcap, volCaps) {
|
||||||
|
confirmed = &csi.ValidateVolumeCapabilitiesResponse_Confirmed{VolumeCapabilities: volCaps}
|
||||||
|
}
|
||||||
|
|
||||||
return &csi.ValidateVolumeCapabilitiesResponse{
|
return &csi.ValidateVolumeCapabilitiesResponse{
|
||||||
Confirmed: &csi.ValidateVolumeCapabilitiesResponse_Confirmed{
|
Confirmed: confirmed,
|
||||||
VolumeContext: req.GetVolumeContext(),
|
|
||||||
VolumeCapabilities: req.GetVolumeCapabilities(),
|
|
||||||
Parameters: req.GetParameters(),
|
|
||||||
},
|
|
||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -177,4 +182,23 @@ func sanitizeVolumeId(volumeId string) string {
|
|||||||
volumeId = hex.EncodeToString(h.Sum(nil))
|
volumeId = hex.EncodeToString(h.Sum(nil))
|
||||||
}
|
}
|
||||||
return volumeId
|
return volumeId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isValidVolumeCapabilities(driverVolumeCaps []*csi.VolumeCapability_AccessMode, volCaps []*csi.VolumeCapability) bool {
|
||||||
|
hasSupport := func(cap *csi.VolumeCapability) bool {
|
||||||
|
for _, c := range driverVolumeCaps {
|
||||||
|
if c.GetMode() == cap.AccessMode.GetMode() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
foundAll := true
|
||||||
|
for _, c := range volCaps {
|
||||||
|
if !hasSupport(c) {
|
||||||
|
foundAll = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return foundAll
|
||||||
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/chrislusf/seaweedfs/weed/security"
|
"github.com/chrislusf/seaweedfs/weed/security"
|
||||||
"github.com/chrislusf/seaweedfs/weed/util"
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||||
"github.com/golang/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
@ -52,6 +52,9 @@ func NewSeaweedFsDriver(filer, nodeID, endpoint string) *SeaweedFsDriver {
|
|||||||
grpcDialOption: security.LoadClientTLS(util.GetViper(), "grpc.client"),
|
grpcDialOption: security.LoadClientTLS(util.GetViper(), "grpc.client"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{
|
||||||
|
csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
|
||||||
|
})
|
||||||
n.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{
|
n.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{
|
||||||
csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,
|
csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,
|
||||||
})
|
})
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package driver
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||||
"github.com/golang/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mitchellh/go-ps"
|
"github.com/mitchellh/go-ps"
|
||||||
"github.com/golang/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"k8s.io/utils/mount"
|
"k8s.io/utils/mount"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"k8s.io/utils/mount"
|
"k8s.io/utils/mount"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
|
|
||||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
@ -29,6 +29,9 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
|
|||||||
if req.GetVolumeCapability() == nil {
|
if req.GetVolumeCapability() == nil {
|
||||||
return nil, status.Error(codes.InvalidArgument, "Volume capability missing in request")
|
return nil, status.Error(codes.InvalidArgument, "Volume capability missing in request")
|
||||||
}
|
}
|
||||||
|
if !isValidVolumeCapabilities(ns.Driver.vcap, []*csi.VolumeCapability{req.GetVolumeCapability()}) {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "Volume capability not supported")
|
||||||
|
}
|
||||||
if volumeID == "" {
|
if volumeID == "" {
|
||||||
return nil, status.Error(codes.InvalidArgument, "Volume ID missing in request")
|
return nil, status.Error(codes.InvalidArgument, "Volume ID missing in request")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||||
"github.com/golang/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user