-
Notifications
You must be signed in to change notification settings - Fork 949
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
bugfix: fix endpoints disappear when pouchd restart #1312
bugfix: fix endpoints disappear when pouchd restart #1312
Conversation
c83b458
to
d1ae621
Compare
Fix endpoints disappear when pouchd restart, restore network controller need keep endpoints that is using by the running containers, add the active sandboxes option to initialize network controller. Signed-off-by: Rudy Zhang <rudyflyzhang@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #1312 +/- ##
==========================================
- Coverage 17.38% 17.37% -0.01%
==========================================
Files 189 189
Lines 11772 11789 +17
==========================================
+ Hits 2046 2048 +2
- Misses 9578 9594 +16
+ Partials 148 147 -1
|
@@ -65,13 +65,32 @@ type NetworkManager struct { | |||
} | |||
|
|||
// NewNetworkManager creates a brand new network manager. | |||
func NewNetworkManager(cfg *config.Config, store *meta.Store) (*NetworkManager, error) { | |||
func NewNetworkManager(cfg *config.Config, store *meta.Store, ctrMgr ContainerMgr) (*NetworkManager, error) { |
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.
can we replace ctrMgr
to containerMgr
, because ctrMgr
may be a little confused.
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 both is ok, short name in function paramters
// Create a new controller instance | ||
cfg.NetworkConfg.MetaPath = path.Dir(store.BaseDir) | ||
cfg.NetworkConfg.ExecRoot = network.DefaultExecRoot | ||
|
||
initNetworkLog(cfg) | ||
|
||
// get active sandboxes | ||
ctrs, err := ctrMgr.List(context.Background(), |
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.
replace ctrs
to containers
?
logrus.Errorf("failed to new network manager, can not get container list") | ||
return nil, errors.Wrap(err, "failed to get container list") | ||
} | ||
cfg.NetworkConfg.ActiveSandboxes = make(map[string]interface{}) |
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.
do we need to store ActiveSandboxes
to disk ?
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.
don't need to store to disk
@@ -562,7 +585,7 @@ func endpointOptions(n libnetwork.Network, endpoint *types.Endpoint) ([]libnetwo | |||
return createOptions, nil | |||
} | |||
|
|||
func (nm *NetworkManager) sandboxOptions(endpoint *types.Endpoint) ([]libnetwork.SandboxOption, error) { | |||
func buildSandboxOptions(config network.Config, endpoint *types.Endpoint) ([]libnetwork.SandboxOption, error) { |
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 sandbox options should not depend on endpoint config. If we have many endpoints, it means we will lose some information?
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.
endpoint in pouchd is different from endpoint in libnetwork, next version I will change it to 'NetDevice'
LGTM |
Ⅰ. Describe what this PR did
Fix endpoints disappear when pouchd restart, restore network controller
need keep endpoints that is using by the running containers, add the
active sandboxes option to initialize network controller.
Ⅱ. Does this pull request fix one issue?
Ⅲ. Describe how you did it
Ⅳ. Describe how to verify it
The container's endpoint is exist when pouchd has restarted.
Ⅴ. Special notes for reviews
Signed-off-by: Rudy Zhang rudyflyzhang@gmail.com