Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #95 from wongma7/csi0.3
Browse files Browse the repository at this point in the history
Update to CSI 0.3
  • Loading branch information
lpabon authored Jul 13, 2018
2 parents 62ceb08 + 842e037 commit d8f283c
Show file tree
Hide file tree
Showing 21 changed files with 126 additions and 47 deletions.
31 changes: 7 additions & 24 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

[[constraint]]
name = "github.com/container-storage-interface/spec"
version = "~0.2.0"
version = "~0.3.0"

[[constraint]]
branch = "master"
Expand Down Expand Up @@ -72,3 +72,7 @@
[[override]]
version = "kubernetes-1.10.0-beta.1"
name = "k8s.io/api"

[[override]]
name = "github.com/golang/protobuf"
version = "v1.1.0"
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
serviceAccount: csi-attacher
containers:
- name: csi-attacher
image: quay.io/k8scsi/csi-attacher:v0.2.0
image: quay.io/k8scsi/csi-attacher:v0.3.0
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
hostNetwork: true
containers:
- name: driver-registrar
image: quay.io/k8scsi/driver-registrar:v0.2.0
image: quay.io/k8scsi/driver-registrar:v0.3.0
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
serviceAccount: csi-provisioner
containers:
- name: csi-provisioner
image: quay.io/k8scsi/csi-provisioner:v0.2.0
image: quay.io/k8scsi/csi-provisioner:v0.3.0
args:
- "--provisioner=csi-cinderplugin"
- "--csi-address=$(ADDRESS)"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cinder/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const (
)

var (
version = "0.2.0"
version = "0.3.0"
)

func NewDriver(nodeID, endpoint string, cloudconfig string) *driver {
Expand Down
41 changes: 34 additions & 7 deletions pkg/cinder/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,54 @@ type nodeServer struct {

func (ns *nodeServer) NodeGetId(ctx context.Context, req *csi.NodeGetIdRequest) (*csi.NodeGetIdResponse, error) {

// Get Mount Provider
m, err := mount.GetMountProvider()
nodeID, err := getNodeID()
if err != nil {
glog.V(3).Infof("Failed to GetMountProvider: %v", err)
return nil, err
}

nodeID, err := m.GetInstanceID()
if len(nodeID) > 0 {
return &csi.NodeGetIdResponse{
NodeId: nodeID,
}, nil
}

// Using default function
return ns.DefaultNodeServer.NodeGetId(ctx, req)
}

func (ns *nodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {

nodeID, err := getNodeID()
if err != nil {
glog.V(3).Infof("Failed to GetInstanceID: %v", err)
return nil, err
}

if len(nodeID) > 0 {
return &csi.NodeGetIdResponse{
return &csi.NodeGetInfoResponse{
NodeId: nodeID,
}, nil
}

// Using default function
return ns.DefaultNodeServer.NodeGetId(ctx, req)
return ns.DefaultNodeServer.NodeGetInfo(ctx, req)
}

func getNodeID() (string, error) {

// Get Mount Provider
m, err := mount.GetMountProvider()
if err != nil {
glog.V(3).Infof("Failed to GetMountProvider: %v", err)
return "", err
}

nodeID, err := m.GetInstanceID()
if err != nil {
glog.V(3).Infof("Failed to GetInstanceID: %v", err)
return "", err
}

return nodeID, nil
}

func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
Expand Down
30 changes: 30 additions & 0 deletions pkg/cinder/nodeserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,36 @@ func TestNodeGetId(t *testing.T) {
assert.Equal(expectedRes, actualRes)
}

// Test NodeGetInfo
func TestNodeGetInfo(t *testing.T) {

// mock MountMock
mmock := new(mount.MountMock)
// GetInstanceID() (string, error)
mmock.On("GetInstanceID").Return(fakeNodeID, nil)
mount.MInstance = mmock

// Init assert
assert := assert.New(t)

// Expected Result
expectedRes := &csi.NodeGetInfoResponse{
NodeId: fakeNodeID,
}

// Fake request
fakeReq := &csi.NodeGetInfoRequest{}

// Invoke NodeGetId
actualRes, err := fakeNs.NodeGetInfo(fakeCtx, fakeReq)
if err != nil {
t.Errorf("failed to NodeGetInfo: %v", err)
}

// Assert
assert.Equal(expectedRes, actualRes)
}

// Test NodePublishVolume
func TestNodePublishVolume(t *testing.T) {

Expand Down
12 changes: 12 additions & 0 deletions pkg/csi-common/controllerserver-default.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,15 @@ func (cs *DefaultControllerServer) ControllerGetCapabilities(ctx context.Context
Capabilities: cs.Driver.cap,
}, nil
}

func (cs *DefaultControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) {
return nil, status.Error(codes.Unimplemented, "")
}

func (cs *DefaultControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) {
return nil, status.Error(codes.Unimplemented, "")
}

func (cs *DefaultControllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error) {
return nil, status.Error(codes.Unimplemented, "")
}
2 changes: 1 addition & 1 deletion pkg/csi-common/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
)

var (
vendorVersion = "0.2.0"
vendorVersion = "0.3.0"
)

func NewFakeDriver() *CSIDriver {
Expand Down
8 changes: 8 additions & 0 deletions pkg/csi-common/nodeserver-default.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ func (ns *DefaultNodeServer) NodeGetId(ctx context.Context, req *csi.NodeGetIdRe
}, nil
}

func (ns *DefaultNodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {
glog.V(5).Infof("Using default NodeGetInfo")

return &csi.NodeGetInfoResponse{
NodeId: ns.Driver.nodeID,
}, nil
}

func (ns *DefaultNodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
glog.V(5).Infof("Using default NodeGetCapabilities")

Expand Down
12 changes: 12 additions & 0 deletions pkg/csi-common/nodeserver-default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ func TestNodeGetId(t *testing.T) {
assert.Equal(t, resp.GetNodeId(), fakeNodeID)
}

func TestNodeGetInfo(t *testing.T) {
d := NewFakeDriver()

ns := NewDefaultNodeServer(d)

// Test valid request
req := csi.NodeGetInfoRequest{}
resp, err := ns.NodeGetInfo(context.Background(), &req)
assert.NoError(t, err)
assert.Equal(t, resp.GetNodeId(), fakeNodeID)
}

func TestNodeGetCapabilities(t *testing.T) {
d := NewFakeDriver()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ spec:
serviceAccount: csi-attacher
containers:
- name: csi-attacher
image: docker.io/k8scsi/csi-attacher
image: quay.io/k8scsi/csi-attacher:v0.3.0
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
hostNetwork: true
containers:
- name: driver-registrar
image: docker.io/k8scsi/driver-registrar
image: quay.io/k8scsi/driver-registrar:v0.3.0
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
Expand Down
2 changes: 1 addition & 1 deletion pkg/flexadapter/flexadapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type flexAdapter struct {
}

var (
version = "0.2.0"
version = "0.3.0"
)

func New() *flexAdapter {
Expand Down
3 changes: 3 additions & 0 deletions pkg/hostpath/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ func (cs *controllerServer) ValidateVolumeCapabilities(ctx context.Context, req
if req.GetVolumeCapabilities() == nil {
return nil, status.Error(codes.InvalidArgument, "Volume capabilities missing in request")
}
if _, ok := hostPathVolumes[req.GetVolumeId()]; !ok {
return nil, status.Error(codes.NotFound, "Volume does not exist")
}

for _, cap := range req.VolumeCapabilities {
if cap.GetAccessMode().GetMode() != csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER {
Expand Down
2 changes: 1 addition & 1 deletion pkg/hostpath/hostpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var hostPathVolumes map[string]hostPathVolume

var (
hostPathDriver *hostPath
vendorVersion = "0.2.0"
vendorVersion = "0.3.0"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/iscsi/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (
)

var (
version = "0.2.0"
version = "0.3.0"
)

func NewDriver(nodeID, endpoint string) *driver {
Expand Down
4 changes: 2 additions & 2 deletions pkg/nfs/deploy/kubernetes/csi-attacher-nfsplugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
serviceAccount: csi-attacher
containers:
- name: csi-attacher
image: quay.io/k8scsi/csi-attacher:v0.2.0
image: quay.io/k8scsi/csi-attacher:v0.3.0
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
Expand All @@ -43,7 +43,7 @@ spec:
mountPath: /var/lib/csi/sockets/pluginproxy/

- name: nfs
image: quay.io/k8scsi/nfsplugin:v0.2.0
image: quay.io/k8scsi/nfsplugin:v0.3.0
args :
- "--nodeid=$(NODE_ID)"
- "--endpoint=$(CSI_ENDPOINT)"
Expand Down
4 changes: 2 additions & 2 deletions pkg/nfs/deploy/kubernetes/csi-nodeplugin-nfsplugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
hostNetwork: true
containers:
- name: driver-registrar
image: quay.io/k8scsi/driver-registrar:v0.2.0
image: quay.io/k8scsi/driver-registrar:v0.3.0
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
Expand All @@ -37,7 +37,7 @@ spec:
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
image: quay.io/k8scsi/nfsplugin:v0.2.0
image: quay.io/k8scsi/nfsplugin:v0.3.0
args :
- "--nodeid=$(NODE_ID)"
- "--endpoint=$(CSI_ENDPOINT)"
Expand Down
2 changes: 1 addition & 1 deletion pkg/nfs/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (
)

var (
version = "0.2.0"
version = "0.3.0"
)

func NewDriver(nodeID, endpoint string) *driver {
Expand Down

0 comments on commit d8f283c

Please sign in to comment.