mirror of https://github.com/containers/podman.git
Show network name network events with podman -remote events
Fixes: https://github.com/containers/podman/issues/21311 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
22b1650619
commit
c7910e75e3
|
@ -31,16 +31,20 @@ func ConvertToLibpodEvent(e Event) *libpodEvents.Event {
|
||||||
}
|
}
|
||||||
image := e.Actor.Attributes["image"]
|
image := e.Actor.Attributes["image"]
|
||||||
name := e.Actor.Attributes["name"]
|
name := e.Actor.Attributes["name"]
|
||||||
details := e.Actor.Attributes
|
network := e.Actor.Attributes["network"]
|
||||||
podID := e.Actor.Attributes["podId"]
|
podID := e.Actor.Attributes["podId"]
|
||||||
|
details := e.Actor.Attributes
|
||||||
delete(details, "image")
|
delete(details, "image")
|
||||||
delete(details, "name")
|
delete(details, "name")
|
||||||
|
delete(details, "network")
|
||||||
|
delete(details, "podId")
|
||||||
delete(details, "containerExitCode")
|
delete(details, "containerExitCode")
|
||||||
return &libpodEvents.Event{
|
return &libpodEvents.Event{
|
||||||
ContainerExitCode: &exitCode,
|
ContainerExitCode: &exitCode,
|
||||||
ID: e.Actor.ID,
|
ID: e.Actor.ID,
|
||||||
Image: image,
|
Image: image,
|
||||||
Name: name,
|
Name: name,
|
||||||
|
Network: network,
|
||||||
Status: status,
|
Status: status,
|
||||||
Time: time.Unix(0, e.TimeNano),
|
Time: time.Unix(0, e.TimeNano),
|
||||||
Type: t,
|
Type: t,
|
||||||
|
@ -64,6 +68,9 @@ func ConvertToEntitiesEvent(e libpodEvents.Event) *types.Event {
|
||||||
attributes["containerExitCode"] = strconv.Itoa(*e.ContainerExitCode)
|
attributes["containerExitCode"] = strconv.Itoa(*e.ContainerExitCode)
|
||||||
}
|
}
|
||||||
attributes["podId"] = e.PodID
|
attributes["podId"] = e.PodID
|
||||||
|
if e.Network != "" {
|
||||||
|
attributes["network"] = e.Network
|
||||||
|
}
|
||||||
message := dockerEvents.Message{
|
message := dockerEvents.Message{
|
||||||
// Compatibility with clients that still look for deprecated API elements
|
// Compatibility with clients that still look for deprecated API elements
|
||||||
Status: e.Status.String(),
|
Status: e.Status.String(),
|
||||||
|
|
|
@ -222,6 +222,36 @@ var _ = Describe("Podman events", func() {
|
||||||
Expect(result2.OutputToString()).To(ContainSubstring(fmt.Sprintf("pod_id=%s", id)))
|
Expect(result2.OutputToString()).To(ContainSubstring(fmt.Sprintf("pod_id=%s", id)))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman events network connection", func() {
|
||||||
|
network := stringid.GenerateRandomID()
|
||||||
|
result := podmanTest.Podman([]string{"create", "--network", "bridge", ALPINE, "top"})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result).Should(ExitCleanly())
|
||||||
|
ctrID := result.OutputToString()
|
||||||
|
|
||||||
|
result = podmanTest.Podman([]string{"network", "create", network})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result).Should(ExitCleanly())
|
||||||
|
|
||||||
|
result = podmanTest.Podman([]string{"network", "connect", network, ctrID})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result).Should(ExitCleanly())
|
||||||
|
|
||||||
|
result = podmanTest.Podman([]string{"network", "disconnect", network, ctrID})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result).Should(ExitCleanly())
|
||||||
|
|
||||||
|
result = podmanTest.Podman([]string{"events", "--stream=false", "--since", "30s"})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result).Should(ExitCleanly())
|
||||||
|
lines := result.OutputToStringArray()
|
||||||
|
Expect(lines).To(HaveLen(5))
|
||||||
|
Expect(lines[3]).To(ContainSubstring("network connect"))
|
||||||
|
Expect(lines[3]).To(ContainSubstring(fmt.Sprintf("(container=%s, name=%s)", ctrID, network)))
|
||||||
|
Expect(lines[4]).To(ContainSubstring("network disconnect"))
|
||||||
|
Expect(lines[4]).To(ContainSubstring(fmt.Sprintf("(container=%s, name=%s)", ctrID, network)))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman events health_status generated", func() {
|
It("podman events health_status generated", func() {
|
||||||
session := podmanTest.Podman([]string{"run", "--name", "test-hc", "-dt", "--health-cmd", "echo working", "busybox"})
|
session := podmanTest.Podman([]string{"run", "--name", "test-hc", "-dt", "--health-cmd", "echo working", "busybox"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
|
Loading…
Reference in New Issue