mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 22:30:23 +00:00
Merge pull request #363 from humblec/merge-csiv1.0
Merge csi v1.0 to master
This commit is contained in:
commit
0a4b2b713a
1
Gopkg.lock
generated
1
Gopkg.lock
generated
@ -528,6 +528,7 @@
|
|||||||
"k8s.io/apimachinery/pkg/api/errors",
|
"k8s.io/apimachinery/pkg/api/errors",
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1",
|
"k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||||
"k8s.io/apimachinery/pkg/util/sets",
|
"k8s.io/apimachinery/pkg/util/sets",
|
||||||
|
"k8s.io/apimachinery/pkg/util/validation",
|
||||||
"k8s.io/apimachinery/pkg/util/wait",
|
"k8s.io/apimachinery/pkg/util/wait",
|
||||||
"k8s.io/client-go/kubernetes",
|
"k8s.io/client-go/kubernetes",
|
||||||
"k8s.io/client-go/rest",
|
"k8s.io/client-go/rest",
|
||||||
|
@ -4,7 +4,7 @@ appVersion: "1.0.0"
|
|||||||
description: "Container Storage Interface (CSI) driver,
|
description: "Container Storage Interface (CSI) driver,
|
||||||
provisioner, and attacher for Ceph cephfs"
|
provisioner, and attacher for Ceph cephfs"
|
||||||
name: ceph-csi-cephfs
|
name: ceph-csi-cephfs
|
||||||
version: 0.5.3
|
version: 0.6.0
|
||||||
keywords:
|
keywords:
|
||||||
- ceph
|
- ceph
|
||||||
- cephfs
|
- cephfs
|
||||||
|
@ -49,7 +49,7 @@ spec:
|
|||||||
valueFrom:
|
valueFrom:
|
||||||
fieldRef:
|
fieldRef:
|
||||||
fieldPath: spec.nodeName
|
fieldPath: spec.nodeName
|
||||||
imagePullPolicy: {{ .Values.nodeplugin.registrar.image.imagePullPolicy }}
|
imagePullPolicy: {{ .Values.nodeplugin.registrar.image.pullPolicy }}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: plugin-dir
|
- name: plugin-dir
|
||||||
mountPath: /csi
|
mountPath: /csi
|
||||||
@ -82,7 +82,7 @@ spec:
|
|||||||
fieldPath: spec.nodeName
|
fieldPath: spec.nodeName
|
||||||
- name: CSI_ENDPOINT
|
- name: CSI_ENDPOINT
|
||||||
value: "unix:/{{ .Values.socketDir }}/{{ .Values.socketFile }}"
|
value: "unix:/{{ .Values.socketDir }}/{{ .Values.socketFile }}"
|
||||||
imagePullPolicy: {{ .Values.nodeplugin.plugin.image.imagePullPolicy }}
|
imagePullPolicy: {{ .Values.nodeplugin.plugin.image.pullPolicy }}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: mount-cache-dir
|
- name: mount-cache-dir
|
||||||
mountPath: /mount-cache-dir
|
mountPath: /mount-cache-dir
|
||||||
|
@ -79,7 +79,7 @@ spec:
|
|||||||
fieldPath: spec.nodeName
|
fieldPath: spec.nodeName
|
||||||
- name: CSI_ENDPOINT
|
- name: CSI_ENDPOINT
|
||||||
value: "unix:/{{ .Values.socketDir }}/{{ .Values.socketFile }}"
|
value: "unix:/{{ .Values.socketDir }}/{{ .Values.socketFile }}"
|
||||||
imagePullPolicy: {{ .Values.nodeplugin.plugin.image.imagePullPolicy }}
|
imagePullPolicy: {{ .Values.nodeplugin.plugin.image.pullPolicy }}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
mountPath: {{ .Values.socketDir }}
|
mountPath: {{ .Values.socketDir }}
|
||||||
|
@ -4,7 +4,7 @@ appVersion: "1.0.0"
|
|||||||
description: "Container Storage Interface (CSI) driver,
|
description: "Container Storage Interface (CSI) driver,
|
||||||
provisioner, snapshotter, and attacher for Ceph RBD"
|
provisioner, snapshotter, and attacher for Ceph RBD"
|
||||||
name: ceph-csi-rbd
|
name: ceph-csi-rbd
|
||||||
version: 0.5.3
|
version: 0.6.0
|
||||||
keywords:
|
keywords:
|
||||||
- ceph
|
- ceph
|
||||||
- rbd
|
- rbd
|
||||||
|
@ -49,7 +49,7 @@ spec:
|
|||||||
valueFrom:
|
valueFrom:
|
||||||
fieldRef:
|
fieldRef:
|
||||||
fieldPath: spec.nodeName
|
fieldPath: spec.nodeName
|
||||||
imagePullPolicy: {{ .Values.nodeplugin.registrar.image.imagePullPolicy }}
|
imagePullPolicy: {{ .Values.nodeplugin.registrar.image.pullPolicy }}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: plugin-dir
|
- name: plugin-dir
|
||||||
mountPath: /csi
|
mountPath: /csi
|
||||||
@ -82,7 +82,7 @@ spec:
|
|||||||
fieldPath: spec.nodeName
|
fieldPath: spec.nodeName
|
||||||
- name: CSI_ENDPOINT
|
- name: CSI_ENDPOINT
|
||||||
value: "unix:/{{ .Values.socketDir }}/{{ .Values.socketFile }}"
|
value: "unix:/{{ .Values.socketDir }}/{{ .Values.socketFile }}"
|
||||||
imagePullPolicy: {{ .Values.nodeplugin.plugin.image.imagePullPolicy }}
|
imagePullPolicy: {{ .Values.nodeplugin.plugin.image.pullPolicy }}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: plugin-dir
|
- name: plugin-dir
|
||||||
mountPath: {{ .Values.socketDir }}
|
mountPath: {{ .Values.socketDir }}
|
||||||
|
@ -43,7 +43,7 @@ spec:
|
|||||||
{{ toYaml .Values.provisioner.resources | indent 12 }}
|
{{ toYaml .Values.provisioner.resources | indent 12 }}
|
||||||
- name: csi-snapshotter
|
- name: csi-snapshotter
|
||||||
image: {{ .Values.snapshotter.image.repository }}:{{ .Values.snapshotter.image.tag }}
|
image: {{ .Values.snapshotter.image.repository }}:{{ .Values.snapshotter.image.tag }}
|
||||||
imagePullPolicy: {{ .Values.nodeplugin.plugin.image.imagePullPolicy }}
|
imagePullPolicy: {{ .Values.nodeplugin.plugin.image.pullPolicy }}
|
||||||
args:
|
args:
|
||||||
- "--csi-address=$(ADDRESS)"
|
- "--csi-address=$(ADDRESS)"
|
||||||
- "--connection-timeout=15s"
|
- "--connection-timeout=15s"
|
||||||
@ -97,7 +97,7 @@ spec:
|
|||||||
fieldPath: spec.nodeName
|
fieldPath: spec.nodeName
|
||||||
- name: CSI_ENDPOINT
|
- name: CSI_ENDPOINT
|
||||||
value: "unix:/{{ .Values.socketDir }}/{{ .Values.socketFile }}"
|
value: "unix:/{{ .Values.socketDir }}/{{ .Values.socketFile }}"
|
||||||
imagePullPolicy: {{ .Values.nodeplugin.plugin.image.imagePullPolicy }}
|
imagePullPolicy: {{ .Values.nodeplugin.plugin.image.pullPolicy }}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
mountPath: {{ .Values.socketDir }}
|
mountPath: {{ .Values.socketDir }}
|
||||||
|
@ -50,8 +50,8 @@ type ControllerServer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
rbdVolumes = map[string]*rbdVolume{}
|
rbdVolumes = map[string]rbdVolume{}
|
||||||
rbdSnapshots = map[string]*rbdSnapshot{}
|
rbdSnapshots = map[string]rbdSnapshot{}
|
||||||
)
|
)
|
||||||
|
|
||||||
// LoadExDataFromMetadataStore loads the rbd volume and snapshot
|
// LoadExDataFromMetadataStore loads the rbd volume and snapshot
|
||||||
@ -60,14 +60,14 @@ func (cs *ControllerServer) LoadExDataFromMetadataStore() error {
|
|||||||
vol := &rbdVolume{}
|
vol := &rbdVolume{}
|
||||||
// nolint
|
// nolint
|
||||||
cs.MetadataStore.ForAll("csi-rbd-vol-", vol, func(identifier string) error {
|
cs.MetadataStore.ForAll("csi-rbd-vol-", vol, func(identifier string) error {
|
||||||
rbdVolumes[identifier] = vol
|
rbdVolumes[identifier] = *vol
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
snap := &rbdSnapshot{}
|
snap := &rbdSnapshot{}
|
||||||
// nolint
|
// nolint
|
||||||
cs.MetadataStore.ForAll("csi-rbd-(.*)-snap-", snap, func(identifier string) error {
|
cs.MetadataStore.ForAll("csi-rbd-(.*)-snap-", snap, func(identifier string) error {
|
||||||
rbdSnapshots[identifier] = snap
|
rbdSnapshots[identifier] = *snap
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
|||||||
// size in bytes)
|
// size in bytes)
|
||||||
rbdVol.VolSize = rbdVol.VolSize * util.MiB
|
rbdVol.VolSize = rbdVol.VolSize * util.MiB
|
||||||
|
|
||||||
rbdVolumes[rbdVol.VolID] = rbdVol
|
rbdVolumes[rbdVol.VolID] = *rbdVol
|
||||||
|
|
||||||
if err = storeVolumeMetadata(rbdVol, cs.MetadataStore); err != nil {
|
if err = storeVolumeMetadata(rbdVol, cs.MetadataStore); err != nil {
|
||||||
return nil, status.Error(codes.Internal, err.Error())
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
@ -434,7 +434,7 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
|
|||||||
|
|
||||||
rbdSnap.CreatedAt = ptypes.TimestampNow().GetSeconds()
|
rbdSnap.CreatedAt = ptypes.TimestampNow().GetSeconds()
|
||||||
|
|
||||||
rbdSnapshots[snapshotID] = rbdSnap
|
rbdSnapshots[snapshotID] = *rbdSnap
|
||||||
|
|
||||||
if err = storeSnapshotMetadata(rbdSnap, cs.MetadataStore); err != nil {
|
if err = storeSnapshotMetadata(rbdSnap, cs.MetadataStore); err != nil {
|
||||||
return nil, status.Error(codes.Internal, err.Error())
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
|
81
pkg/rbd/controllerserver_test.go
Normal file
81
pkg/rbd/controllerserver_test.go
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
package rbd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ceph/ceph-csi/pkg/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
type testCachePersister struct {
|
||||||
|
volumes map[string]rbdVolume
|
||||||
|
snapshots map[string]rbdSnapshot
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *testCachePersister) Create(identifier string, data interface{}) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *testCachePersister) Get(identifier string, data interface{}) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *testCachePersister) ForAll(pattern string, destObj interface{}, f util.ForAllFunc) error {
|
||||||
|
|
||||||
|
switch pattern {
|
||||||
|
case "csi-rbd-vol-":
|
||||||
|
for identifier, vol := range t.volumes {
|
||||||
|
*destObj.(*rbdVolume) = vol
|
||||||
|
if err := f(identifier); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "csi-rbd-(.*)-snap-":
|
||||||
|
for identifier, snap := range t.snapshots {
|
||||||
|
*destObj.(*rbdSnapshot) = snap
|
||||||
|
if err := f(identifier); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *testCachePersister) Delete(identifier string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLoadExDataFromMetadataStore(t *testing.T) {
|
||||||
|
cs := &ControllerServer{
|
||||||
|
MetadataStore: &testCachePersister{
|
||||||
|
volumes: map[string]rbdVolume{
|
||||||
|
"item1": {
|
||||||
|
VolID: "1",
|
||||||
|
},
|
||||||
|
"item2": {
|
||||||
|
VolID: "2",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
snapshots: map[string]rbdSnapshot{
|
||||||
|
"item1": {
|
||||||
|
SnapID: "1",
|
||||||
|
},
|
||||||
|
"item2": {
|
||||||
|
SnapID: "2",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := cs.LoadExDataFromMetadataStore(); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if rbdVolumes["item1"] == rbdVolumes["item2"] {
|
||||||
|
t.Error("rbd volume entries contain pointer to same volume")
|
||||||
|
}
|
||||||
|
|
||||||
|
if rbdSnapshots["item1"] == rbdSnapshots["item2"] {
|
||||||
|
t.Error("rbd snapshot entries contain pointer to same snapshot")
|
||||||
|
}
|
||||||
|
}
|
@ -400,7 +400,7 @@ func hasSnapshotFeature(imageFeatures string) bool {
|
|||||||
|
|
||||||
func getRBDVolumeByID(volumeID string) (*rbdVolume, error) {
|
func getRBDVolumeByID(volumeID string) (*rbdVolume, error) {
|
||||||
if rbdVol, ok := rbdVolumes[volumeID]; ok {
|
if rbdVol, ok := rbdVolumes[volumeID]; ok {
|
||||||
return rbdVol, nil
|
return &rbdVol, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("volume id %s does not exit in the volumes list", volumeID)
|
return nil, fmt.Errorf("volume id %s does not exit in the volumes list", volumeID)
|
||||||
}
|
}
|
||||||
@ -408,7 +408,8 @@ func getRBDVolumeByID(volumeID string) (*rbdVolume, error) {
|
|||||||
func getRBDVolumeByName(volName string) (*rbdVolume, error) {
|
func getRBDVolumeByName(volName string) (*rbdVolume, error) {
|
||||||
for _, rbdVol := range rbdVolumes {
|
for _, rbdVol := range rbdVolumes {
|
||||||
if rbdVol.VolName == volName {
|
if rbdVol.VolName == volName {
|
||||||
return rbdVol, nil
|
v := rbdVol
|
||||||
|
return &v, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("volume name %s does not exit in the volumes list", volName)
|
return nil, fmt.Errorf("volume name %s does not exit in the volumes list", volName)
|
||||||
@ -417,7 +418,8 @@ func getRBDVolumeByName(volName string) (*rbdVolume, error) {
|
|||||||
func getRBDSnapshotByName(snapName string) (*rbdSnapshot, error) {
|
func getRBDSnapshotByName(snapName string) (*rbdSnapshot, error) {
|
||||||
for _, rbdSnap := range rbdSnapshots {
|
for _, rbdSnap := range rbdSnapshots {
|
||||||
if rbdSnap.SnapName == snapName {
|
if rbdSnap.SnapName == snapName {
|
||||||
return rbdSnap, nil
|
s := rbdSnap
|
||||||
|
return &s, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("snapshot name %s does not exit in the snapshots list", snapName)
|
return nil, fmt.Errorf("snapshot name %s does not exit in the snapshots list", snapName)
|
||||||
@ -467,7 +469,7 @@ func protectSnapshot(pOpts *rbdSnapshot, adminID string, credentials map[string]
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractStoredVolOpt(r *rbdVolume) map[string]string {
|
func extractStoredVolOpt(r rbdVolume) map[string]string {
|
||||||
volOptions := make(map[string]string)
|
volOptions := make(map[string]string)
|
||||||
volOptions["pool"] = r.Pool
|
volOptions["pool"] = r.Pool
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user