Commit graph

47200 commits

Author SHA1 Message Date
Sebastiaan van Stijn
b92cf68add
libnetwork/osl: remove Sandbox and Info interfaces
It only has a single implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 23:29:09 +02:00
Sebastiaan van Stijn
b63400fa4a
Merge pull request #46149 from thaJeztah/libnetwork_remove_interface_interface
libnetwork/osl: remove Interface Interface and other funny stories
2023-08-23 23:28:41 +02:00
Sebastiaan van Stijn
9668613541
Merge pull request #46303 from thaJeztah/TestDiskUsage_no_panic
TestDiskUsage: don't panic if results don't match
2023-08-23 21:07:02 +02:00
Sebastiaan van Stijn
c881360e88
libnetwork/osl: remove Interface.Master() as it's unused
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 20:13:15 +02:00
Sebastiaan van Stijn
b9bf407929
libnetwork/osl: remove Interface Interface
There's only one implementation; let's use that.
Also fixing a linting issue;

    libnetwork/osl/interface_linux.go:91:2: S1001: should use copy(to, from) instead of a loop (gosimple)
        for i, iface := range n.iFaces {
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 20:13:15 +02:00
Sebastiaan van Stijn
8631e69cdf
libnetwork/osl: remove Sandbox.InterfaceOptions() etc.
InterfaceOptions() returned an IfaceOptionSetter interface, which contained
"methods" that returned functional options. Such a construct could have made
sense if the functional options returned would (e.g.) be pre-propagated with
information from the Sandbox (network namespace), but none of that was the case.

There was only one implementation of IfaceOptionSetter (networkNamespace),
which happened to be the same as the only implementation of Sandbox, so remove
the interface as well, to help networkNamespace with its multi-personality
disorder.

This patch:

- removes Sandbox.Bridge() and makes it a regular function (WithIsBridge)
- removes Sandbox.Master() and makes it a regular function (WithMaster)
- removes Sandbox.MacAddress() and makes it a regular function (WithMACAddress)
- removes Sandbox.Address() and makes it a regular function (WithIPv4Address)
- removes Sandbox.AddressIPv6() and makes it a regular function (WithIPv6Address)
- removes Sandbox.LinkLocalAddresses() and makes it a regular function (WithLinkLocalAddresses)
- removes Sandbox.Routes() and makes it a regular function (WithRoutes)
- removes Sandbox.InterfaceOptions().
- removes the IfaceOptionSetter interface.

Note that the IfaceOption signature was changes as well to allow returning
an error. This is not currently used, but will be used for some options
in the near future, so adding that in preparation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 20:13:15 +02:00
Sebastiaan van Stijn
f3d29db6a2
libnetwork/osl: remove Sandbox.NeighborOptions() etc.
NeighborOptions() returned an NeighborOptionSetter interface, which
contained "methods" that returned functional options. Such a construct
could have made sense if the functional options returned would (e.g.)
be pre-propagated with information from the Sandbox (network namespace),
but none of that was the case.

There was only one implementation of NeighborOptionSetter (networkNamespace),
which happened to be the same as the only implementation of Sandbox, so
remove the interface as well, to help networkNamespace with its multi-personality
disorder.

This patch:

- removes Sandbox.LinkName() and makes it a regular function (WithLinkName)
- removes Sandbox.Family() and makes it a regular function (WithFamily)
- removes Sandbox.NeighborOptions().
- removes the NeighborOptionSetter interface

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 20:13:15 +02:00
Sebastiaan van Stijn
a365fb0e9d
libnetwork: move more osl.Sandbox related code to Linux-only files
osl.NewSandbox() always returns a nil interface on Windows (and other non-Linux
platforms). This means that any code that these fields are always nil, and
any code using these fields must be considered Linux-only.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 20:13:15 +02:00
Sebastiaan van Stijn
95abde479a
libnetwork: implement Controller.setupOSLSandbox
osl.NewSandbox() always returns a nil interface on Windows (and other non-Linux
platforms). This means that any code that these fields are always nil, and
any code using these fields must be considered Linux-only;

- libnetwork/Controller.defOsSbox
- libnetwork/Sandbox.osSbox

Ideally, these fields would live in Linux-only files, but they're referenced
in various platform-neutral parts of the code, so let's start with moving
the initialization code to Linux-only files.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 20:13:15 +02:00
Sebastiaan van Stijn
35456d2eb1
libnetwork/osl: add godoc to networkNamespace
Copying the descriptions from the Sandbox, Info, NeighborOptionSetter,
and IfaceOptionSetter interfaces that it implements.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 20:13:14 +02:00
Sebastiaan van Stijn
0e3b2ec267
Merge pull request #46245 from thaJeztah/firewalld_dont_fail_on_removal
libnetwork/iptables: ProgramChain: don't fail if interface not found
2023-08-23 19:58:18 +02:00
Sebastiaan van Stijn
53afd2ae9f
Merge pull request #46201 from thaJeztah/daemon_updateSandboxNetworkSettings_err
libnetwork: remove unused err-return, and minor refactor around Sandbox creating
2023-08-23 19:56:58 +02:00
Sebastiaan van Stijn
d74f0a47de
Merge pull request #46207 from thaJeztah/daemon_cleanup_withLibnetwork
daemon: withLibnetwork(): return early if networking is disabled
2023-08-23 19:56:01 +02:00
Sebastiaan van Stijn
71f4916357
Merge pull request #46246 from thaJeztah/fix_TestFirewalldInit
libnetwork/iptables: fix TestFirewalldInit
2023-08-23 19:38:08 +02:00
Sebastiaan van Stijn
4b0d38de06
TestDiskUsage: don't panic if results don't match
This test is currently failing with containerd-integration, which should
be looked into, but let's start with preventing it from panicking, to make
the test-failures less noisy;

        --- FAIL: TestDiskUsage/after_container.Run (0.26s)
    panic: runtime error: index out of range [0] with length 0 [recovered]
        panic: runtime error: index out of range [0] with length 0

    goroutine 280 [running]:
    testing.tRunner.func1.2({0xb07a00, 0x40002006a8})
        /usr/local/go/src/testing/testing.go:1526 +0x1c8
    testing.tRunner.func1()
        /usr/local/go/src/testing/testing.go:1529 +0x364
    panic({0xb07a00, 0x40002006a8})
        /usr/local/go/src/runtime/panic.go:884 +0x1f4
    github.com/docker/docker/integration/system.TestDiskUsage.func3(0x0?, {0x0, {0x14ea4a8, 0x0, 0x0}, {0x14ea4a8, 0x0, 0x0}, {0x14ea4a8, 0x0, ...}, ...})
        /go/src/github.com/docker/docker/integration/system/disk_usage_test.go:82 +0x7e4
    github.com/docker/docker/integration/system.TestDiskUsage.func4(0x4000235c80?)
        /go/src/github.com/docker/docker/integration/system/disk_usage_test.go:118 +0x8c

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 19:15:21 +02:00
Sebastiaan van Stijn
9b9348ce86
Merge pull request #46284 from vvoland/c8d-legacybuilder-fix-from-scratch
c8d: Fix building Dockerfiles that have `FROM scratch`
2023-08-23 18:57:53 +02:00
Sebastiaan van Stijn
e2fc596de4
Merge pull request #46293 from rumpl/fix-platform-check
Don't return lease not found errors on platform mismatch
2023-08-23 15:55:04 +02:00
Sebastiaan van Stijn
20b770237c
daemon/network: Settings: move sandbox fields together
Just a minor nit; let's move these fields together.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 14:26:58 +02:00
Sebastiaan van Stijn
405f571ae8
daemon: updateSandboxNetworkSettings: remove unused error-return
This function never returns an error, so let's remove the error-return,
and give it a slightly more to-the-point name.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 14:26:58 +02:00
Sebastiaan van Stijn
2eccf0e8d1
libnetwork: Controller.NewSandbox: don't generate ID if not used
Windows uses the container-iD as ID for sandboxes, so it's not needed to
generate an ID  when running on Windows.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 14:26:53 +02:00
Sebastiaan van Stijn
389b21a341
Merge pull request #46262 from thaJeztah/libnetwork_resolv_cleanups
libnetwork: resolve: assorted cleanups
2023-08-23 14:22:33 +02:00
Sebastiaan van Stijn
13c4eaea92
Merge pull request #46205 from thaJeztah/libnetwork_noexecroot
libnetwork: cleanup SetBasePath, un-export SetExternalKey and other cleanups
2023-08-23 14:21:30 +02:00
Sebastiaan van Stijn
8f0b62e4d9
Merge pull request #46226 from thaJeztah/conntrack_reduce_noise
libnetwork/iptables: reduce DeleteConntrackEntriesXX debug logs
2023-08-23 14:19:53 +02:00
Sebastiaan van Stijn
bb5813a93d
Merge pull request #46240 from thaJeztah/libnetwork_named_returns
libnetwork: Controller.NewNetwork, Controller.NewSandbox: use named error-return
2023-08-23 14:19:27 +02:00
Sebastiaan van Stijn
cec49ba976
Merge pull request #46247 from thaJeztah/libnetwork_unexport_ZoneSettings
libnetwork/iptables: un-export ZoneSettings, and slight refactor
2023-08-23 14:17:38 +02:00
Sebastiaan van Stijn
0e7186af95
Merge pull request #46278 from thaJeztah/libnetwork_remove_InterfaceInfo_interface
libnetwork: remove InterfaceInfo interface
2023-08-23 14:16:23 +02:00
Sebastiaan van Stijn
8c3b14ee85
Merge pull request #46264 from thaJeztah/libnetwork_sandbox_split_options
libnetwork: move all SandboxOptions to a separate file
2023-08-23 14:13:52 +02:00
Sebastiaan van Stijn
77539e7bc7
Merge pull request #46279 from thaJeztah/libnetwork_remove_sandbox_info
libnetwork/osl: remove Sandbox.Info()
2023-08-23 14:13:26 +02:00
Sebastiaan van Stijn
79fa17e181
Merge pull request #46298 from rumpl/c8d-test-skip-graphdriver
test: Skip graph driver tests when using containerd snapshotters
2023-08-23 14:00:58 +02:00
Sebastiaan van Stijn
18c5d863d6
Merge pull request #46296 from thaJeztah/replace_dockerignore
replace dockerfile/dockerignore with patternmatcher/ignorefile
2023-08-23 10:55:14 +02:00
Djordje Lukic
6cbe06ff3f
test: Skip graph driver tests when using containerd snapshotters
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-08-23 09:48:27 +02:00
Sebastiaan van Stijn
3553b4c684
replace dockerfile/dockerignore with patternmatcher/ignorefile
The BuildKit dockerignore package was integrated in the patternmatcher
repository / module. This patch updates our uses of the BuildKit package
with its new location.

A small local change was made to keep the format of the existing error message,
because the "ignorefile" package is slightly more agnostic in that respect
and doesn't include ".dockerignore" in the error message.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 00:53:18 +02:00
Sebastiaan van Stijn
a479b287c7
vendor: github.com/moby/patternmatcher v0.6.0
- integrate frontend/dockerfile/dockerignore from buildkit

full diff: https://github.com/moby/patternmatcher/compare/v0.5.0...v0.6.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 00:50:05 +02:00
Sebastiaan van Stijn
70ae5c13ea
Merge pull request #44704 from thaJeztah/api_hostconfig_RestartPolicyMode_enum
api/types/container: add RestartPolicyMode type and enum
2023-08-22 22:31:51 +02:00
Bjorn Neergaard
8383430946
Merge pull request #45759 from akerouanton/validate-ipam-config
Validate IPAM config before handing it over to libnetwork
2023-08-22 13:58:28 -06:00
Paweł Gronowski
bedcc94de4
daemon: Handle NotFound when deleting container lease
If the lease doesn't exit (for example when creating the container
failed), just ignore the not found error.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-08-22 17:32:22 +02:00
Paweł Gronowski
dfaff9598c
c8d/run: Allow running container without image
This allows the legacy builder to apply changes to the `FROM scratch`
layer.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-08-22 17:32:20 +02:00
Paweł Gronowski
eb56493f4e
c8d/commit: Don't produce an empty layer
If the diff is empty and don't produce an empty layer.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-08-22 17:32:18 +02:00
Albin Kerouanton
3e8af0817a
ipam: Replace ChildSubnet with parent Subnet when its mask is bigger
Prior to moby/moby#44968, libnetwork would happily accept a ChildSubnet
with a bigger mask than its parent subnet. In such case, it was
producing IP addresses based on the parent subnet, and the child subnet
was not allocated from the address pool.

This commit automatically fixes invalid ChildSubnet for networks stored
in libnetwork's datastore.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-08-22 17:12:06 +02:00
Albin Kerouanton
4f47013feb
api: Validate IPAM config before creating a network
Currently, IPAM config is never validated by the API. Some checks
are done by the CLI, but they're not exhaustive. And some of these
misconfigurations might be caught early by libnetwork (ie. when the
network is created), and others only surface when connecting a container
to a misconfigured network. In both cases, the API would return a 500.

Although the `NetworkCreate` endpoint might already return warnings,
these are never displayed by the CLI. As such, it was decided during a
maintainer's call to return validation errors _for all API versions_.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-22 17:11:54 +02:00
Sebastiaan van Stijn
2be118379e
api/types/container: add RestartPolicyMode type and enum
Also move the validation function to live with the type definition,
which allows it to be used outside of the daemon as well.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-22 16:40:57 +02:00
Djordje Lukic
b8ff8ea58e
Don't return an error if the lease is not found
If the image for the wanted platform doesn't exist then the lease
doesn't exist either. Returning this error hides the real error, so
let's not return it.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-08-22 14:52:41 +02:00
Sebastiaan van Stijn
331854a126
Merge pull request #46239 from thaJeztah/vars_collide
libnetwork:  rename vars that collided
2023-08-22 10:50:35 +02:00
Sebastiaan van Stijn
fa517bb420
Merge pull request #46271 from neersighted/bin_image_meta
bin-image: metadata cleanup, take two
2023-08-21 21:43:04 +02:00
Sebastiaan van Stijn
5d15da8290
Merge pull request #46206 from thaJeztah/libnetwork_no_walk
libnetwork: implement Controller.GetSandbox, remove Controller.WalkSandboxes and related code
2023-08-21 21:21:16 +02:00
Sebastiaan van Stijn
3ffa00909d
Merge pull request #46285 from thaJeztah/gha_report_timeout
gha: set 10-minute timeout on "report" actions
2023-08-21 20:19:39 +02:00
Bjorn Neergaard
764419ed4e
Merge pull request #45534 from polarathene/fix/config-init-limits
fix: Normalize `RLIMIT_NOFILE` to sensible defaults
2023-08-21 12:09:38 -06:00
Brian Goff
fc15e08a6c
Merge pull request #46137 from thaJeztah/v1_deprecation 2023-08-21 10:51:23 -07:00
Sebastiaan van Stijn
dff53a02ef
libnetwork: remove Controller.Sandboxes as it's no longer used
The Controller.Sandboxes method was used by some SandboxWalkers. Now
that those have been removed, there are no longer any consumers of this
method, so let's remove it for now.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-21 19:08:43 +02:00
Sebastiaan van Stijn
d6f340e784
gha: set 10-minute timeout on "report" actions
I had a CI run fail to "Upload reports":

    Exponential backoff for retry #1. Waiting for 4565 milliseconds before continuing the upload at offset 0
    Finished backoff for retry #1, continuing with upload
    Total file count: 211 ---- Processed file #160 (75.8%)
    ...
    Total file count: 211 ---- Processed file #164 (77.7%)
    Total file count: 211 ---- Processed file #164 (77.7%)
    Total file count: 211 ---- Processed file #164 (77.7%)
    A 503 status code has been received, will attempt to retry the upload
    ##### Begin Diagnostic HTTP information #####
    Status Code: 503
    Status Message: Service Unavailable
    Header Information: {
      "content-length": "592",
      "content-type": "application/json; charset=utf-8",
      "date": "Mon, 21 Aug 2023 14:08:10 GMT",
      "server": "Kestrel",
      "cache-control": "no-store,no-cache",
      "pragma": "no-cache",
      "strict-transport-security": "max-age=2592000",
      "x-tfs-processid": "b2fc902c-011a-48be-858d-c62e9c397cb6",
      "activityid": "49a48b53-0411-4ff3-86a7-4528e3f71ba2",
      "x-tfs-session": "49a48b53-0411-4ff3-86a7-4528e3f71ba2",
      "x-vss-e2eid": "49a48b53-0411-4ff3-86a7-4528e3f71ba2",
      "x-vss-senderdeploymentid": "63be6134-28d1-8c82-e969-91f4e88fcdec",
      "x-frame-options": "SAMEORIGIN"
    }
    ###### End Diagnostic HTTP information ######
    Retry limit has been reached for chunk at offset 0 to https://pipelinesghubeus5.actions.githubusercontent.com/Y2huPMnV2RyiTvKoReSyXTCrcRyxUdSDRZYoZr0ONBvpl5e9Nu/_apis/resources/Containers/8331549?itemPath=integration-reports%2Fubuntu-22.04-systemd%2Fbundles%2Ftest-integration%2FTestInfoRegistryMirrors%2Fd20ac12e48cea%2Fdocker.log
    Warning: Aborting upload for /tmp/reports/ubuntu-22.04-systemd/bundles/test-integration/TestInfoRegistryMirrors/d20ac12e48cea/docker.log due to failure
    Error: aborting artifact upload
    Total file count: 211 ---- Processed file #165 (78.1%)
    A 503 status code has been received, will attempt to retry the upload
    Exponential backoff for retry #1. Waiting for 5799 milliseconds before continuing the upload at offset 0

As a result, the "Download reports" continued retrying:

    ...
    Total file count: 1004 ---- Processed file #436 (43.4%)
    Total file count: 1004 ---- Processed file #436 (43.4%)
    Total file count: 1004 ---- Processed file #436 (43.4%)
    An error occurred while attempting to download a file
    Error: Request timeout: /Y2huPMnV2RyiTvKoReSyXTCrcRyxUdSDRZYoZr0ONBvpl5e9Nu/_apis/resources/Containers/8331549?itemPath=integration-reports%2Fubuntu-20.04%2Fbundles%2Ftest-integration%2FTestCreateWithDuplicateNetworkNames%2Fd47798cc212d1%2Fdocker.log
        at ClientRequest.<anonymous> (/home/runner/work/_actions/actions/download-artifact/v3/dist/index.js:3681:26)
        at Object.onceWrapper (node:events:627:28)
        at ClientRequest.emit (node:events:513:28)
        at TLSSocket.emitRequestTimeout (node:_http_client:839:9)
        at Object.onceWrapper (node:events:627:28)
        at TLSSocket.emit (node:events:525:35)
        at TLSSocket.Socket._onTimeout (node:net:550:8)
        at listOnTimeout (node:internal/timers:559:17)
        at processTimers (node:internal/timers:502:7)
    Exponential backoff for retry #1. Waiting for 5305 milliseconds before continuing the download
    Total file count: 1004 ---- Processed file #436 (43.4%)

And, it looks like GitHub doesn't allow cancelling the job, possibly
because it is defined with `if: always()`?

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-21 18:52:52 +02:00