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
Carry Fix docker inspect container only reports last assigned information #17393
Conversation
@@ -0,0 +1,28 @@ | |||
// Package v1p21 provides specific API types for the API version 1, patch 21. |
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 can remove this whole file 🔥 🤘
e2e8df4
to
02bd490
Compare
Code LGTM. Waiting to see what janky thinks about it. 👏 |
CI has issues, we need to run the tests locally |
return strings.Trim(out, " \r\n'") | ||
} | ||
|
||
func (d *Daemon) findContainerIP(id string) string { | ||
return findContainerIP(d.c, id, "--host", d.sock()) | ||
return findContainerIP(d.c, id, "--host") |
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.
@tiborvass Busy this day, get no time to read the notes from the github.
return findContainerIP(d.c, id, "--host")
should be return findContainerIP(d.c, id, "bridge")
Sorry for my mistake in my PR, don't know why CI got green on my PR
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.
Thanks so much for looking @coolljt0725, and no need to apologize (that's where reviews are for, we're all human!)
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.
@thaJeztah thanks
@tiborvass After investigating why return findContainerIP(d.c, id, "--host")
unexpectedly make CI green and found that we can't call findContainerIP
in func (d *Daemon) findContainerIP(id string)
because findContainerIP
connect to the daemon start by .integration-daemon-start
, we should connect the daemon d
here, so I think the correct fix here is
func (d *Daemon) findContainerIP(id string) string {
out, _ := d.Cmd("inspect", fmt.Sprintf("--format='{{ .NetworkSettings.Networks.bridge.IPAddress }}'"), id)
return strings.Trim(out, " \r\n'")
}
correct me if I'm wrong :-)
Though the original code findContainerIP(d.c, id, "--host", d.sock())
has set the "--host", d.sock()
but it never been used in func findContainerIP(c *check.C, id string, vargs ...string)
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.
diff --git a/integration-cli/docker_utils.go b/integration-cli/docker_utils.go
index 67627af..850ad2e 100644
--- a/integration-cli/docker_utils.go
+++ b/integration-cli/docker_utils.go
@@ -783,12 +783,19 @@ func dockerCmdInDirWithTimeout(timeout time.Duration, path string, args ...strin
}
func findContainerIP(c *check.C, id string, network string) string {
- out, _ := dockerCmd(c, "inspect", fmt.Sprintf("--format='{{ .NetworkSettings.Networks.%s.IPAddress }}'", network), id)
+ out, err := dockerCmd(c, "inspect", fmt.Sprintf("--format='{{ .NetworkSettings.Networks.%s.IPAddress }}'", network), id)
+ if err != nil {
+ c.Warn(err)
+ }
return strings.Trim(out, " \r\n'")
}
func (d *Daemon) findContainerIP(id string) string {
- return findContainerIP(d.c, id, "--host")
+ out, err := d.Cmd("inspect", fmt.Sprintf("--format='{{ .NetworkSettings.Networks.bridge.IPAddress }}'"), id)
+ if err != nil {
+ d.c.Warn(err)
+ }
+ return strings.TrimSpace(out)
}
func getContainerCount() (int, error) {
@calavera @coolljt0725 does this sound ok to you guys ?
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.
lgtm
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.
@tiborvass err
will be an int in findContainerIP
with 0
as value (or it will fail the test if an error occured — so the Warn
feels useless). You probably want to use out, _, err := dockerCmdWithError(…)
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.
that if err != nil (from dockerCmd) won't compile (cannot convert nil to type int) I think @vdemeester
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.
@runcom Yeah even that 😅 😝
02bd490
to
b26b813
Compare
@vdemeester @runcom @calavera @coolljt0725 fixed thank you |
@tiborvass it looks like
|
Signed-off-by: Lei Jitang <leijitang@huawei.com>
@tiborvass you need this patch: diff --git c/integration-cli/docker_utils.go i/integration-cli/docker_utils.go
index 8aea980..581766d 100644
--- c/integration-cli/docker_utils.go
+++ i/integration-cli/docker_utils.go
@@ -785,7 +785,7 @@ func dockerCmdInDirWithTimeout(timeout time.Duration, path string, args ...strin
func findContainerIP(c *check.C, id string, network string) string {
out, _, err := dockerCmdWithError(c, "inspect", fmt.Sprintf("--format='{{ .NetworkSettings.Networks.%s.IPAddress }}'", network), id)
if err != nil {
- c.Warn(err)
+ c.Log(err)
}
return strings.Trim(out, " \r\n'")
}
@@ -793,7 +793,7 @@ func findContainerIP(c *check.C, id string, network string) string {
func (d *Daemon) findContainerIP(id string) string {
out, err := d.Cmd("inspect", fmt.Sprintf("--format='{{ .NetworkSettings.Networks.bridge.IPAddress }}'"), id)
if err != nil {
- d.c.Warn(err)
+ d.c.Log(err)
}
return strings.TrimSpace(out)
} |
b26b813
to
e2907ba
Compare
@calavera yes thank you I noticed it while rebasing :) |
if err != nil { | ||
d.c.Log(err) | ||
} | ||
return strings.Trim(out, " \r\n'") |
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.
@calavera note that i just took what was at line 787
LGTM |
putting merge label, since it already got okays in the pr this is carrying. |
e2907ba
to
93d70c3
Compare
@@ -88,15 +88,25 @@ func (container *Container) setupLinkedContainers() ([]string, error) { | |||
return nil, err | |||
} | |||
|
|||
bridgeSettings := container.NetworkSettings.Networks["bridge"] | |||
if bridgeSettings == nil { | |||
return nil, nil |
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.
|
93d70c3
to
f87f09e
Compare
@calavera fixed |
f87f09e
to
426a6b4
Compare
changes LGTM. Let's wait for the CI to become green |
@mrjana CI has issues, please test locally |
Keeping backwards compatibility. Signed-off-by: David Calavera <david.calavera@gmail.com> Signed-off-by: Tibor Vass <tibor@docker.com>
426a6b4
to
2568257
Compare
LGTM. We're going to open a PR in docker-py to fix the functional suite. Merging. |
Carry Fix docker inspect container only reports last assigned information
@thaJeztah removing changelog, since it's part of the new networking feature which is already in the changelog. |
moby/moby#17393 changes the network settings struct a bit, which impacts tests checking values in inspect results Signed-off-by: Joffrey F <joffrey@docker.com>
Fixes #17352
Closes #17360
Ping @calavera