Skip to content

Commit c38319e

Browse files
authored
Merge pull request #230 from opensds/development
Merge development into master branch for publishing Capri RC-01
2 parents 83e089f + 5ce07d7 commit c38319e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3939
-1593
lines changed

Gopkg.lock

+4-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
[[constraint]]
4545
name = "github.com/opensds/opensds"
46-
version = "0.5.2"
46+
version = "0.5.3"
4747

4848
[[constraint]]
4949
name = "github.com/pmorie/go-open-service-broker-client"

client/opensds/helper.go

+1-35
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,15 @@ package opensds
22

33
import (
44
"log"
5-
"os"
65

76
"github.com/opensds/opensds/client"
87
"github.com/opensds/opensds/pkg/utils/constants"
98
)
109

11-
const (
12-
13-
// OpenSDSEndPoint environment variable name
14-
OpenSDSEndPoint = "OPENSDS_ENDPOINT"
15-
16-
// OpenSDSAuthStrategy environment variable name
17-
OpenSDSAuthStrategy = "OPENSDS_AUTH_STRATEGY"
18-
19-
// Noauth
20-
Noauth = "noauth"
21-
)
22-
2310
// GetClient return OpenSDS Client
2411
func GetClient(endpoint string, authStrategy string) (*client.Client, error) {
25-
if endpoint == "" {
26-
// Get endpoint from environment
27-
endpoint = os.Getenv(OpenSDSEndPoint)
28-
log.Printf("current OpenSDS Client endpoint: %s", endpoint)
29-
}
3012

31-
if endpoint == "" {
32-
// Using default endpoint
33-
endpoint = constants.DefaultOpensdsEndpoint
34-
log.Printf("using default OpenSDS Client endpoint: %s", endpoint)
35-
}
36-
37-
if authStrategy == "" {
38-
// Get auth strategy from environment
39-
authStrategy = os.Getenv(OpenSDSAuthStrategy)
40-
log.Printf("current OpenSDS Client auth strategy: %s", authStrategy)
41-
}
42-
43-
if authStrategy == "" {
44-
// Using default auth strategy
45-
authStrategy = Noauth
46-
log.Printf("using default OpenSDS Client auth strategy: %s", authStrategy)
47-
}
13+
log.Printf("current OpenSDS client endpoint: %s, auth strategy: %s ", endpoint, authStrategy)
4814

4915
cfg := &client.Config{Endpoint: endpoint}
5016

csi/server/.gitignore

-3
This file was deleted.

csi/server/deploy/kubernetes/csi-attacher-opensdsplugin.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ spec:
3333
serviceAccount: csi-attacher
3434
containers:
3535
- name: csi-attacher
36-
image: quay.io/k8scsi/csi-attacher:v1.0.1
36+
image: quay.io/k8scsi/csi-attacher:v1.1.1
3737
args:
3838
- "--v=5"
3939
- "--csi-address=$(ADDRESS)"
@@ -64,7 +64,7 @@ spec:
6464
- "--csiEndpoint=$(CSI_ENDPOINT)"
6565
- "--opensdsEndpoint=$(OPENSDS_ENDPOINT)"
6666
- "--opensdsAuthStrategy=$(OPENSDS_AUTH_STRATEGY)"
67-
- "-v8"
67+
- "--v=8"
6868
env:
6969
- name: CSI_ENDPOINT
7070
value: unix://csi/csi.sock

csi/server/deploy/kubernetes/csi-nodeplugin-opensdsplugin.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ spec:
2121
hostNetwork: true
2222
containers:
2323
- name: node-driver-registrar
24-
image: quay.io/k8scsi/csi-node-driver-registrar:v1.0.1
24+
image: quay.io/k8scsi/csi-node-driver-registrar:v1.1.0
2525
args:
2626
- "--v=5"
2727
- "--csi-address=/csi/csi.sock"
@@ -50,7 +50,7 @@ spec:
5050
- "--csiEndpoint=$(CSI_ENDPOINT)"
5151
- "--opensdsEndpoint=$(OPENSDS_ENDPOINT)"
5252
- "--opensdsAuthStrategy=$(OPENSDS_AUTH_STRATEGY)"
53-
- "-v8"
53+
- "--v=8"
5454
env:
5555
- name: CSI_ENDPOINT
5656
value: unix://var/lib/kubelet/plugins/csi-opensdsplugin/csi.sock

csi/server/deploy/kubernetes/csi-provisioner-opensdsplugin.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ spec:
3333
serviceAccount: csi-provisioner
3434
containers:
3535
- name: csi-provisioner
36-
image: quay.io/k8scsi/csi-provisioner:v1.0.1
36+
image: quay.io/k8scsi/csi-provisioner:v1.1.0
3737
args:
3838
- "--provisioner=csi-opensdsplugin"
3939
- "--csi-address=$(ADDRESS)"
4040
- "--connection-timeout=15s"
41+
- "--feature-gates=Topology=True"
4142
env:
4243
- name: ADDRESS
4344
value: /csi/csi.sock
@@ -51,7 +52,7 @@ spec:
5152
- "--csiEndpoint=$(CSI_ENDPOINT)"
5253
- "--opensdsEndpoint=$(OPENSDS_ENDPOINT)"
5354
- "--opensdsAuthStrategy=$(OPENSDS_AUTH_STRATEGY)"
54-
- "-v8"
55+
- "--v=8"
5556
env:
5657
- name: CSI_ENDPOINT
5758
value: unix://csi/csi.sock

csi/server/deploy/kubernetes/csi-provisioner-rbac.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ rules:
1515
- apiGroups: [""]
1616
resources: ["secrets"]
1717
verbs: ["get", "list"]
18+
- apiGroups: [""]
19+
resources: ["nodes"]
20+
verbs: ["get", "list", "watch"]
1821
- apiGroups: [""]
1922
resources: ["persistentvolumes"]
2023
verbs: ["get", "list", "watch", "create", "delete"]
2124
- apiGroups: [""]
2225
resources: ["persistentvolumeclaims"]
2326
verbs: ["get", "list", "watch", "update"]
2427
- apiGroups: ["storage.k8s.io"]
25-
resources: ["storageclasses"]
28+
resources: ["storageclasses", "csinodes"]
2629
verbs: ["get", "list", "watch"]
2730
- apiGroups: [""]
2831
resources: ["events"]

csi/server/deploy/kubernetes/csi-snapshotter-opensdsplugin.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ spec:
3333
serviceAccount: csi-snapshotter
3434
containers:
3535
- name: csi-snapshotter
36-
image: quay.io/k8scsi/csi-snapshotter:v1.0.1
36+
image: quay.io/k8scsi/csi-snapshotter:v1.1.0
3737
args:
3838
- "--snapshotter=csi-opensdsplugin"
3939
- "--csi-address=$(ADDRESS)"
@@ -51,7 +51,7 @@ spec:
5151
- "--csiEndpoint=$(CSI_ENDPOINT)"
5252
- "--opensdsEndpoint=$(OPENSDS_ENDPOINT)"
5353
- "--opensdsAuthStrategy=$(OPENSDS_AUTH_STRATEGY)"
54-
- "-v8"
54+
- "--v=8"
5555
env:
5656
- name: CSI_ENDPOINT
5757
value: unix://csi/csi.sock
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This YAML file contains nginx & csi opensds driver objects,
2+
# which are necessary to run nginx with csi opensds driver.
3+
4+
apiVersion: v1
5+
kind: Pod
6+
metadata:
7+
name: nginx
8+
spec:
9+
containers:
10+
- image: nginx
11+
imagePullPolicy: IfNotPresent
12+
name: nginx
13+
ports:
14+
- containerPort: 80
15+
protocol: TCP
16+
volumeMounts:
17+
- mountPath: /var/lib/www/html
18+
name: csi-data-opensdsplugin
19+
volumes:
20+
- name: csi-data-opensdsplugin
21+
persistentVolumeClaim:
22+
claimName: opensdspvc
23+
readOnly: false

csi/server/examples/kubernetes/CreateVolumefromSnapshot/pvc_sc.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
apiVersion: storage.k8s.io/v1
55
kind: StorageClass
66
metadata:
7-
name: csi-sc-opensdsplugin-1
7+
name: nginx-sc
88
provisioner: csi-opensdsplugin
99
parameters:
1010
fsType: ext4
11+
profile:
12+
1113
---
1214
apiVersion: v1
1315
kind: PersistentVolumeClaim
@@ -19,4 +21,4 @@ spec:
1921
resources:
2022
requests:
2123
storage: 1Gi
22-
storageClassName: csi-sc-opensdsplugin-1
24+
storageClassName: nginx-sc

csi/server/examples/kubernetes/CreateVolumefromSnapshot/restore.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: PersistentVolumeClaim
33
metadata:
44
name: opensds-pvc-restore
55
spec:
6-
storageClassName: csi-sc-opensdsplugin-1
6+
storageClassName: nginx-sc
77
dataSource:
88
name: new-snapshot-demo
99
kind: VolumeSnapshot

csi/server/examples/kubernetes/CreateVolumefromSnapshot/nginx_1.yaml csi/server/examples/kubernetes/CreateVolumefromSnapshot/restored-nginx.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
apiVersion: v1
55
kind: Pod
66
metadata:
7-
name: nginx-1
7+
name: restored-nginx
88
spec:
99
containers:
1010
- image: nginx

csi/server/examples/kubernetes/CreateVolumefromSnapshot/snapshotclass.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ kind: VolumeSnapshotClass
33
metadata:
44
name: csi-opensds-snapclass
55
snapshotter: csi-opensdsplugin
6+
parameters:
7+
profile:
8+

csi/server/examples/kubernetes/nginx.yaml

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ metadata:
77
name: csi-sc-opensdsplugin
88
provisioner: csi-opensdsplugin
99
parameters:
10-
fsType: ext4
1110
attachMode: rw
12-
profile:
11+
profile: abc
12+
storageType: block
13+
allowedTopologies:
14+
- matchLabelExpressions:
15+
- key: topology.csi-opensdsplugin/zone
16+
values:
17+
- default
1318
---
1419
apiVersion: v1
1520
kind: PersistentVolumeClaim

csi/server/examples/kubernetes/pod-with-block-volume.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ metadata:
44
name: csi-sc-opensdsplugin-block
55
provisioner: csi-opensdsplugin
66
parameters:
7-
7+
profile: abc
8+
storageType: block
89
---
910
apiVersion: v1
1011
kind: PersistentVolumeClaim

csi/server/main.go

+21-54
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ import (
2222

2323
csi "github.com/container-storage-interface/spec/lib/go/csi"
2424
"github.com/golang/glog"
25-
"github.com/opensds/nbp/csi/server/plugin"
26-
"github.com/opensds/nbp/csi/server/plugin/opensds"
25+
plugin "github.com/opensds/nbp/csi/server/plugin/opensds"
2726
"github.com/opensds/nbp/csi/util"
28-
"github.com/spf13/cobra"
2927
"google.golang.org/grpc"
3028
"google.golang.org/grpc/reflection"
3129

@@ -34,76 +32,45 @@ import (
3432
_ "github.com/opensds/opensds/contrib/connector/rbd"
3533
)
3634

37-
var (
38-
csiEndpoint string
39-
opensdsEndpoint string
40-
opensdsAuthStrategy string
41-
)
42-
43-
func init() {
44-
flag.Set("alsologtostderr", "true")
45-
}
46-
4735
func main() {
48-
49-
flag.CommandLine.Parse([]string{})
36+
flag.Set("alsologtostderr", "true")
5037
// Open OpenSDS dock service log file.
5138
util.InitLogs()
5239
defer util.FlushLogs()
5340

54-
cmd := &cobra.Command{
55-
Use: "OpenSDS",
56-
Short: "CSI based OpenSDS driver",
57-
Run: func(cmd *cobra.Command, args []string) {
58-
handle()
59-
},
60-
}
41+
var csiEndpoint, opensdsEndpoint, opensdsAuthStrategy string
42+
// CSI endpoint
43+
flag.StringVar(&csiEndpoint, "csiEndpoint", util.CSIDefaultEndpoint, "CSI Endpoint")
6144

62-
// the endpoint variable priority is flag, ENV and default.
63-
cmd.Flags().AddGoFlagSet(flag.CommandLine)
45+
// opensds endpoint
46+
flag.StringVar(&opensdsEndpoint, "opensdsEndpoint", util.OpensdsDefaultEndpoint, "OpenSDS Endpoint")
6447

65-
csiEp := util.CSIDefaultEndpoint
66-
opensdsEp := util.OpensdsDefaultEndpoint
67-
if ep, ok := os.LookupEnv(util.CSIEndpoint); ok {
68-
csiEp = ep
69-
}
70-
if ep, ok := os.LookupEnv(util.OpensdsEndpoint); ok {
71-
opensdsEp = ep
72-
}
73-
cmd.PersistentFlags().StringVar(&csiEndpoint, "csiEndpoint", csiEp, "CSI Endpoint")
74-
cmd.PersistentFlags().StringVar(&opensdsEndpoint, "opensdsEndpoint", opensdsEp, "OpenSDS Endpoint")
75-
cmd.PersistentFlags().StringVar(&opensdsAuthStrategy, "opensdsAuthStrategy", "", "OpenSDS Auth Strategy")
48+
// opensds auth strategy
49+
flag.StringVar(&opensdsAuthStrategy, "opensdsAuthStrategy", util.OpensdsDefaultAuthStrategy, "OpenSDS Auth Strategy")
7650

77-
cmd.ParseFlags(os.Args[1:])
78-
if err := cmd.Execute(); err != nil {
79-
glog.Errorf("failed to execute: %v", err)
80-
os.Exit(1)
81-
}
82-
83-
os.Exit(0)
84-
}
85-
86-
func handle() {
87-
88-
// Set Env
89-
os.Setenv(util.OpensdsEndpoint, opensdsEndpoint)
90-
os.Setenv(util.OpensdsAuthStrategy, opensdsAuthStrategy)
51+
flag.Parse()
9152

9253
// Get CSI Endpoint Listener
9354
lis, err := util.GetCSIEndPointListener(csiEndpoint)
9455
if err != nil {
9556
glog.Errorf("failed to listen: %v", err)
57+
os.Exit(1)
58+
}
59+
60+
// Initialize the driver
61+
pluginServer, err := plugin.NewServer(opensdsEndpoint, opensdsAuthStrategy)
62+
if err != nil {
63+
glog.Errorf("failed to initialize the driver: %v", err)
64+
os.Exit(1)
9665
}
9766

9867
// New Grpc Server
9968
s := grpc.NewServer()
10069

10170
// Register CSI Service
102-
var defaultplugin plugin.Service = &opensds.Plugin{}
103-
conServer := &server{plugin: defaultplugin}
104-
csi.RegisterIdentityServer(s, conServer)
105-
csi.RegisterControllerServer(s, conServer)
106-
csi.RegisterNodeServer(s, conServer)
71+
csi.RegisterIdentityServer(s, pluginServer)
72+
csi.RegisterControllerServer(s, pluginServer)
73+
csi.RegisterNodeServer(s, pluginServer)
10774

10875
// Register reflection Service
10976
reflection.Register(s)

0 commit comments

Comments
 (0)