Skip to content
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

Merged
merged 21 commits into from
Feb 6, 2017

Conversation

Jacobingalls
Copy link
Collaborator

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:

./run.sh -db=mysql -dbpass=mypassword -dbschema=rdma_volumes

This starts the plugin with mysql, counting to localhost with root user, mypassword as the password, and the schema as rdma_volumes.

@@ -91,3 +91,4 @@ $RECYCLE.BIN/
# End of https://www.gitignore.io/api/macos,windows,linux

.idea
*.db
Copy link
Member

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 😉

Copy link
Collaborator Author

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.

Copy link
Member

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

Copy link
Collaborator Author

@Jacobingalls Jacobingalls Feb 6, 2017

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))
Copy link
Member

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.

Copy link
Collaborator Author

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
Copy link
Member

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -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 {
Copy link
Member

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.

Copy link
Collaborator Author

@Jacobingalls Jacobingalls Feb 6, 2017

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()
Copy link
Member

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.

Copy link
Collaborator Author

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()
Copy link
Member

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.

Copy link
Collaborator Author

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()
Copy link
Member

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.

Copy link
Collaborator Author

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)
Copy link
Member

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)
Copy link
Member

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.

Copy link
Collaborator Author

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)
Copy link
Member

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #13

@Jacobingalls Jacobingalls merged commit 45a16d3 into develop Feb 6, 2017
@JohnStarich JohnStarich deleted the feature/db branch February 6, 2017 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants