summaryrefslogtreecommitdiff
path: root/api/server
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #45469 from thaJeztah/deprecate_virtualsize_STEP2Akihiro Suda2023-05-162-1/+13
|\ | | | | API: omit deprecated VirtualSize field for API v1.44 and up
| * API: omit deprecated VirtualSize field for API v1.44 and upSebastiaan van Stijn2023-05-062-1/+13
| | | | | | | | | | | | | | | | This field is deprecated since 1261fe69a3586bb102182aa885197822419c768c, and will now be omitted on API v1.44 and up for the `GET /images/json`, `GET /images/{id}/json`, and `GET /system/df` endpoints. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | fixing consistent aliases for OCI spec importsJeyanthinath Muthuram2023-05-084-12/+12
|/ | | | Signed-off-by: Jeyanthinath Muthuram <jeyanthinath10@gmail.com>
* api/server/router/container: containerRouter.postCommit: inline structSebastiaan van Stijn2023-04-291-4/+2
| | | | | | Remove intermediate variable and inline the struct-literal. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Merge pull request #45314 from corhere/graceful-shutdownSebastiaan van Stijn2023-04-281-80/+3
|\ | | | | cmd/dockerd: gracefully shut down the API server
| * cmd/dockerd: gracefully shut down the API serverCory Snider2023-04-261-80/+3
| | | | | | | | | | | | | | | | | | | | | | As of Go 1.8, "net/http".Server provides facilities to close all listeners, making the same facilities in server.Server redundant. http.Server also improves upon server.Server by additionally providing a facility to also wait for outstanding requests to complete after closing all listeners. Leverage those facilities to give in-flight requests up to five seconds to finish up after all containers have been shut down. Signed-off-by: Cory Snider <csnider@mirantis.com>
* | Use the image service instead of the reference store for taggingDjordje Lukic2023-04-261-1/+1
|/ | | | | | | | The image store sends events when a new image is created/tagged, using it instead of the reference store makes sure we send the "tag" event when a new image is built using buildx. Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
* API: deprecate VirtualSize field for /images/json and /images/{id}/jsonSebastiaan van Stijn2023-04-181-1/+1
| | | | | | | | | In versions of Docker before v1.10, this field was calculated from the image itself and all of its parent images. Images are now stored self-contained, and no longer use a parent-chain, making this field an equivalent of the Size field. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* api/server: getImagesJSON(): don't check version in a loopSebastiaan van Stijn2023-04-171-1/+2
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Merge pull request #45300 from thaJeztah/errdefs_aliasSebastiaan van Stijn2023-04-131-7/+7
|\ | | | | use consistent alias for containerd's errdefs package, and validate in CI
| * use consistent alias for containerd's errdefs packageSebastiaan van Stijn2023-04-081-7/+7
| | | | | | | | | | | | | | | | | | | | The signatures of functions in containerd's errdefs packages are very similar to those in our own, and it's easy to accidentally use the wrong package. This patch uses a consistent alias for all occurrences of this import. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | Merge pull request #44510 from thaJeztah/api_server_sanitizeRepoAndTagsSebastiaan van Stijn2023-04-121-11/+5
|\ \ | |/ |/| api/server/backend/build: sanitizeRepoAndTags() check for digest
| * api/server/backend/build: sanitizeRepoAndTags() check for digestSebastiaan van Stijn2022-11-241-11/+5
| | | | | | | | | | | | | | | | The reference.ParseNormalizedNamed() utility already returns a Named reference, but we're interested in wether the digest has a digest, so check for that. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | Merge pull request #44963 from vvoland/c8d-push-upstreamTianon Gravi2023-03-302-2/+20
|\ \ | | | | | | c8d: Implement push
| * | images/push: Accept referencePaweł Gronowski2023-03-302-2/+20
| | | | | | | | | | | | | | | | | | | | | Push the reference parsing from repo and tag names into the api and pass a reference object to the ImageService. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
* | | c8d: add support for `docker diff`Laura Brehm2023-03-302-2/+2
|/ / | | | | | | Signed-off-by: Laura Brehm <laurabrehm@hey.com>
* | registry/search: pass User-Agent through headersSebastiaan van Stijn2023-03-212-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 3991faf4640a46412a8af000ede78fc5cba76d0a moved search into the registry package, which also made the `dockerversion` package a dependency for registry, which brings additional (indirect) dependencies, such as `pkg/parsers/kernel`, and `golang.org/x/sys/windows/registry`. Client code, such as used in docker/cli may depend on the `registry` package, but should not depend on those additional dependencies. This patch moves setting the userAgent to the API router, and instead of passing it as a separate argument, includes it into the "headers". As these headers now not only contain the `X-Meta-...` headers, the variables were renamed accordingly. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | Merge pull request #45086 from corhere/search-in-registry-serviceBjorn Neergaard2023-03-153-4/+9
|\ \ | | | | | | Move filtered registry search out of the image service
| * | Move filtered registry search out of image serviceCory Snider2023-03-103-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SearchRegistryForImages does not make sense as part of the image service interface. The implementation just wraps the search API of the registry service to filter the results client-side. It has nothing to do with local image storage, and the implementation of search does not need to change when changing which backend (graph driver vs. containerd snapshotter) is used for local image storage. Filtering of the search results is an implementation detail: the consumer of the results does not care which actor does the filtering so long as the results are filtered as requested. Move filtering into the exported API of the registry service to hide the implementation details. Only one thing---the registry service implementation---would need to change in order to support server-side filtering of search results if Docker Hub or other registry servers were to add support for it to their APIs. Use a fake registry server in the search unit tests to avoid having to mock out the registry API client. Signed-off-by: Cory Snider <csnider@mirantis.com>
* | | volumes: fix error-handling when removing volumes with swarm enabledSebastiaan van Stijn2023-03-131-14/+18
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 3246db3755698455740c812c6477f43e74924fa7 added handling for removing cluster volumes, but in some conditions, this resulted in errors not being returned if the volume was in use; docker swarm init docker volume create foo docker create -v foo:/foo busybox top docker volume rm foo This patch changes the logic for ignoring "local" volume errors if swarm is enabled (and cluster volumes supported). While working on this fix, I also discovered that Cluster.RemoveVolume() did not handle the "force" option correctly; while swarm correctly handled these, the cluster backend performs a lookup of the volume first (to obtain its ID), which would fail if the volume didn't exist. Before this patch: make TEST_FILTER=TestVolumesRemoveSwarmEnabled DOCKER_GRAPHDRIVER=vfs test-integration ... Running /go/src/github.com/docker/docker/integration/volume (arm64.integration.volume) flags=-test.v -test.timeout=10m -test.run TestVolumesRemoveSwarmEnabled ... === RUN TestVolumesRemoveSwarmEnabled === PAUSE TestVolumesRemoveSwarmEnabled === CONT TestVolumesRemoveSwarmEnabled === RUN TestVolumesRemoveSwarmEnabled/volume_in_use volume_test.go:122: assertion failed: error is nil, not errdefs.IsConflict volume_test.go:123: assertion failed: expected an error, got nil === RUN TestVolumesRemoveSwarmEnabled/volume_not_in_use === RUN TestVolumesRemoveSwarmEnabled/non-existing_volume === RUN TestVolumesRemoveSwarmEnabled/non-existing_volume_force volume_test.go:143: assertion failed: error is not nil: Error response from daemon: volume no_such_volume not found --- FAIL: TestVolumesRemoveSwarmEnabled (1.57s) --- FAIL: TestVolumesRemoveSwarmEnabled/volume_in_use (0.00s) --- PASS: TestVolumesRemoveSwarmEnabled/volume_not_in_use (0.01s) --- PASS: TestVolumesRemoveSwarmEnabled/non-existing_volume (0.00s) --- FAIL: TestVolumesRemoveSwarmEnabled/non-existing_volume_force (0.00s) FAIL With this patch: make TEST_FILTER=TestVolumesRemoveSwarmEnabled DOCKER_GRAPHDRIVER=vfs test-integration ... Running /go/src/github.com/docker/docker/integration/volume (arm64.integration.volume) flags=-test.v -test.timeout=10m -test.run TestVolumesRemoveSwarmEnabled ... make TEST_FILTER=TestVolumesRemoveSwarmEnabled DOCKER_GRAPHDRIVER=vfs test-integration ... Running /go/src/github.com/docker/docker/integration/volume (arm64.integration.volume) flags=-test.v -test.timeout=10m -test.run TestVolumesRemoveSwarmEnabled ... === RUN TestVolumesRemoveSwarmEnabled === PAUSE TestVolumesRemoveSwarmEnabled === CONT TestVolumesRemoveSwarmEnabled === RUN TestVolumesRemoveSwarmEnabled/volume_in_use === RUN TestVolumesRemoveSwarmEnabled/volume_not_in_use === RUN TestVolumesRemoveSwarmEnabled/non-existing_volume === RUN TestVolumesRemoveSwarmEnabled/non-existing_volume_force --- PASS: TestVolumesRemoveSwarmEnabled (1.53s) --- PASS: TestVolumesRemoveSwarmEnabled/volume_in_use (0.00s) --- PASS: TestVolumesRemoveSwarmEnabled/volume_not_in_use (0.01s) --- PASS: TestVolumesRemoveSwarmEnabled/non-existing_volume (0.00s) --- PASS: TestVolumesRemoveSwarmEnabled/non-existing_volume_force (0.00s) PASS Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | remove GetLayerByID from ImageService interfaceNicolas De Loof2023-03-102-2/+2
| | | | | | | | | | | | Co-authored-by: Nicolas De Loof <nicolas.deloof@gmail.com> Co-authored-by: Paweł Gronowski <pawel.gronowski@docker.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | c8d: Compute container's layer sizeLaura Brehm2023-03-082-2/+2
| | | | | | | | | | Co-authored-by: Sebastiaan van Stijn <github@gone.nl> Signed-off-by: Laura Brehm <laurabrehm@hey.com>
* | Merge pull request #45088 from corhere/make-apiserver-less-weirdCory Snider2023-03-011-15/+2
|\ \ | | | | | | api/server: delete Wait method
| * | api/server: delete Wait methodCory Snider2023-03-011-15/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's surprising that the method to begin serving requests is named Wait. And it is unidiomatic: it is a synchronous call, but it sends its return value to the channel passed in as an argument instead of just returning the value. And ultimately it is just a trivial wrapper around serveAPI. Export the ServeAPI method instead so callers can decide how to call and synchronize around it. Call ServeAPI synchronously on the main goroutine in cmd/dockerd. The goroutine and channel which the Wait() API demanded are superfluous after all. The notifyReady() call was always concurrent and asynchronous with respect to serving the API (its implementation spawns a goroutine) so it makes no difference whether it is called before ServeAPI() or after `go ServeAPI()`. Signed-off-by: Cory Snider <csnider@mirantis.com>
* | | Merge pull request #45083 from corhere/unused-api-config-structCory Snider2023-03-012-26/+1
|\ \ \ | |/ / |/| | api/server: drop unused Config struct
| * | api/server: drop unused Config structCory Snider2023-02-282-26/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Server.cfg field is never referenced by any code in package "./api/server". "./api/server".Config struct values are used by DaemonCli code, but only to pass around configuration copied out of the daemon config within the "./cmd/dockerd" package. Delete the "./api/server".Config struct definition and refactor the "./cmd/dockerd" package to pull configuration directly from cli.Config. Signed-off-by: Cory Snider <csnider@mirantis.com>
* | | api: Remove <none> in Repo(Tags|Digests) for >= 1.43Paweł Gronowski2023-02-271-3/+12
|/ / | | | | | | | | | | | | | | | | Deprecate `<none>:<none>` and `<none>@<none>` magic strings included in `RepoTags` and `RepoDigests`. Produce an empty arrays instead and leave the presentation of untagged/dangling images up to the client. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
* | Merge pull request #45025 from corhere/oci-annotation-passthruBrian Goff2023-02-241-0/+5
|\ \
| * | daemon: add annotations to container HostConfigCory Snider2023-02-231-0/+5
| | | | | | | | | | | | | | | | | | | | | Allow clients to set annotations on a container which will applied to the container's OCI spec. Signed-off-by: Cory Snider <csnider@mirantis.com>
* | | api: Move Repo(Digests|Tags) <none> fallback from daemonPaweł Gronowski2023-02-221-0/+7
| | | | | | | | | | | | Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
* | | chore: use http constants to replace numbersxin.li2023-02-211-6/+6
|/ / | | | | | | Signed-off-by: xin.li <xin.li@daocloud.io>
* | api/s/r/swarm: log backend errors at Debug levelCory Snider2023-02-151-16/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The errors are already returned to the client in the API response, so logging them to the daemon log is redundant. Log the errors at level Debug so as not to pollute the end-users' daemon logs with noise. Refactor the logs to use structured fields. Add the request context to the log entry so that logrus hooks could annotate the log entries with contextual information about the API request in the hypothetical future. Fixes #44997 Signed-off-by: Cory Snider <csnider@mirantis.com>
* | api: Extract parsing reference from repo and tagPaweł Gronowski2023-02-073-39/+47
| | | | | | | | Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
* | api/tag: Reject digested target referencesPaweł Gronowski2023-02-071-0/+4
| | | | | | | | Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
* | daemon/imageService: Remove TagImageWithReferencePaweł Gronowski2023-02-074-4/+26
| | | | | | | | | | | | | | | | TagImage is just a wrapper for TagImageWithReference which parses the repo and tag into a reference. Change TagImageWithReference into TagImage and move the responsibility of reference parsing to caller. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
* | daemon: Pass ctx to image tagging operationsNicolas De Loof2023-02-074-6/+7
| | | | | | | | | | Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com> Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
* | api/import: Guard from Digested instead of Canonical referencePaweł Gronowski2023-01-111-1/+1
| | | | | | | | | | | | | | Import shouldn't accept any digested reference, instead of only strictly canonical ones. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
* | daemon/import: Extract common logic to apiPaweł Gronowski2023-01-112-3/+62
| | | | | | | | | | | | | | Extract logic that would need to be duplicated in both implementations of ImageService. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
* | add support for image inspect with containerd-integrationNicolas De Loof2023-01-051-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a squashed version of various PRs (or related code-changes) to implement image inspect with the containerd-integration; - add support for image inspect - introduce GetImageOpts to manage image inspect data in backend - GetImage to return image tags with details - list images matching digest to discover all tags - Add ExposedPorts and Volumes to the image returned - Refactor resolving/getting images - Return the image ID on inspect - consider digest and ignore tag when both are set - docker run --platform Signed-off-by: Djordje Lukic <djordje.lukic@docker.com> Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | manage image inspect data in backendNicolas De Loof2022-12-091-27/+6
| | | | | | | | | | | | | | | | This allows differentiating how the detailed data is collected between the containerd-integration code and the existing implementation. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | ImageService.ImageHistory(): pass contextSebastiaan van Stijn2022-12-092-2/+2
|/ | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* imageservice: Add context to various methodsNicolas De Loof2022-11-036-12/+12
| | | | | Co-authored-by: Paweł Gronowski <pawel.gronowski@docker.com> Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
* implement docker system dfNicolas De Loof2022-11-021-1/+1
| | | | Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
* Merge pull request #44224 from dperny/cluster-volumes-updateBrian Goff2022-10-252-7/+20
|\ | | | | Fix force-remove for cluster volumes
| * fix force remove for cluster volumesDrew Erny2022-10-122-7/+20
| | | | | | | | Signed-off-by: Drew Erny <derny@mirantis.com>
* | Volume prune: only prune anonymous volumes by defaultBrian Goff2022-10-041-0/+6
|/ | | | | | | | | | | | | | | This adds a new filter argument to the volume prune endpoint "all". When this is not set, or it is a false-y value, then only anonymous volumes are considered for pruning. When `all` is set to a truth-y value, you get the old behavior. This is an API change, but I think one that is what most people would want. Signed-off-by: Brian Goff <cpuguy83@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* api/server: fix empty-lines (revive)Sebastiaan van Stijn2022-09-283-3/+0
| | | | | | | | 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>
* Merge pull request #44111 from thaJeztah/remove_taggerSebastiaan van Stijn2022-09-272-28/+7
|\ | | | | api/server/backend/build: remove Tagger and NewTagger
| * api/server/backend/build: remove Tagger and NewTaggerSebastiaan van Stijn2022-09-072-28/+7
| | | | | | | | | | | | | | | | | | | | | | | | The Tagger was introduced in 0296797f0f39477d675128c93c1646b3186937ee, 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>
* | set ReadHeaderTimeout to address G112: Potential Slowloris Attack (gosec)Sebastiaan van Stijn2022-09-221-1/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | | 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>