Commit Graph

54719 Commits

Author SHA1 Message Date
Paweł Gronowski
f8b9396c2c gha/labeler: Fix dependencies
Make sure that ALL (not ANY) conditions are satisfied

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-10-29 11:21:51 +01:00
Sebastiaan van Stijn
d3eb04fe59 Merge pull request #51312 from austinvazquez/refactor-client-container-wait
client: refactor ContainerWait to use client defined options/results structs
2025-10-29 11:12:52 +01:00
Austin Vazquez
40bf2b05f3 Merge pull request #51317 from austinvazquez/refactor-client-container-logs
client: refactor `ContainerLogs` to wrap result
2025-10-29 05:06:22 -05:00
Sebastiaan van Stijn
a0f877d1b3 Merge pull request #51316 from austinvazquez/refactor-client-container-export
client: refactor `ContainerExport` to wrap options/result structs
2025-10-29 10:01:07 +01:00
Austin Vazquez
28ed1ef927 client: refactor ContainerLogs to wrap result
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-29 09:54:23 +01:00
Sebastiaan van Stijn
c438b3fbbf Merge pull request #51314 from austinvazquez/refactor-client-container-list
client: refactor `ContainerList` to wrap result
2025-10-29 08:31:22 +01:00
Sebastiaan van Stijn
2bb019b1d2 Merge pull request #51313 from austinvazquez/refactor-client-container-top
client: refactor `ContainerTop` to wrap options and results
2025-10-29 08:29:22 +01:00
Austin Vazquez
749c980d4e client: refactor ContainerExport to wrap options/result structs
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-28 19:39:13 -05:00
Austin Vazquez
ec22a1e5b2 client: refactor ContainerTop to wrap options and results
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-28 18:54:43 -05:00
Austin Vazquez
c5ddef1122 client: refactor ContainerList to wrap result
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-28 18:52:52 -05:00
Austin Vazquez
cf173bc941 client: refactor ContainerWait to use client defined options/results structs
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-28 18:15:01 -05:00
Austin Vazquez
4ce86e2c9b Merge pull request #51310 from thaJeztah/volume_output_structs
client: VolumeRemove, VolumeUpdate: add output struct
2025-10-28 18:14:24 -05:00
Austin Vazquez
aa380c26fc Merge pull request #51304 from thaJeztah/faulty_defers
fix some faulty defers in tests
2025-10-28 18:11:19 -05:00
Austin Vazquez
e95f6c8191 Merge pull request #51307 from thaJeztah/ping_once
client: remove NegotiateAPIVersion, NegotiateAPIVersionPing
2025-10-28 14:08:56 -05:00
Sebastiaan van Stijn
848b0452d3 client: VolumesPrune: rename argument for consistency
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-28 15:42:34 +01:00
Sebastiaan van Stijn
1985a8979e client: VolumeUpdate: add output struct, and move "version"
- Add a VolumeUpdateResult output struct
- Move the swarm version argument to the options, to align
  with other swarm-related methods.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-28 15:42:33 +01:00
Sebastiaan van Stijn
faee204c02 client: VolumeRemove: add output struct
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-28 15:42:33 +01:00
Sebastiaan van Stijn
90109a373d Merge pull request #51308 from thaJeztah/client_container_types
client: add option and output structs for various container methods
2025-10-28 15:42:25 +01:00
Sebastiaan van Stijn
9e7e01ef16 Merge pull request #51153 from corhere/excise-json-streams-from-api
api: move `pkg/streamformatter`, `pkg/progress` to `daemon/internal`
2025-10-28 13:36:16 +01:00
Sebastiaan van Stijn
1f5c82b9fa client: add option and output structs for various container methods
Add option- and output structs for;

- Client.ContainerKill
- Client.ContainerPause
- Client.ContainerRemove
- Client.ContainerResize
- Client.ContainerRestart
- Client.ContainerStart
- Client.ContainerStop
- Client.ContainerUnpause

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 23:46:28 +01:00
Sebastiaan van Stijn
bbf3dea9b2 Merge pull request #51305 from thaJeztah/stats_ostype
api/types/container: StatsResponse: add OSType field, remove client.ContainerStatsResult.OSType
2025-10-27 21:14:43 +01:00
Sebastiaan van Stijn
edbf321ce6 client: remove NegotiateAPIVersion, NegotiateAPIVersionPing
Remove these methods in favor of adding negotiation options to the
Ping method.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 19:27:48 +01:00
Sebastiaan van Stijn
c4aee2a50e client: remove ContainerStatsResult.OSType field
The API now includes this information per record, and clients can
get this information using the `Ping` method if needed as fallback.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 17:20:16 +01:00
Sebastiaan van Stijn
6a2a1dd6cf api/types/container: StatsResponse: add OSType field
Adds a per-stats OSType field to allow handle the platform-specific fields.
Before this change, the client had to get the OSType field from the server's
API response header and copy it to each record.

Older daemon versions don't have this field, so the client still needs to
handle fallbacks.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 16:39:32 +01:00
Sebastiaan van Stijn
25d16ddc0e Merge pull request #51293 from thaJeztah/merge_stats
client: ContainerStats: add option, output-structs, remove ContainerStatsOneShot
2025-10-27 16:13:47 +01:00
Sebastiaan van Stijn
8498525a98 Merge pull request #51298 from thaJeztah/cleaner_stats
daemon: stats: cleanup and remove "OneShot" error
2025-10-27 15:18:39 +01:00
Sebastiaan van Stijn
8118385ba8 client: ContainerStats: add option, output-structs, remove ContainerStatsOneShot
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 14:03:55 +01:00
Sebastiaan van Stijn
de2ff4973f Merge pull request #51303 from thaJeztah/merge_stats_step1
integration-cli, integration: cleanup and improve some "stats" tests
2025-10-27 13:59:04 +01:00
Sebastiaan van Stijn
5df881f3a7 daemon: Daemon.ContainerStats: don't escape HTML in responses
We have no need for it, and keeps the response more readable in case
it would ever contain any values that need escaping; it also would save
some cycles to check for such characters.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 12:46:03 +01:00
Sebastiaan van Stijn
7623979aba daemon: Daemon.ContainerStats: combine some conditions and remove error
When streaming stats, the `OneShot` option is implied; streaming results
never populate the Pre* fields on the first result, so instead of producing
an error, we may as well ignore the option.

While updating this, also combine some of the conditions for non-streaming
results in an attempt to make the logic (early return on non-streaming,
one-shot requests) slightly clearer.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 12:46:02 +01:00
Sebastiaan van Stijn
95a3880197 daemon: Daemon.ContainerStats: inline getStatJSON closure
Inline the code that handles preserving the previous read and putting
it in the next read, and rename some variables for clarity.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 12:46:02 +01:00
Sebastiaan van Stijn
f7003ef7de integration-cli: minor cleanups in stats tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 12:45:12 +01:00
Sebastiaan van Stijn
5742b40c87 integration-cli: simplify, improve some stats tests
Remove the go-routines and just fetch the result for non-streaming stats.
Also check for the result to be valid for some tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 12:45:05 +01:00
Sebastiaan van Stijn
e690c84bed integration-cli: remove TestAPIStatsNetworkStatsVersioning
It was a leftover for pre-API v1.21 tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 12:43:48 +01:00
Sebastiaan van Stijn
155d697010 integration/container: TestStats: use sub-tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 12:43:47 +01:00
Sebastiaan van Stijn
6511d86797 Merge pull request #51302 from thaJeztah/fix_one_shot_stats
daemon: Daemon.stats: fill-in container ID and Name when collecting
2025-10-27 12:42:47 +01:00
Sebastiaan van Stijn
6040a2f686 fix some faulty defers in tests
Calling "defer assert.NilError(t, someCommand())" executes "someCommand()"
immediately, but doesn't assert the error until the defer.
https://go.dev/play/p/EO--y7OYerg

    package main

    import (
        "errors"
        "testing"

        "gotest.tools/v3/assert"
    )

    func TestDefer(t *testing.T) {
        doSomething := func() error {
            t.Log("doSomething failed with an error!")
            return errors.New("foo error")
        }

        defer assert.NilError(t, doSomething())

        t.Log("running test")
        t.Log("running test")
        t.Log("running test")
    }

Produces:

    === RUN   TestDefer
        prog_test.go:12: doSomething failed with an error!
        prog_test.go:18: running test
        prog_test.go:19: running test
        prog_test.go:20: running test
        prog_test.go:21: assertion failed: error is not nil: foo error
    --- FAIL: TestDefer (0.00s)
    FAIL

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 12:39:21 +01:00
Sebastiaan van Stijn
370ca31ecf Merge pull request #51299 from thaJeztah/cleanup_stats_type
api/types/container: StatsResponse: cleanup fields and GoDoc
2025-10-27 12:08:58 +01:00
Sebastiaan van Stijn
e410daf8f7 integration-cli: TestContainerAPIStatsWithNetworkDisabled: check result
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 10:55:01 +01:00
Sebastiaan van Stijn
7439f09cd2 daemon: Daemon.stats: fill-in container ID and Name when collecting
Propagate these fields when collecting the data, instead of patching the
result inside the router.

This also fixes a bug where the ID and Name fields were not set when using
one-shot.

Before this patch, the "id" and "name" fields were not set in one-shot mode:

    curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/foo/stats?stream=false' | jq .id
    "125d7f3df7919c33195fa4ec0636c27cdbe6d9b14339867d2920900565bcaf7e"
    curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/foo/stats?stream=false' | jq .name
    "/foo"

    curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/foo/stats?stream=false&one-shot=true' | jq .id
    null
    curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/foo/stats?stream=false&one-shot=true' | jq .name
    null

With this patch, both are set:

    curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/foo/stats?stream=false&one-shot=true' | jq .id
    "125d7f3df7919c33195fa4ec0636c27cdbe6d9b14339867d2920900565bcaf7e"
    curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/foo/stats?stream=false&one-shot=true' | jq .name
    "/foo"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 10:55:01 +01:00
Sebastiaan van Stijn
882cffee93 Merge pull request #51297 from thaJeztah/remove_ImageLoadResult_json
client: remove ImageLoadResult.JSON
2025-10-26 21:35:03 +01:00
Sebastiaan van Stijn
3088c4e192 api/types/container: StatsResponse: cleanup fields and GoDoc
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-26 20:37:40 +01:00
Sebastiaan van Stijn
9b795c53a7 client: remove ImageLoadResult.JSON field
The JSON field was added in [moby@9fd2c0f], to address [moby#19177], which
reported an incompatibility with Classic (V1) Swarm, which produced a non-
standard response;

> Make docker load to output json when the response content type is json
> Swarm hijacks the response from docker load and returns JSON rather
> than plain text like the Engine does. This makes the API library to return
> information to figure that out.

A later change in [moby@96d7db6] added additional logic to make sure the
correct content-type was returned, depending on whether the `quiet` option
was set (which produced a non-JSON response). This caused inconsistency in
the API response, and [moby@2f27632] changed the endpoint to always produce
JSON (only skipping the "progress" output if `quiet` was set).

This means that the "load" endpoint ([`imageRouter.postImagesLoad`]) now
unconditionally returns JSON, making the `JSON` field fully redundant.

We should consider deprecating the "quiet" option, as it's really the client's
responsibility to show or hide progress-bars, but we can do this separately.

This patch removes the JSON field, as it's redundant, and the way it handles
the content-type is incorrect because it would not handle correct, but different
formatted response-headers (`application/json; charset=utf-8`), which could
result in malformed output on the client.

[moby@9fd2c0f]: 9fd2c0feb0
[moby#19177]: https://github.com/moby/moby/issues/19177
[moby@96d7db6]: 96d7db665b
[moby@2f27632]: 2f27632cde
[`imageRouter.postImagesLoad`]: 7b9d2ef6e5/api/server/router/image/image_routes.go (L248-L255)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-26 19:46:49 +01:00
Rob Murray
0a134ecc16 Merge pull request #51296 from thaJeztah/fix_ImageLoadResult_godoc
client: fix ImageLoadResult GoDoc
2025-10-26 15:22:50 +00:00
Sebastiaan van Stijn
ef589ef824 client: fix ImageLoadResult GoDoc
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-26 12:30:18 +01:00
Paweł Gronowski
c8df751f86 Merge pull request #51294 from thaJeztah/daemon_cleanups
daemon: some minor cleanups
2025-10-26 11:21:27 +01:00
Sebastiaan van Stijn
bc2d0b4b5a Merge pull request #51289 from vvoland/client-container-exec2
client/container_exec: Separate structs for Start and Attach
2025-10-25 19:30:59 +02:00
Sebastiaan van Stijn
5cf4d68121 daemon: subscribeToContainerStats: return cancel / unsubscribe function
Rewrite this method to return a function to cancel / unsubscribe, so that
callers are encouraged to handle this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-25 16:15:50 +02:00
Sebastiaan van Stijn
99410827c7 daemon: use errdefs instead of string-matching in some places
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-25 16:13:30 +02:00
Paweł Gronowski
4aac139fc0 client/container_exec: Separate structs for Start and Attach
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-10-25 12:23:14 +02:00