vendor update for CSI 0.3.0

This commit is contained in:
gman
2018-07-18 16:47:22 +02:00
parent 6f484f92fc
commit 8ea659f0d5
6810 changed files with 438061 additions and 193861 deletions

View File

@ -40,7 +40,7 @@ $ sudo ./_output/cinderplugin --endpoint tcp://127.0.0.1:10000 --cloud-config /e
```
### Test using csc
Get ```csc``` tool from https://github.com/thecodeteam/gocsi/tree/master/csc
Get ```csc``` tool from https://github.com/rexray/gocsi/tree/master/csc
#### Get plugin info
```
@ -48,12 +48,6 @@ $ csc identity plugin-info --endpoint tcp://127.0.0.1:10000
"csi-cinderplugin" "0.1.0"
```
#### Get supported versions
```
$ csc identity supported-versions --endpoint tcp://127.0.0.1:10000
0.1.0
```
#### Create a volume
```
$ csc controller new --endpoint tcp://127.0.0.1:10000 CSIVolumeName

View File

@ -30,7 +30,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)"
@ -42,7 +42,7 @@ spec:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
- name: cinder
image: docker.io/k8scsi/cinderplugin
image: quay.io/k8scsi/cinderplugin
args :
- "--nodeid=$(NODE_ID)"
- "--endpoint=$(CSI_ENDPOINT)"
@ -53,13 +53,13 @@ spec:
fieldRef:
fieldPath: spec.nodeName
- name: CSI_ENDPOINT
value: unix://plugin/csi.sock
value: unix://csi/csi.sock
- name: CLOUD_CONFIG
value: /etc/config/cloud.conf
imagePullPolicy: "IfNotPresent"
volumeMounts:
- name: socket-dir
mountPath: /plugin
mountPath: /csi
- name: secret-cinderplugin
mountPath: /etc/config
readOnly: true

View File

@ -18,27 +18,27 @@ 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)"
env:
- name: ADDRESS
value: /plugin/csi.sock
value: /csi/csi.sock
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
volumeMounts:
- name: plugin-dir
mountPath: /plugin
- name: socket-dir
mountPath: /csi
- name: cinder
securityContext:
privileged: true
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
image: docker.io/k8scsi/cinderplugin
image: quay.io/k8scsi/cinderplugin
args :
- "--nodeid=$(NODE_ID)"
- "--endpoint=$(CSI_ENDPOINT)"
@ -49,13 +49,13 @@ spec:
fieldRef:
fieldPath: spec.nodeName
- name: CSI_ENDPOINT
value: unix://plugin/csi.sock
value: unix://csi/csi.sock
- name: CLOUD_CONFIG
value: /etc/config/cloud.conf
imagePullPolicy: "IfNotPresent"
volumeMounts:
- name: plugin-dir
mountPath: /plugin
- name: socket-dir
mountPath: /csi
- name: pods-mount-dir
mountPath: /var/lib/kubelet/pods
mountPropagation: "Bidirectional"
@ -69,7 +69,7 @@ spec:
mountPath: /etc/config
readOnly: true
volumes:
- name: plugin-dir
- name: socket-dir
hostPath:
path: /var/lib/kubelet/plugins/csi-cinderplugin
type: DirectoryOrCreate

View File

@ -30,7 +30,7 @@ spec:
serviceAccount: csi-provisioner
containers:
- name: csi-provisioner
image: docker.io/k8scsi/csi-provisioner
image: quay.io/k8scsi/csi-provisioner:v0.3.0
args:
- "--provisioner=csi-cinderplugin"
- "--csi-address=$(ADDRESS)"
@ -42,7 +42,7 @@ spec:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
- name: cinder
image: docker.io/k8scsi/cinderplugin
image: quay.io/k8scsi/cinderplugin
args :
- "--nodeid=$(NODE_ID)"
- "--endpoint=$(CSI_ENDPOINT)"
@ -53,13 +53,13 @@ spec:
fieldRef:
fieldPath: spec.nodeName
- name: CSI_ENDPOINT
value: unix://plugin/csi.sock
value: unix://csi/csi.sock
- name: CLOUD_CONFIG
value: /etc/config/cloud.conf
imagePullPolicy: "IfNotPresent"
volumeMounts:
- name: socket-dir
mountPath: /plugin
mountPath: /csi
- name: secret-cinderplugin
mountPath: /etc/config
readOnly: true

View File

@ -42,7 +42,7 @@ const (
)
var (
version = "0.2.0"
version = "0.3.0"
)
func NewDriver(nodeID, endpoint string, cloudconfig string) *driver {

View File

@ -33,16 +33,8 @@ 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 err != nil {
glog.V(3).Infof("Failed to GetInstanceID: %v", err)
return nil, err
}
@ -56,6 +48,41 @@ func (ns *nodeServer) NodeGetId(ctx context.Context, req *csi.NodeGetIdRequest)
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 {
return nil, err
}
if len(nodeID) > 0 {
return &csi.NodeGetInfoResponse{
NodeId: nodeID,
}, nil
}
// Using default function
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) {
targetPath := req.GetTargetPath()

View File

@ -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) {