-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create mechanism for plugin to store and share state with other plugins in the same cluster. #3
Conversation
…ved and never mounted
68aac6c
to
fb9c7eb
Compare
fb9c7eb
to
8c5f903
Compare
…-volume-rdma into HEAD
1006f71
to
9b56bbb
Compare
9b56bbb
to
ea71ff1
Compare
@@ -91,3 +91,4 @@ $RECYCLE.BIN/ | |||
# End of https://www.gitignore.io/api/macos,windows,linux | |||
|
|||
.idea | |||
*.db |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For shame on missing the newline 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't know what you are talking about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click on the file name to see it. Looks like the review comment hid the red mark
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
db/inmemory.go
Outdated
|
||
// List all of the volumes in the database, returning an error if one occured. | ||
func (i InMemoryVolumeDatabase) List() ([]*volume.Volume, error) { | ||
l := make([]*volume.Volume, 0, len(i.volumes)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short variable names hinder the reader's ability to understand this code. Please lengthen them for all our sakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
db/mysql.go
Outdated
glog.Fatal("A database schema must be specified with -dbschema") | ||
} | ||
connection += "/" + schema | ||
printedConnection += "/" + schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use path.Join
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
drivers/driver.go
Outdated
@@ -36,8 +25,8 @@ type RDMAStorageController interface { | |||
} | |||
|
|||
// NewRDMAVolumeDriver constructs a new RDMAVolumeDriver. | |||
func NewRDMAVolumeDriver(sc RDMAStorageController) RDMAVolumeDriver { | |||
return RDMAVolumeDriver{sc} | |||
func NewRDMAVolumeDriver(sc RDMAStorageController, vd db.VolumeDatabase) RDMAVolumeDriver { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short variable names hinder the reader's ability to understand this code. Please lengthen them for all our sakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is clear.
db/sqldb.go
Outdated
} | ||
|
||
// Begin transaction to the database | ||
tx, err := sqlDB.Begin() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short variable names hinder the reader's ability to understand this code. Please lengthen them for all our sakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in later commit.
main.go
Outdated
|
||
// Create and begin serving volume driver on tcp/ip port, httpPort. | ||
vd, dberr := GetDatabaseConnection() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short variable names hinder the reader's ability to understand this code. Please lengthen them for all our sakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in later commit.
main.go
Outdated
glog.Fatal(dberr) | ||
} | ||
|
||
// Configure Storage Controller | ||
sc := drivers.NewGlusterStorageController() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short variable names hinder the reader's ability to understand this code. Please lengthen them for all our sakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in later commit.
main.go
Outdated
defer driver.Disconnect() | ||
|
||
// Handle SIGINT gracefully | ||
c := make(chan os.Signal, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short variable names hinder the reader's ability to understand this code. Please lengthen them for all our sakes.
main.go
Outdated
os.Exit(1) | ||
}() | ||
|
||
glog.Info("Running! http://localhost:" + port) | ||
h := volume.NewHandler(driver) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short variable names hinder the reader's ability to understand this code. Please lengthen them for all our sakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in later commit.
main.go
Outdated
func GetDatabaseConnection() (db.VolumeDatabase, error) { | ||
switch volumeDatabaseDriver { | ||
case "in-memory": | ||
validateDatabaseFlags(true, true, false, false, false, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some brief searching I found this: https://groups.google.com/forum/#!topic/golang-nuts/oWeeqCJfRzk
They basically made a config struct and passed the struct after initialization around. Performance-wise this would be identical, but reading-wise it would be far more obvious what's going on. Let's do that instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #13
…er-volume-rdma into feature/db
…-volume-rdma into feature/db
Adds the ability to store volumes via drivers. There are several included drivers
Drivers:
in-memory
: For testing purposes, keeps the entire state in memory. Completely ephemeral.sqlite
: Stores the state of the plugin in a local database file, this could be shared between plugins via nfs or gluster fs.mysql
: Store the state in a remote mysql server, this guarantees consistency but requires an additional service/container/server to maintain.The default is
sqlite
and can be changed with-db
Example: