-
Notifications
You must be signed in to change notification settings - Fork 881
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
Add local datastore to persist states of LocalScope network #466
Conversation
Depending on godep updates of libkv. |
@chenchun thanks for your fast response. The CI failure is expected since the corresponding boltdb changes have not made into libkv project. FYI, this needs a Godep update. which we can update once docker/libkv#46 is merged |
@@ -68,6 +68,7 @@ install-deps: | |||
go get github.com/tools/godep | |||
go get github.com/golang/lint/golint | |||
go get github.com/mattn/goveralls | |||
go get github.com/boltdb/bolt |
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.
This should ideally go into godep.
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.
Yes, once bolt gets merged into libkv project, I'll update.
@chenchun You added all the etcd log files, make sure to exclude the |
Needs a vendoring of |
@abronan Thanks, updated and removed them. |
This will replace #439 |
Datastore DatastoreCfg | ||
Daemon DaemonCfg | ||
Cluster ClusterCfg | ||
Datastore, LocalDataStore DatastoreCfg |
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.
Shall we call these GlobalStore and LocalStore ?
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.
Addressed this
Also contains the following change: |
if err := c.initLocalStore(); err != nil { | ||
// Failing to initalize datastore is a bad situation to be in. | ||
// But it cannot fail creating the Controller | ||
log.Debugf("Failed to Initialize LocalDatastore due to %v.", err) |
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.
Since we added default configurations for local store, shall we return err here?
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 so.
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.
Addressed this.
@chenchun thanks for addressing all the comments. its shaping up nicely. I just gave a few more comments. Could you please address them ? |
@mavenugo, I'll update the PR soon. |
@mavenugo, just updated the PR. It's quite later today, if you have more comments, I'll take a look 8 hours later. |
if err != nil || !global { | ||
func (c *controller) newNetworkFromStore(n *network) error { | ||
// Check if a network already exists with the specified network name | ||
c.Lock() |
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 remove the c.Lock() and Unlock() in this method. It causes deadlock :(
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. And tested against docker, seems ok now.
I agree it tries to do too many things. I think we can split the last commit and focus on introducing localstore. But these should be a way to handle https://github.com/docker/libnetwork/blob/master/drivers/bridge/bridge.go#L887 |
thanks @chenchun. I noticed that you have reverted the bridge driver changes that I reported. Is that expected ? Without the changes to the bridge driver, wouldnt restore fail as I indicated earlier ? |
@chenchun based on our discussion, i agree that the bridge driver changes aren't required & also the daemon restart is going to cleanup the endpoint anyways. |
Correct me if I'm wrong. I think daemon restarts won't delete endpoints currently because daemon only keeps SandboxID/EndpointID now and when daemon is killed manually, daemon won't be able to delete veth devices. So I think it's better to keep endpoints and deletes them upon restart. |
@chenchun you are right. But, we have other ideas to clean up the stale endpoints. Another reason to keep the endpoints deletion away from this PR is to reduce the complexity and get this in ASAP. |
case "local": | ||
c.Scope = driverapi.LocalScope | ||
c.DataScope = datastore.LocalScope |
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.
Thats a very quick rebase :-).
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.
Unfortunately forget to refactor tests during rebase.
LGTM |
@chenchun as we discussed, we were trying to simplify this logic by removing my commit from this PR. With the introduction of #547, we can actually do that ... 🎆 Shall I request you to submit the PR again (with a rebase) and remove my commit (https://github.com/chenchun/libnetwork/commit/652d319c33bef98e58f1223b6f47d25a609f1291) from this PR ? BTW I attempted this change in : https://github.com/mavenugo/libnetwork/commits/defnet_save. Please use it if you find it useful. (You can ignore my last commit that introduces This ofcourse needs changes in the docker daemon to call controller.New with driver init params. Which we will take care during vendoring in. |
OK, will update the PR shortly. |
Signed-off-by: Chun Chen <ramichen@tencent.com>
Signed-off-by: Chun Chen <ramichen@tencent.com>
Thanks @chenchun pls let me know if you need any help. |
@mavenugo, some problems with unit tests now. Since we changed many unit tests to pass configs to |
@chenchun. Can't we use config Params to point to different Boltdb file for each of the different controllers to make use of ? |
Yes, doing it right now. |
1. Don't save localscope endpoints to localstore for now. 2. Add common function updateToStore/deleteFromStore to store KVObjects. 3. Merge `getNetworksFromGlobalStore` and `getNetworksFromLocalStore` 4. Add `n.isGlobalScoped` before `n.watchEndpoints` in `addNetwork` 5. Fix integration-tests 6. Fix test failure in drivers/remote/driver_test.go 7. Restore network to store if deleteNework failed
@mavenugo updated now. Will test it against docker tomorrow. |
if err == datastore.ErrKeyModified { | ||
return types.InternalErrorf("operation in progress. delete failed for network %s. Please try again.") | ||
} | ||
return err | ||
} | ||
|
||
defer func() { |
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.
Add a defer here to restore network.
@chenchun thanks for your patience and handling all the comments. Will merge this PR. |
Add local datastore to persist states of LocalScope network
👍 , Happy to see it finally gets merged. I apologize if I slow down your work during the process of this PR. Thanks for your patient review and help too. |
Signed-off-by: Chun Chen ramichen@tencent.com
Fixes #461