Commit graph

44982 commits

Author SHA1 Message Date
Sebastiaan van Stijn
8a8202fcdc
pkg/chrootarchive: TestChrootTarUntar fix copy/paste mistake
Introduced in 3ac6394b80, which makes no mention
of a reason for extracting to the same directory as we created the archive from,
so I assume this was a copy/paste mistake and the path was meant to be "dest",
not "src".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-16 13:15:23 +02:00
Sebastiaan van Stijn
0955c88c2e
pkg/chrootarchive: use t.TempDir()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-16 13:02:45 +02:00
Sebastiaan van Stijn
30e5333ce3
registry: allow "allow-nondistributable-artifacts" for Docker Hub
Previously, Docker Hub was excluded when configuring "allow-nondistributable-artifacts".
With the updated policy announced by Microsoft, we can remove this restriction;
https://techcommunity.microsoft.com/t5/containers/announcing-windows-container-base-image-redistribution-rights/ba-p/3645201

There are plans to deprecated support for foreign layers altogether in the OCI,
and we should consider to make this option the default, but as that requires
deprecating the option (and possibly keeping an "opt-out" option), we can look
at that separately.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-16 01:08:49 +02:00
Sebastiaan van Stijn
d006242d73
Merge pull request #44251 from thaJeztah/pkg_dir_cleanup
pkg/directory: remove unused MoveToSubdir() utility, and some refactoring
2022-10-15 22:48:19 +02:00
Sebastiaan van Stijn
69f72417f4
pkg/idtools: remove CanAccess(), and move to daemon
The implementation of CanAccess() is very rudimentary, and should
not be used for anything other than a basic check (and maybe not
even for that). It's only used in a single location in the daemon,
so move it there, and un-export it to not encourage others to use
it out of context.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-15 22:42:39 +02:00
Sebastiaan van Stijn
ee34a8ac29
pkg/idtools: setPermissions() accept Identity as argument
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-15 22:42:39 +02:00
Sebastiaan van Stijn
bca90530fa
pkg/idtools: simplify if-statement
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-15 22:42:38 +02:00
Sebastiaan van Stijn
d68fa0382d
pkg/idtools: don't use system.Stat() on unix
Looks like we don't need the abstraction, so we can reduce the
dependency on pkg/system.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-15 22:42:35 +02:00
Sebastiaan van Stijn
1311687d0d
Merge pull request #44254 from thaJeztah/idtools_cleanup2
pkg/idtools: various cleanups
2022-10-15 22:42:09 +02:00
Sebastiaan van Stijn
081c00c7df
Merge pull request #44265 from thaJeztah/pkg_system_move_init_step1
pkg/system: cleanup, test-fixes and improvements and minor fixes
2022-10-15 21:28:13 +02:00
Sebastiaan van Stijn
b3a6ae71c1
Merge pull request #44266 from thaJeztah/pidfile_cleanup
pkg/pidfile: remove PIDFile type and cleanup
2022-10-15 21:26:17 +02:00
Sebastiaan van Stijn
43d6eb7173
pkg/pidfile: remove PIDFile type, rename New() to Write()
This type felt really redundant; `pidfile.New()` takes the path of the file to
create as an argument, so this is already known. The only thing the PIDFile
type provided was a `Remove()` method, which was just calling `os.Remove()` on
the path of the file.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-15 16:40:16 +02:00
Sebastiaan van Stijn
dd8983f96c
pkg/pidfile: reduce cyclomatic complexity, and small optimisation
Use bytes.TrimSpace instead of using the strings package, which is
more performant, and allows us to skip the intermediate variable.

Also combined some "if" statements to reduce cyclomatic complexity.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-15 15:11:40 +02:00
Sebastiaan van Stijn
4917bcc039
pkg/pidfile: don't ignore all errors when reading file
It's ok to ignore if the file doesn't exist, or if the file doesn't
have a PID in it, but we should produce an error if the file exists,
but we're unable to read it for other reasons.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-15 15:11:40 +02:00
Sebastiaan van Stijn
3ce2a7d026
pkg/pidfile: pkg/pidfile: use strconv instead of fmt.Sprintf(), and unconvert
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-15 15:11:40 +02:00
Sebastiaan van Stijn
a9fa147a92
daemon/logger/etwlogs: rewrite to use go-winio/pkg/etw
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-15 14:14:18 +02:00
Sebastiaan van Stijn
f058afc861
pkg/system: synchronize mkdirall() with latest os.MkDirAll()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-15 13:24:43 +02:00
Sebastiaan van Stijn
2e66c0b6f0
pkg/system: create SecurityAttribute only once (Windows)
The same attribute was generated for each path that was created, but always
the same, so instead of generating it in each iteration, generate it once,
and pass it to our mkdirall() implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-15 13:24:43 +02:00
Sebastiaan van Stijn
55ceb5047c
pkg/system: update volumePath regex to allow returning earlier
The regex only matched volume paths without a trailing path-separator. In cases
where a path would be passed with a trailing path-separator, it would depend on
further code in mkdirall to strip the trailing slash, then to perform the regex
again in the next iteration.

While regexes aren't ideal, we're already executing this one, so we may as well
use it to match those situations as well (instead of executing it twice), to
allow us to return early.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-15 13:24:43 +02:00
Sebastiaan van Stijn
cfef1b11e5
pkg/system: compile volume-path regex once, and update GoDoc
Ideally, we would construct this lazily, but adding a function and a
sync.Once felt like a bit "too much".

Also updated the GoDoc for some functions to better describe what they do.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-15 13:24:40 +02:00
Tianon Gravi
af10b35ba9
Merge pull request #44287 from thaJeztah/use_SetRecoveryActions
cmd/dockerd: use x/sys Service.SetRecoveryActions(), and update restart delay
2022-10-14 18:18:47 +00:00
Tianon Gravi
96155f626d
Merge pull request #44286 from thaJeztah/use_SetStdHandle
cmd/dockerd: use golang.org/x/sys/windows.SetStdHandle()
2022-10-14 18:15:52 +00:00
Tianon Gravi
6b2328e5cc
Merge pull request #44281 from thaJeztah/windows_filter_defer_in_loop
daemon/graphdriver/windows: Remove() don't use defer() in a loop
2022-10-14 18:14:32 +00:00
Tianon Gravi
82d563243f
Merge pull request #44280 from thaJeztah/windows_filter
daemon/graphdriver/windows: use go-winio.GetFileSystemType()
2022-10-14 18:12:42 +00:00
Cory Snider
40429857c3
Merge pull request #44296 from corhere/narrow-pkg-imports-validator
hack: allow pkg/ to import internal/ packages
2022-10-14 12:30:57 -04:00
Sebastiaan van Stijn
ec3c08d618
Merge pull request #44261 from thaJeztah/remove_deprecated_pkgs
remove aliases for deprecated pkg/urlutil, pkg/fsutils, pkg/pubsub
2022-10-14 01:35:01 +02:00
Sebastiaan van Stijn
c0309cfe69
Merge pull request #44284 from thaJeztah/replace_IsAnInteractiveSession
cmd/dockerd: replace deprecated windows.IsAnInteractiveSession()
2022-10-14 01:28:10 +02:00
Sebastiaan van Stijn
f29a3eb9c7
Merge pull request #44278 from thaJeztah/overlay_remove_kernel_check_override
daemon/graphdriver/overlay2: remove deprecated overrideKernelCheck
2022-10-13 22:35:25 +02:00
Cory Snider
264706f804 hack: allow pkg/ to import internal/ packages
The pkg-imports validation prevents reusable library packages from
depending on the whole daemon, accidentally or intentionally. The
allowlist is overly restrictive as it also prevents us from reusing code
in both pkg/ and daemon/ unless that code is also made into a reusable
library package under pkg/. Allow pkg/ packages to import internal/
packages which do not transitively depend on disallowed packages.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2022-10-13 16:21:10 -04:00
Drew Erny
3246db3755 fix force remove for cluster volumes
Signed-off-by: Drew Erny <derny@mirantis.com>
2022-10-12 11:31:00 -05:00
Sebastiaan van Stijn
624daf8d9e
Change restart delay for Windows service to 15s
Previously we waited for 60 seconds after the service faults to restart
it. However, there isn't much benefit to waiting this long. We expect
15 seconds to be a more reasonable delay.

Co-Authored-by: Kevin Parsons <kevpar@microsoft.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-12 09:52:51 +02:00
Sebastiaan van Stijn
3c585e6567
cmd/dockerd: use golang.org/x/sys Service.SetRecoveryActions()
This is the equivalent of the local implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-12 09:52:10 +02:00
Brian Goff
34f459423a Replace overlay2 mount reexec with in-proc impl
Building off insights from the great work Cory Snider has been doing,
this replaces a reexec with a much lower overhead implementation which
performs the `Chddir` in a new goroutine that is locked to a specific
thread with CLONE_FS unshared.
The thread is thrown away afterwards and the Chdir does effectively the
same thing as what the reexec was being used for.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-10-12 00:38:50 +00:00
Sebastiaan van Stijn
6176ab5901
cmd/dockerd: use golang.org/x/sys/windows.SetStdHandle()
golang.org/x/sys/windows now implements this, so we can use that
instead of a local implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-12 01:50:44 +02:00
Sebastiaan van Stijn
ffcddc908e
cmd/dockerd: replace deprecated windows.IsAnInteractiveSession()
The `IsAnInteractiveSession` was deprecated, and `IsWindowsService` is marked
as the recommended replacement.

For details, see 280f808b4a

> CL 244958 includes isWindowsService function that determines if a
> process is running as a service. The code of the function is based on
> public .Net implementation.
>
> IsAnInteractiveSession function implements similar functionality, but
> is based on an old Stackoverflow post., which is not as authoritative
> as code written by Microsoft for their official product.
>
> This change copies CL 244958 isWindowsService function into svc package
> and makes it public. The intention is that future users will prefer
> IsWindowsService to IsAnInteractiveSession.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-11 22:54:40 +02:00
Brian Goff
058010187b
Merge pull request #44271 from thaJeztah/pidfile_windows_cleanup
pkg/pidfile: windows: replace magic consts for golang.org/x/sys consts
2022-10-10 09:30:06 -07:00
Sebastiaan van Stijn
75bdbf02a6
daemon/graphdriver/windows: Remove() don't use defer() in a loop
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-10 17:48:45 +02:00
Sebastiaan van Stijn
90431d1857
daemon/graphdriver/windows: use go-winio.GetFileSystemType()
go-winio now defines this function, so we can consume that.

Note that there's a difference between the old implementation and the original
one (added in 1cb9e9b44e). The old implementation
had special handling for win32 error codes, which was removed in the go-winio
implementation in 0966e1ad56

As `go-winio.GetFileSystemType()` calls `filepath.VolumeName(path)` internally,
this patch also removes the `string(home[0])`, which is redundant, and could
potentially panic if an empty string would be passed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-10 16:22:05 +02:00
Sebastiaan van Stijn
e35700eb50
daemon/graphdriver/overlay2: remove deprecated overrideKernelCheck
Commit 955c1f881a (Docker v17.12.0) replaced
detection of support for multiple lowerdirs (as required by overlay2) to not
depend on the kernel version. The `overlay2.override_kernel_check` was still
used to print a warning that older kernel versions may not have full support.

After this, commit e226aea280 (Docker v20.10.0,
backported to v19.03.7) removed uses of the `overlay2.override_kernel_check`
option altogether, but we were still parsing it.

This patch changes the `parseOptions()` function to not parse the option,
printing a deprecation warning instead. We should change this to be an error,
but the  `overlay2.override_kernel_check` option was not deprecated in the
documentation, so keeping it around for one more release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-10 14:58:40 +02:00
Sebastiaan van Stijn
b43a7ac530
integration/plugin: remove deprecated overlay2.override_kernel_check
It's no longer used since e226aea280

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-10 14:46:08 +02:00
Samuel Karp
c9d2b7df77
Merge pull request #44222 from thaJeztah/godoc_instead_of_readme 2022-10-10 00:06:17 -07:00
Samuel Karp
620fbb5655
Merge pull request #44272 from thaJeztah/remove_solaris_leftovers 2022-10-09 23:56:31 -07:00
Sebastiaan van Stijn
de705907a5
client: remove solaris build-tag, simplify and gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-09 22:41:55 +02:00
Sebastiaan van Stijn
6fd2d4e772
integration: remove uses of pkg/system.Stat()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-09 17:55:42 +02:00
Sebastiaan van Stijn
0242fef89c
integration-cli: remove uses of pkg/system.Stat()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-09 17:55:13 +02:00
Sebastiaan van Stijn
402e0b58ca
testutil: use filepath.WalkDir instead of filepath.Walk
WalkDir is more performant as it doesn't perform an os.Lstat on every visited
file or directory.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-09 17:26:31 +02:00
Sebastiaan van Stijn
3db11af44b
libnetwork/drivers/overlay: use filepath.WalkDir instead of filepath.Walk
WalkDir is more performant as it doesn't perform an os.Lstat on every visited
file or directory.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-09 17:25:03 +02:00
Sebastiaan van Stijn
0ee5518e76
oci: use filepath.WalkDir instead of filepath.Walk
WalkDir is more performant as it doesn't perform an os.Lstat on every visited
file or directory.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-09 17:21:04 +02:00
Sebastiaan van Stijn
ec000ce555
pkg/archive: use filepath.WalkDir instead of filepath.Walk
WalkDir is more performant as it doesn't perform an os.Lstat on every visited
file or directory.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-09 17:12:04 +02:00
Sebastiaan van Stijn
f595434abc
daemon/graphdriver/devmapper: use filepath.WalkDir instead of filepath.Walk
WalkDir is more performant as it doesn't perform an os.Lstat on every visited
file or directory.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-09 17:04:44 +02:00