-
Notifications
You must be signed in to change notification settings - Fork 174
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
Avoid errors: ip conflict and ip address already in use #8445
Conversation
we should run a full CI see if this breaks some tests, thanks. |
6ec8b2e
to
4e6a4ab
Compare
@@ -161,6 +161,7 @@ func (s *Scope) reserveEndpointIP(e *Endpoint) error { | |||
e.ip = eip | |||
return nil | |||
} | |||
err = fmt.Errorf("No available IP address in current network %s", s.name) |
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.
What is the reason to throw a new error 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.
More friendly :)
@@ -1096,13 +1096,14 @@ func (c *ContainerBackend) containerStart(op trace.Operation, name string, hostC | |||
handle = bindRes.Payload.Handle | |||
endpoints = bindRes.Payload.Endpoints | |||
|
|||
// due to issue 8405, 7128 and 8052, we will not clear out assigned IP address besides container is removed |
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 unbind() happens during error, so we should keep the undo 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 assume here we have assigned an IP address here, so we do not release the IP address even though it is not started.
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 each exited container would keep an IP, should we inform users to reap exited containers to avoid ip exhausting?
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.
We inform users when there is no available ip, see line 164
@@ -1263,7 +1264,7 @@ func (c *ContainerBackend) containerStop(op trace.Operation, name string, second | |||
} | |||
|
|||
operation := func() error { | |||
return c.containerProxy.Stop(op, vc, name, seconds, true) | |||
return c.containerProxy.Stop(op, vc, name, seconds, 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.
What is logic from true -> false 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.
It is using to determine if we need to call unbindContainer.
a9180b8
to
2cf9a22
Compare
@@ -1412,6 +1412,71 @@ func (c *Context) deleteScope(s *Scope) { | |||
delete(c.scopes, s.Name()) | |||
} | |||
|
|||
func (c *Context) UpdateContainerNameInScope(h *exec.Handle) 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.
Please add some comments about this api
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.
Will do. thanks
// name | ||
c.containers[h.ExecConfig.Name] = con | ||
// aliases | ||
for k, v := range newAliases { |
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 c.removeAliases is invoked in line 1455, there is no need to check if con exists or not in the for loop?
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.
Done.
@@ -1412,6 +1412,71 @@ func (c *Context) deleteScope(s *Scope) { | |||
delete(c.scopes, s.Name()) | |||
} | |||
|
|||
func (c *Context) UpdateContainerNameInScope(h *exec.Handle) 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.
Per discussion, please remove stop/start containers in the rename test case.
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.
Sure, will do.
@@ -513,6 +516,7 @@ func (handler *ContainersHandlersImpl) RenameContainerHandler(params containers. | |||
} | |||
|
|||
h = h.Rename(op, params.Name) | |||
handler.netCtx.UpdateContainerNameInScope(h) |
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.
Are there any other cases to call this UpdateContainerNameInScope
function besides h.Rename
?
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.
No, this is a new method for rename ops.
If the container VM is operated from vSphere client, in some cases VIC will allocate duplicate IP address for cVMs. For example: when the first cVM is poweroff from VC, the assigned IP address will be released, but the guestinfo is still saving the assigned IP address for VC HA or migration functionality; the second cVM will be assigned the first cVM ip address, when the first cVM is powered on from VC, these two cVMs are using same IP address. Another related error scenario is the docker network inspect will not show container endpoint if cVM is powered on from vSphere.
2cf9a22
to
0d71696
Compare
If the container VM is operated from vSphere client, in some cases
VIC will allocate duplicate IP address for cVMs. For example: when
the first cVM is poweroff from VC, the assigned IP address will be
released, but the guestinfo is still saving the assigned IP address
for VC HA or migration functionality; the second cVM will be assigned
the first cVM ip address, when the first cVM is powered on from VC,
these two cVMs are using same IP address.
Another related error scenario is the docker network inspect will not
show container endpoint if cVM is powered on from vSphere.
[full ci]
Fixes #8405 #7128 #8052