Created
November 29, 2017 19:55
-
-
Save lpabon/03f57d5eb1e5c1a551a7028d2815a08e to your computer and use it in GitHub Desktop.
Use CSI server on libopenstorage/openstorage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 74efc642b42a2b3217facc0b8bf98e6ed965fd66 Mon Sep 17 00:00:00 2001 | |
From: =?UTF-8?q?Luis=20Pab=C3=B3n?= <luis@portworx.com> | |
Date: Tue, 28 Nov 2017 18:03:12 -0500 | |
Subject: [PATCH] MAIN | |
--- | |
cmd/osd/main.go | 25 +++++++++++++++++++++++++ | |
csi/csi.go | 2 +- | |
etc/config/config.yaml | 2 +- | |
3 files changed, 27 insertions(+), 2 deletions(-) | |
diff --git a/cmd/osd/main.go b/cmd/osd/main.go | |
index 8662c19..8b494db 100644 | |
--- a/cmd/osd/main.go | |
+++ b/cmd/osd/main.go | |
@@ -17,6 +17,7 @@ import ( | |
osdcli "github.com/libopenstorage/openstorage/cli" | |
"github.com/libopenstorage/openstorage/cluster" | |
"github.com/libopenstorage/openstorage/config" | |
+ "github.com/libopenstorage/openstorage/csi" | |
"github.com/libopenstorage/openstorage/graph/drivers" | |
"github.com/libopenstorage/openstorage/volume" | |
"github.com/libopenstorage/openstorage/volume/drivers" | |
@@ -171,6 +172,8 @@ func start(c *cli.Context) error { | |
} | |
isDefaultSet := false | |
+ csiServers := make(map[string]csi.Server) | |
+ | |
// Start the volume drivers. | |
for d, v := range cfg.Osd.Drivers { | |
dlog.Infof("Starting volume driver: %v", d) | |
@@ -178,6 +181,28 @@ func start(c *cli.Context) error { | |
return fmt.Errorf("Unable to start volume driver: %v, %v", d, err) | |
} | |
+ // Start CSI server for driver | |
+ clusterInstance, err := cluster.Inst() | |
+ if err != nil { | |
+ return fmt.Errorf("Unable to get cluster instance: %v", err) | |
+ } | |
+ csiServer, err := csi.NewOsdCsiServer(&csi.OsdCsiServerConfig{ | |
+ Net: "tcp", | |
+ Address: "127.0.0.1:0", | |
+ DriverName: d, | |
+ DriverParams: v, | |
+ Cluster: clusterInstance, | |
+ }) | |
+ if err != nil { | |
+ return fmt.Errorf("Unable to create CSI server: %s", err.Error()) | |
+ } | |
+ err = csiServer.Start() | |
+ if err != nil { | |
+ return fmt.Errorf("Unable to start CSI server: %s", err.Error()) | |
+ } | |
+ csiServers[d] = csiServer | |
+ dlog.Infof("CSI server for driver %s on %s", d, csiServer.Address()) | |
+ | |
var mgmtPort, pluginPort uint64 | |
if port, ok := v[config.MgmtPortKey]; ok { | |
mgmtPort, err = strconv.ParseUint(port, 10, 16) | |
diff --git a/csi/csi.go b/csi/csi.go | |
index 4ff143b..fb9d9ed 100644 | |
--- a/csi/csi.go | |
+++ b/csi/csi.go | |
@@ -74,7 +74,7 @@ func NewOsdCsiServer(config *OsdCsiServerConfig) (Server, error) { | |
// Register driver name and initialize it using the parameters provided | |
err := volumedrivers.Register(config.DriverName, config.DriverParams) | |
- if err != nil { | |
+ if err != nil && err != volume.ErrExist { | |
return nil, fmt.Errorf("Unable to setup driver %s: %s", config.DriverName, err.Error()) | |
} | |
diff --git a/etc/config/config.yaml b/etc/config/config.yaml | |
index 38b7750..fbbc6d6 100644 | |
--- a/etc/config/config.yaml | |
+++ b/etc/config/config.yaml | |
@@ -10,7 +10,7 @@ osd: | |
# pluginPort: "2377" | |
nfs: | |
server: "127.0.0.1" | |
- path: "/nfs" | |
+ path: "/scratch" | |
# btrfs: | |
# home: "/var/lib/openstorage/btrfs" | |
# aws: | |
-- | |
2.13.6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
THIS IS ALL TEMPORARY UNTIL THE MAIN.GO OFFICIALLY STARTS THE SERVER
I then setup a terminal with the following:
configbuse.yaml looks like:
Then on another window, I use
csc
(installing by usinggo get github.com/thecodeteam/gocsi/csc
):