Skip to content

migrate TestAPIStatsNetworkStats to integration#51800

Closed
deahtstroke wants to merge 80 commits intomoby:masterfrom
deahtstroke:50159-migrate-TestAPIStatsNetworkStats-to-integration
Closed

migrate TestAPIStatsNetworkStats to integration#51800
deahtstroke wants to merge 80 commits intomoby:masterfrom
deahtstroke:50159-migrate-TestAPIStatsNetworkStats-to-integration

Conversation

@deahtstroke
Copy link

…n/ suite

- What I did
Migrated the test TestAPIStatsNetworkStats to integration/ from the integration-cli/ suite in reference to epic #50159
- How I did it
Using test on integration-cli/docker_api_stats_test.go and slightly tweaking it to use the go-client instead of the direct CLI
- How to verify it
Run using the integration test directive in the makefile:

TESTDIRS='./integration/container/' TESTFLAGS='-test.run TestStatsNetworkStats' make test-integration

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)
image

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Overall looking good; I left some suggestions, let me know what you think; I opened a PR against your branch with my suggestions; if those changes look good to you, you can merge that PR, which will make them show up here; feel free to squash my commit though, as we don't need the extra commit 😅

@deahtstroke
Copy link
Author

Saw the changes to my branch and I think they look good! Just for guidance, in deahstroke/moby I need to squash + merge, then those changes will appear here? And additionally, I need force push the removal of the code that polls for the container to be ready in that specific order?

@thaJeztah
Copy link
Member

Thanks! Yes, you can (rebase, and) squash your branch; also happy to do so for you; looks like the DCO check doesn't like the merge-commit, so I can do a quick rebase and squash for you.

@thaJeztah thaJeztah force-pushed the 50159-migrate-TestAPIStatsNetworkStats-to-integration branch from f60e3eb to 2fbd1b4 Compare January 5, 2026 13:00
@thaJeztah
Copy link
Member

Rebased; DCO-check should probably be happy now 🤞

@deahtstroke
Copy link
Author

When you said that the DCO did not like the merge-commit, is that something I did on my end?

@thaJeztah
Copy link
Member

No, not really a mistake you made; the DCO check checks for every commit-message in the PR to have a Signed-Off-By line. When merging my PR into your branch, GitHub will create a merge commit, using a generic merge XXX into XXX commit-message, and it doesn't include such a line in the commit-message.

}

func (s *DockerAPISuite) TestAPIStatsNetworkStats(c *testing.T) {
skip.If(c, RuntimeIsWindowsContainerd(), "FIXME: Broken on Windows + containerd combination")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realised that there was a FIXME comment here; apparently something wasn't right when using containerd as runtime (see 1285c6d).

Perhaps good to preserve that comment so that it's clear why we're skipping it currently (and to look into the failure to see if we can un-skip it)

Let me push a quick change to restore that comment.

@thaJeztah thaJeztah force-pushed the 50159-migrate-TestAPIStatsNetworkStats-to-integration branch from 2fbd1b4 to 4df22f2 Compare January 5, 2026 13:17
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

but perhaps @vvoland can give a second review because I pushed the latest changes 😅

Copy link
Contributor

@vvoland vvoland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vvoland vvoland added this to the 29.2.0 milestone Jan 5, 2026
@vvoland vvoland added the kind/refactor PR's that refactor, or clean-up code label Jan 5, 2026
@thaJeztah
Copy link
Member

Interesting; getting a failure now 🤔

=== RUN   TestStatsNetworkStats
    stats_test.go:167: assertion failed: postTxPackets is less than expTxPkts: Reported less TxPackets than expected. Expected >= 3. Found 1. PING 172.17.0.2 (172.17.0.2): 56 data bytes
        64 bytes from 172.17.0.2: icmp_seq=0 ttl=64 time=0.092 ms
        --- 172.17.0.2 ping statistics ---
        1 packets transmitted, 1 packets received, 0% packet loss
        round-trip min/avg/max/stddev = 0.092/0.092/0.092/0.000 ms

@deahtstroke
Copy link
Author

deahtstroke commented Jan 5, 2026

Yes I was checking this while the CI tests were running but I'm not sure how it fails in Ubuntu-22.04 🤔 only difference between the old and new test is just how we get the network stats.

@thaJeztah
Copy link
Member

Yeah, not sure either. Perhaps it's cgroups v1 vs v2; ISTR we may be skipping (some of) the integration-cli tests on cgroups v2. Although in that case, I'd expected the reverse to happen (and it failing on 24.04) 🤔

Could still be some race-condition of course.

@deahtstroke
Copy link
Author

Is there a way I can replicate this myself? I was just reading through the docs for testing but I'm unsure how to target a specific distro while being rootless

@deahtstroke
Copy link
Author

deahtstroke commented Jan 7, 2026

Hello again! Yesterday I worked on trying to replicate this as much as I could on my own local environment by running it on Ubuntu 22.04 LTS while using Docker Rootless mode. Perhaps something from my environment was missing to fully replicate it 100% as it is in the CI, but the test passed fully. I was thinking if I should add some slight delay before running the assertions or worst comes to worst, skip in rootless mode which I don't think this is the best way to go. Any thoughts?

Copy link
Contributor

@vvoland vvoland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI red

@vvoland vvoland modified the milestones: 29.2.0, 29.3.0, 29.2.1 Jan 22, 2026
@vvoland vvoland removed this from the 29.2.1 milestone Feb 2, 2026
@deahtstroke deahtstroke force-pushed the 50159-migrate-TestAPIStatsNetworkStats-to-integration branch from 4df22f2 to 993d69e Compare February 4, 2026 06:52
…n/suite

Signed-off-by: Daniel Villavicencio <dvm3099@pm.me>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@deahtstroke deahtstroke force-pushed the 50159-migrate-TestAPIStatsNetworkStats-to-integration branch from 993d69e to 1846aa6 Compare February 4, 2026 07:04
thaJeztah and others added 14 commits February 24, 2026 00:49
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Follow-up to fadc29b

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The driver was removed in f725489,
so users won't be able to have it configured.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The oracle vm tests are frequently timing out; let's see if it's
just slowness.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
While these fields are only propagated on Linux, there should be no
need to only conditionally include the fields in the inspect response;
just pass through the information we have (which should be empty on
Windows).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The log would log an info about skipping a missing directory together
with a "not found" error (which was redundant), but discard the error
for other problems.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
When shutting down the daemon, containers are stopped/killed, which calls
`container.ExitOnNext()` to stop the restart manager to prevent containers
with a restart policy from being restarted. However, when the daemon handles
the container exit (Daemon.handleContainerExit), it checks whether the container
should be restarted (`container.RestartManager().ShouldRestart`), which returns
an `ErrRestartCanceled` if the restart manager is stopped.

This patch:

- Prevents the `ErrRestartCanceled` from being logged as a warning; for
  other errors, a log is still produced; also splitting the `exitStatus`
  field to `exitCode` and `exitedAt` as the string presentation of it
  was not human-readable.
- Adds an "info" log to log when the restart-manager is disabled for a
  container with a restart-policy.
- Changes the confusing "ignoring event" log for a more informative message
  ("received task-delete event from containerd"). We don't act on this
  event, but do want to log it to verify containerd handled the shutdown.
- Changes the "restarting container" log from "Debug" to "Info"; this
  allows verifying that the restart-monitor handled a container-exit

Before this patch:

    ^CINFO[2026-02-21T20:04:42.937057877Z] Processing signal 'interrupt'
    INFO[2026-02-21T20:04:43.074175085Z] ignoring event                                container=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
    INFO[2026-02-21T20:04:43.073736502Z] shim disconnected                             id=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 namespace=moby
    INFO[2026-02-21T20:04:43.074380960Z] cleaning up after shim disconnected           id=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 namespace=moby
    INFO[2026-02-21T20:04:43.074393169Z] cleaning up dead shim                         id=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 namespace=moby
    WARN[2026-02-21T20:04:43.084973627Z] ShouldRestart failed, container will not be restarted  container=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 daemonShuttingDown=true error="restart canceled" execDuration=4.868244252s exitStatus="{0 2026-02-21 20:04:43.061117752 +0000 UTC}" hasBeenManuallyStopped=false restartCount=0
    INFO[2026-02-21T20:04:43.231618294Z] stopping event stream following graceful shutdown  error="<nil>" module=libcontainerd namespace=moby
    INFO[2026-02-21T20:04:43.232019419Z] stopping healthcheck following graceful shutdown  module=libcontainerd
    INFO[2026-02-21T20:04:43.232244877Z] stopping event stream following graceful shutdown  error="context canceled" module=libcontainerd namespace=plugins.moby
    INFO[2026-02-21T20:04:44.238598878Z] Daemon shutdown complete

With this patch:

    ^CINFO[2026-02-21T20:07:39.524114750Z] Processing signal 'interrupt'
    INFO[2026-02-21T20:07:39.525043125Z] stopping restart-manager                      container=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8
    INFO[2026-02-21T20:07:39.592829959Z] received task-delete event from containerd    container=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
    INFO[2026-02-21T20:07:39.592859084Z] shim disconnected                             id=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 namespace=moby
    INFO[2026-02-21T20:07:39.593019334Z] cleaning up after shim disconnected           id=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 namespace=moby
    INFO[2026-02-21T20:07:39.593038667Z] cleaning up dead shim                         id=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 namespace=moby
    INFO[2026-02-21T20:07:39.710357042Z] stopping event stream following graceful shutdown  error="<nil>" module=libcontainerd namespace=moby
    INFO[2026-02-21T20:07:39.710912875Z] stopping healthcheck following graceful shutdown  module=libcontainerd
    INFO[2026-02-21T20:07:39.710989959Z] stopping event stream following graceful shutdown  error="context canceled" module=libcontainerd namespace=plugins.moby
    INFO[2026-02-21T20:07:40.724286834Z] Daemon shutdown complete

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The Cleanup function oportunistically tries to cleanup old rule (if any).
In cases where the rules didn't exist, it would log the error returned
by the command, but this would always be `exit status 1`, which doesn't
provide details about the actual failure (i.e., if it's the expected
"does not exist").

We could improve the code by first calling `nft list table` to check if
rules were found, but that would expose a similar problem (error could
be due to the rules not present, or "other cause".

This patch just changes the logs to be more informative, and passes the
context to allow cancelling the command if the context is cancelled.

Before this patch:

    INFO[2026-02-21T13:30:10.428457589Z] Deleting nftables IPv4 rules                  error="exit status 1"
    INFO[2026-02-21T13:30:10.453012214Z] Deleting nftables IPv6 rules                  error="exit status 1"

With this patch:

    INFO[2026-02-21T14:10:06.183933878Z] Deleting nftables IPv4 rules                  error="exit status 1" output="Error: Could not process rule: No such file or directory\ndelete table ip docker-bridges"
    INFO[2026-02-21T14:10:06.212198878Z] Deleting nftables IPv6 rules                  error="exit status 1" output="Error: Could not process rule: No such file or directory\ndelete table ip6 docker-bridges"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Some services are shut-down in a defer, resulting in logs for them being
shut down logged after the "Daemon shutdown complete" log;

    ^CINFO[2026-02-21T16:57:55.312312593Z] Processing signal 'interrupt'
    INFO[2026-02-21T16:57:55.424494218Z] shim disconnected                             id=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 namespace=moby
    INFO[2026-02-21T16:57:55.424642052Z] cleaning up after shim disconnected           id=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 namespace=moby
    INFO[2026-02-21T16:57:55.424655718Z] cleaning up dead shim                         id=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 namespace=moby
    ...
    INFO[2026-02-21T16:57:55.535564427Z] stopping event stream following graceful shutdown  error="<nil>" module=libcontainerd namespace=moby
    INFO[2026-02-21T16:57:55.536002469Z] Daemon shutdown complete
    INFO[2026-02-21T16:57:55.536108635Z] stopping healthcheck following graceful shutdown  module=libcontainerd
    INFO[2026-02-21T16:57:55.536799719Z] stopping event stream following graceful shutdown  error="context canceled" module=libcontainerd namespace=plugins.moby

Move printing the log to a defer so that it's printed last:

    ^CINFO[2026-02-21T17:30:32.762078180Z] Processing signal 'interrupt'
    INFO[2026-02-21T17:30:32.844606222Z] shim disconnected                             id=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 namespace=moby
    INFO[2026-02-21T17:30:32.844780972Z] cleaning up after shim disconnected           id=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 namespace=moby
    INFO[2026-02-21T17:30:32.844787555Z] cleaning up dead shim                         id=1ed1fcfd71c27b5ff4f04c1b33104c17725a841fba7661acea205879fdd687c8 namespace=moby
    ...
    INFO[2026-02-21T17:30:32.962354138Z] stopping event stream following graceful shutdown  error="<nil>" module=libcontainerd namespace=moby
    INFO[2026-02-21T17:30:32.962715347Z] stopping event stream following graceful shutdown  error="context canceled" module=libcontainerd namespace=plugins.moby
    INFO[2026-02-21T17:30:32.962760680Z] stopping healthcheck following graceful shutdown  module=libcontainerd
    INFO[2026-02-21T17:30:33.970766458Z] Daemon shutdown complete

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The daemon previously signaled systemd (READY=1) before the API Serve loops
were started.

Move the readiness notification until after the API listeners are serving
to reduce the window where systemd considers the daemon ready but the
HTTP accept loop has not yet started.

While modifying, also use `WaitGroup.Go` for a slight cleanup.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
It's more idiomatic to not return non-exported types for an exported
function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The `DisplayJSONMessages` only accepted a `JSONMessagesStream`. This meant that
it would not accept the output from (for example) [client.ImagePushResponse].

This patch:

- Makes `DisplayJSONMessages` accept any `iter.Seq2[jsonstream.Message, error]`
- Makes `JSONMessagesStream` an alias instead of a concrete type (TBD if we
  actually need the type).
- Some minor cleanups in the implementation.

[client.ImagePushResponse]: https://github.com/moby/moby/blob/fa87120ae64a170fd42096de3b873b439b95016b/client/image_push.go#L20-L24

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…n/suite

Signed-off-by: Daniel Villavicencio <dvm3099@pm.me>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@deahtstroke deahtstroke deleted the 50159-migrate-TestAPIStatsNetworkStats-to-integration branch February 24, 2026 09:15
@deahtstroke deahtstroke restored the 50159-migrate-TestAPIStatsNetworkStats-to-integration branch February 24, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants