Commit graph

1235 commits

Author SHA1 Message Date
Sebastiaan van Stijn
f71fe8476a
api/server: fix empty-lines (revive)
api/server/router/build/build_routes.go:239:32: empty-lines: extra empty line at the start of a block (revive)
    api/server/middleware/version.go:45:241: empty-lines: extra empty line at the end of a block (revive)
    api/server/router/swarm/helpers_test.go:11:44: empty-lines: extra empty line at the end of a block (revive)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-28 01:58:51 +02:00
Sebastiaan van Stijn
91f14e751f
Merge pull request #44111 from thaJeztah/remove_tagger
api/server/backend/build: remove Tagger and NewTagger
2022-09-27 21:04:16 +02:00
Sebastiaan van Stijn
55fd77f724
set ReadHeaderTimeout to address G112: Potential Slowloris Attack (gosec)
After discussing in the maintainers meeting, we concluded that Slowloris attacks
are not a real risk other than potentially having some additional goroutines
lingering around, so setting a long timeout to satisfy the linter, and to at
least have "some" timeout.

    libnetwork/diagnostic/server.go:96:10: G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server (gosec)
        srv := &http.Server{
            Addr:    net.JoinHostPort(ip, strconv.Itoa(port)),
            Handler: s,
        }
    api/server/server.go:60:10: G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server (gosec)
                srv: &http.Server{
                    Addr: addr,
                },
    daemon/metrics_unix.go:34:13: G114: Use of net/http serve function that has no support for setting timeouts (gosec)
            if err := http.Serve(l, mux); err != nil && !strings.Contains(err.Error(), "use of closed network connection") {
                      ^
    cmd/dockerd/metrics.go:27:13: G114: Use of net/http serve function that has no support for setting timeouts (gosec)
            if err := http.Serve(l, mux); err != nil && !strings.Contains(err.Error(), "use of closed network connection") {
                      ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-22 12:13:28 +02:00
Sebastiaan van Stijn
ff81dc3544
api/server/backend/build: remove Tagger and NewTagger
The Tagger was introduced in 0296797f0f, as part
of a refactor, but was never used outside of the package itself. The commit
also didn't explain why this was changed into a Type with a constructor, as all
the constructor appears to be used for is to sanitize and validate the tags.

This patch removes the `Tagger` struct and its constructor, and instead just
uses a function to do the same.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-07 20:36:00 +02:00
Sebastiaan van Stijn
779a5b3029 ImageService.GetImage(): pass context
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2022-09-07 16:53:45 +02:00
Sebastiaan van Stijn
ce550fa9c2
Merge pull request #43968 from thaJeztah/implement_GetImageOpts
introduce GetImageOpts to manage image inspect data in backend
2022-08-24 19:07:30 +02:00
Sebastiaan van Stijn
a4ac991d02
Merge pull request #43657 from thaJeztah/default_builder_version
api: set default "Builder-Version" to "2" (BuildKit) on Linux
2022-08-18 20:14:47 +02:00
Nicolas De Loof
9a849cc83a
introduce GetImageOpts to manage image inspect data in backend
Currently only provides the existing "platform" option, but more
options will be added in follow-ups.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-08-16 16:49:46 +02:00
Samuel Karp
af1edfd368
Merge pull request #43899 from thaJeztah/fix_build_api_errors 2022-08-13 16:21:38 -07:00
Sebastiaan van Stijn
acd0aa7d38
api/server/router/image: address some linter warnings
My IDE was complaining about some things;

- fix inconsistent receiver name (i vs s)
- fix some variables that collided with imports

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-08-08 13:07:50 +02:00
Sebastiaan van Stijn
2279803c8c
Merge pull request #43822 from thaJeztah/image_load_save
containerd integration: Implement load/save
2022-08-04 13:45:27 +02:00
Nicolas De Loof
50fb999bb1
add image load/save support
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-08-04 09:41:19 +02:00
Sebastiaan van Stijn
e0db8207f3
api: add BuildCache.Parents for API >= v1.42
This field was added to replace the deprecated "Parent" field.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-08-04 09:30:06 +02:00
Sebastiaan van Stijn
ebf339628a
api: deprecate BuildCache.Parent in API >= v1.42
This field has been deprecated in BuildKit, so this follows the deprecation
in the Engine API.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-08-04 09:27:34 +02:00
Brian Goff
7e8df0e2c9
Merge pull request #43820 from thaJeztah/image_delete
containerd integration: Implement ImageDelete for containerd
2022-08-03 15:47:07 -07:00
Sebastiaan van Stijn
0f5ac7761d
api: api/server/router/build: fix API errors
Some error conditions returned a non-typed error, which would be returned
as a 500 status by the API. This patch;

- Updates such errors to return an errdefs.InvalidParameter type
- Introduces a locally defined `invalidParam{}` type for convenience.
- Updates some error-strings to match Go conventions

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-08-02 17:17:49 +02:00
Sebastiaan van Stijn
7819811835
api: add registry.DecodeAuthConfig, registry.DecodeAuthConfigBody
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-29 23:11:13 +02:00
Sebastiaan van Stijn
55d1a56826
plugin: use types/registry.AuthConfig
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-29 23:05:19 +02:00
Sebastiaan van Stijn
d8a43399a8
api/server/router: use types/registry.AuthConfig
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-29 23:05:14 +02:00
Sebastiaan van Stijn
857cb260c7
api: add const for 'X-Registry-Auth'
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-29 23:04:34 +02:00
Djordje Lukic
26c65447df
Implement ImageDelete for containerd
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-28 22:56:34 +02:00
Sebastiaan van Stijn
6668801d40
gofmt files
result of:

    gofmt -s -w $(find . -type f -name '*.go' | grep -v "/vendor/")

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-08 18:37:30 +02:00
Sebastiaan van Stijn
717a503590
api: add Hosts to API Config
This makes the API configuration more self-contained.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-06-29 19:55:03 +02:00
Sebastiaan van Stijn
0bce64f08d
api: POST /containers/{id}/wait: fix validation for "condition" parameter
commit 737e8c6ab8 added validation for the wait
condition parameter, however, the default ("not-running") option was not part
of the list of valid options, resulting in a regression if the default value
was explicitly passed;

    docker scan --accept-license --version
    Error response from daemon: invalid condition: "not-running"

This patch adds the missing option, and adds a test to verify.

With this patch;

    make BIND_DIR=. DOCKER_GRAPHDRIVER=vfs TEST_FILTER=TestWaitConditions test-integration
    ...
    --- PASS: TestWaitConditions (0.04s)
    --- PASS: TestWaitConditions/removed (1.79s)
    --- PASS: TestWaitConditions/default (1.91s)
    --- PASS: TestWaitConditions/next-exit (1.97s)
    --- PASS: TestWaitConditions/not-running (1.99s)
    PASS

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-06-27 14:45:32 +02:00
Paweł Gronowski
56a20dbc19 container/exec: Support ConsoleSize
Now client have the possibility to set the console size of the executed
process immediately at the creation. This makes a difference for example
when executing commands that output some kind of text user interface
which is bounded by the console dimensions.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2022-06-24 11:54:25 +02:00
Djordje Lukic
b4ffe3a9fb Move the inspect code away from the image service
The LoopkupImage method is only used by the inspect image route and
returns an api/type struct. The depenency to api/types of the
daemon/images package is wrong, the daemon doesn't need to know about
the api types.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2022-06-22 15:08:55 +02:00
Sebastiaan van Stijn
7b153b9e28
api: set default "Builder-Version" to "2" (BuildKit) on Linux
Starting with the 22.06 release, buildx is the default client for
docker build, which uses BuildKit as builder.

This patch changes the default builder version as advertised by
the daemon to "2" (BuildKit), so that pre-22.06 CLIs with BuildKit
support (but no buildx installed) also default to using BuildKit
when interacting with a 22.06 (or up) daemon.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-05-29 16:41:07 +02:00
Nicolas De Loof
304fbf0804
introduce CreateMountpoint for parity between binds and mounts
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-05-19 16:43:06 +02:00
Paweł Gronowski
85a7f5a09a daemon/linux: Set console size on creation
On Linux the daemon was not respecting the HostConfig.ConsoleSize
property and relied on cli initializing the tty size after the container
was created. This caused a delay between container creation and
the tty actually being resized.

This is also a small change to the api description, because
HostConfig.ConsoleSize is no longer Windows-only.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2022-05-19 07:57:27 +02:00
Nicolas De Loof
ea6760138c
wsContainersAttach attach to stdin/out/err streams as requested
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-05-17 13:23:07 +02:00
Drew Erny
240a9fcb83
Add Swarm cluster volume supports
Adds code to support Cluster Volumes in Swarm using CSI drivers.

Signed-off-by: Drew Erny <derny@mirantis.com>
2022-05-13 00:55:44 +02:00
Nicolas De Loof
af5d83a641
Make it explicit raw|multiplexed stream implementation being used
fix #35761

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2022-05-12 11:36:31 +02:00
Sebastiaan van Stijn
f0d1911ddf
api/server: fix stray import in container_routes.go
This import was left behind due to some PR's being merged, both
affecting the imports that were used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-05-06 19:09:13 +02:00
Sebastiaan van Stijn
7b08faa089
Merge pull request #43552 from thaJeztah/remove_redundant_validation
api:  postContainersStop, postContainersRestart  remove redundant validation
2022-05-06 17:47:33 +02:00
Sebastiaan van Stijn
d733481399
daemon: daemon.ContainerKill() accept stop-signal as string
This allows the postContainersKill() handler to pass values as-is. As part of
the rewrite, I also moved the daemon.GetContainer(name) call later in the
function, so that we can fail early if an invalid signal is passed, before
doing the (heavier) fetching of the container.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-05-05 11:27:47 +02:00
Sebastiaan van Stijn
789223f2dc
api: postContainersStop, postContainersRestart remove redundant validation
Both of these pass the signal to daemon.containerStop(), which already validates
the signal; 2ed904cad7/daemon/stop.go (L48-L52)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-05-02 14:12:14 +02:00
Sebastiaan van Stijn
41b96bff55
update uses of container.ContainerCreateCreatedBody to CreateResponse
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-28 22:39:20 +02:00
Sebastiaan van Stijn
64e96932bd
api: rename volume.VolumeCreateBody to volume.CreateOptions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-28 22:39:14 +02:00
Sebastiaan van Stijn
18281c92fa
api: rename volume.VolumeListOKBody to volume.ListResponse
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-28 22:39:12 +02:00
Sebastiaan van Stijn
3cae9fef16
imports: remove "volumetypes" aliases for api/types/volume
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-28 22:39:04 +02:00
Sebastiaan van Stijn
7293857456
api: rename ContainerWaitOKBody to container.WaitResponse
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-28 22:38:20 +02:00
Sebastiaan van Stijn
787257f767
Merge pull request #43332 from thaJeztah/api_swagger_move_definitions
api: swagger: use explicit definitions for some response types, and move examples per-field
2022-04-26 23:46:49 +02:00
Sebastiaan van Stijn
cd054983ff
api/server: remove "Logging" from config
The Logging boolean was unconditionally set to true and ignored in all locations,
except for enabling the debugging middleware, which was also gated by the active
logrus logging level.

While it could make sense to have a Loglevel option configured on the API server,
we don't have this currently, and to make that actually useful, that config would
need to be tollerated by all locations that produce logs (which isn't the case
either).

Looking at the history of this option; a boolean to disable logging was originally
added in commit c423a790d6, which hard-coded it to
"disabled" in a test, and "enabled" for the API server outside of tests (before
that commit, logging was always enabled).

02ddaad5d9 and 5c42b2b512
changed the hard-coded values to be configurable through a `Logging` env-var (env-
vars were used _internally_ at the time to pass on options), which later became
a configuration struct in a0bf80fe03.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-23 23:38:30 +02:00
Sebastiaan van Stijn
176f66df9c
api/types: replace uses of deprecated types.Volume with volume.Volume
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-21 19:50:59 +02:00
Sebastiaan van Stijn
83a185897d
API: add "signal" parameter to container stop and restart endpoints
Containers can have a default stop-signal (`--stop-signal` / `STOPSIGNAL`) and
timeout (`--stop-timeout`). It is currently not possible to update either of
these after the container is created (`docker update` does not allow updating
them), and while either of these can be overridden through some commands, we
currently do not have a command that can override *both*:

command         | stop-signal | stop-timeout | notes
----------------|-------------|--------------|----------------------------
docker kill     | yes         | DNA          | only sends a single signal
docker restart  | no          | yes          |
docker stop     | no          | yes          |

As a result, if a user wants to stop a container with a custom signal and
timeout, the only option is to do this manually:

    docker kill -s <custom signal> mycontainer
    # wait <desired timeout>
    # press ^C to cancel the graceful stop
    # forcibly kill the container
    docker kill mycontainer

This patch adds a new `signal` query parameter to the container "stop" and
"restart" endpoints. This parameter can be added as a new flag on the CLI,
which would allow stopping and restarting with a custom timeout and signal,
for example:

    docker stop --signal=SIGWINCH --time=120 mycontainer

    docker restart --signal=SIGWINCH --time=120 mycontainer

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-20 21:29:31 +02:00
Sebastiaan van Stijn
90de570cfa
backend: add StopOptions to ContainerRestart and ContainerStop
While we're modifying the interface, also add a context to both.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-20 21:29:30 +02:00
Brian Goff
9b4c516864
Merge pull request #43471 from thaJeztah/grpc_nit
api/server/router/grpc: fix some nits in NewRouter()
2022-04-20 09:59:58 -07:00
Sebastiaan van Stijn
ff5f70e55f
api/server/httputils: move WriteJSON() together with ReadJSON()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-11 21:37:57 +02:00
Sebastiaan van Stijn
0c9ff0b45a
api/server/httputils: add ReadJSON() utility
Implement a ReadJSON() utility to help reduce some code-duplication,
and to make sure we handle JSON requests consistently (e.g. always
check for the content-type).

Differences compared to current handling:

- prevent possible panic if request.Body is nil ("should never happen")
- always require Content-Type to be "application/json"
- be stricter about additional content after JSON (previously ignored)
- but, allow the body to be empty (an empty body is not invalid);
  update TestContainerInvalidJSON accordingly, which was testing the
  wrong expectation.
- close body after reading (some code did this)

We should consider to add a "max body size" on this function, similar to
7b9275c0da/api/server/middleware/debug.go (L27-L40)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-11 21:37:51 +02:00
Sebastiaan van Stijn
ef490cae45
api/server/httputils: matchesContentType(): return error instead of logging
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-11 21:37:00 +02:00