Commit Graph

399 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
f9c4601760 volume/mounts: MountPoint.Setup: rename output-var, and simplify err-handling
Rename the ouput variable to prevent accidental shadowing, and simplify how
we check for the `syscall.ENOTDIR` error; `errors.Is()` will already unwrap
the error, so no type-casting is needed;

    package main

    import (
        "errors"
        "fmt"
        "os"
        "syscall"
    )

    func main() {
        err := &os.PathError{Op: "mkdir", Path: "/hello/world", Err: syscall.ENOTDIR}
        if errors.Is(err, syscall.ENOTDIR) {
            fmt.Println(err)
        }
    }

While at it, also improve the code-comment that outlines the intent.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:11 +02:00
Sebastiaan van Stijn
6ac3afe483 volume: remove/rename err-returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:11 +02:00
Sebastiaan van Stijn
ea7152e493 volume/local: use t.TempDir
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 16:07:56 +02:00
Sebastiaan van Stijn
4b41198e3c volume/mounts: use t.TempDir
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 16:07:56 +02:00
Sebastiaan van Stijn
2b869baea3 volume/service: use t.TempDir
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 16:07:56 +02:00
Sebastiaan van Stijn
88f6dd72e5 volume/service: rename interface that collided with vars
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 16:07:56 +02:00
Sebastiaan van Stijn
d8a5e8928b replace uses of idtools.MkdirAllAndChown, MkdirAllAndChownNew
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 12:04:42 +02:00
Sebastiaan van Stijn
6422ff2804 deprecate pkg/atomicwriter, migrate to github.com/moby/sys/atomicwriter
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-04 23:07:00 +02:00
Paweł Gronowski
1c63f3983b volume/service: adjust "gotest.tools/v3/assert/cmp" import alias
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-03 19:11:46 +01:00
Sebastiaan van Stijn
827f84d3ef volume/mounts: parseMountSpec: make switch exhaustive (exhaustive)
Adding a `default` statement so that disabling the "default-signifies-exhaustive"
linter option will  make it show up.

    volume/mounts/linux_parser.go:353:2: missing cases in switch of type mount.Type: mount.TypeNamedPipe, mount.TypeCluster (exhaustive)
        switch cfg.Type {
        ^
    volume/mounts/windows_parser.go:392:2: missing cases in switch of type mount.Type: mount.TypeTmpfs, mount.TypeCluster, mount.TypeImage (exhaustive)
        switch cfg.Type {
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:51 +01:00
Paweł Gronowski
02563f2805 Merge pull request #48798 from LaurentGoderre/implement-30449-image-mount
Implement mount from image
2025-02-05 18:04:22 +00:00
Laurent Goderre
90aea3b85f Add image subpath mounting functionality
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2025-02-04 21:32:04 -05:00
Sebastiaan van Stijn
294df1c447 volumes/service: OpErr: implement go1.13 unwrapper
This error implemented the Causer interface, but did not implement
the go1.13 unwrapper, which could prevent errors from being matched.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 18:10:51 +01:00
Laurent Goderre
8c58934106 Implement mount from image
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2025-01-31 10:34:27 -05:00
Sebastiaan van Stijn
7864454792 pkg/ioutils: move atomic file-writers to a separate (pkg/atomicwriter) package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 10:36:32 +01:00
Sebastiaan van Stijn
690e00733e volume/mounts: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:34 +01:00
Aleksa Sarai
caae3c051d tests: migrate to assert.ErrorContains when possible
If we have an error type that we're checking a substring against, we
should really be checking using ErrorContains to indicate the right
semantics to assert.

Mostly done using these transforms:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r 'assert.Assert(t, is.ErrorContains(e, s)) -> assert.ErrorContains(t, e, s)'
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r 'assert.Assert(t, is.Contains(err.Error(), s)) -> assert.ErrorContains(t, err, s)'
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r 'assert.Check(t, is.Contains(err.Error(), s)) -> assert.Check(t, is.ErrorContains(err, s))'

As well as some small fixups to helpers that were doing
strings.Contains explicitly.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-11-22 23:59:21 +11:00
Aleksa Sarai
1b470d15d8 tests: migrate away from assert.Assert(v == nil)
If a values is non-nil when we don't expect it, it would be quite
helpful to get an error message explaining what happened.

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, a == nil) -> assert.Assert(t, is.Nil(a))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, a == nil) -> assert.Check(t, is.Nil(a))"

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-11-22 23:59:20 +11:00
Aleksa Sarai
0553d3d994 tests: migrate away from assert.Assert(err == nil)
Unfortunately, gofmt doesn't know about types so it was necessary to
find all of the err == nil statements through trial and error. Note that
there is no is.NilError, so for assert.Check(t, err == nil) we need to
switch to just doing assert.Check(t, err). If err is an error type, this
is equivalent (and there isn't another trivial way of doing it). Here
are the full set of rules used:

Generic "err == nil":

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, err == nil) -> assert.NilError(t, err)"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, err == nil) -> assert.Check(t, err)"

Generic, but with a different variable name:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, sr.err == nil) -> assert.NilError(t, sr.err)"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, sr.err == nil) -> assert.Check(t, sr.err)"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, err2 == nil) -> assert.NilError(t, err2)"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, err2 == nil) -> assert.Check(t, err2)"

JSON-related error assertions:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, json.Unmarshal(a, b) == nil) -> assert.NilError(t, json.Unmarshal(a, b))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, json.Unmarshal(a, b) == nil) -> assert.Check(t, json.Unmarshal(a, b))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, json.NewDecoder(a).Decode(b) == nil) -> assert.NilError(t, json.NewDecoder(a).Decode(b))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, json.NewDecoder(a).Decode(b) == nil) -> assert.Check(t, json.NewDecoder(a).Decode(b))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, json.NewEncoder(a).Encode(b) == nil) -> assert.NilError(t, json.NewEncoder(a).Encode(b))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, json.NewEncoder(a).Encode(b) == nil) -> assert.Check(t, json.NewEncoder(a).Encode(b))"

Process-related error assertions:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, a.Start() == nil) -> assert.NilError(t, a.Start())"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, a.Start() == nil) -> assert.Check(t, a.Start())"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, a.Kill() == nil) -> assert.NilError(t, a.Kill())"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, a.Kill() == nil) -> assert.Check(t, a.Kill())"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, a.Signal(b) == nil) -> assert.NilError(t, a.Signal(b))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, a.Signal(b) == nil) -> assert.Check(t, a.Signal(b))"

waitInspect:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, waitInspect(a, b, c, d) == nil) -> assert.NilError(t, waitInspect(a, b, c, d))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, waitInspect(a, b, c, d) == nil) -> assert.Check(t, waitInspect(a, b, c, d))"

File closing error assertions:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, a.Close() == nil) -> assert.NilError(t, a.Close())"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, a.Close() == nil) -> assert.Check(t, a.Close())"

mount.MakeRShared:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, mount.MakeRShared(a) == nil) -> assert.NilError(t, mount.MakeRShared(a))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, mount.MakeRShared(a) == nil) -> assert.Check(t, mount.MakeRShared(a))"

daemon.SwarmLeave:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, d.SwarmLeave(a, b, c) == nil) -> assert.NilError(t, d.SwarmLeave(a, b, c))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, d.SwarmLeave(a, b, c) == nil) -> assert.Check(t, d.SwarmLeave(a, b, c))"

os.MkdirAll:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, os.MkdirAll(a, b) == nil) -> assert.NilError(t, os.MkdirAll(a, b))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, os.MkdirAll(a, b) == nil) -> assert.Check(t, os.MkdirAll(a, b))"

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-11-22 23:59:20 +11:00
Sebastiaan van Stijn
821d974789 volume/testutils: simplify fakePluginGetter
Embed the interface to simplify the mock

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-21 11:33:19 +01:00
Sebastiaan van Stijn
67d91e7622 volume/local: remove redundant capturing of loop vars (copyloopvar)
volume/local/local_linux_test.go:232:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    volume/local/local_linux_test.go:316:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:16 +01:00
Sebastiaan van Stijn
3a34264129 volume/mounts: remove redundant capturing of loop vars (copyloopvar)
volume/mounts/lcow_parser_test.go:260:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    volume/mounts/linux_parser_test.go:253:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    volume/mounts/parser_test.go:82:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    volume/mounts/validate_test.go:59:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    volume/mounts/validate_test.go:117:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    volume/mounts/windows_parser_test.go:283:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:14 +01:00
Sebastiaan van Stijn
222b3a9e5c Merge pull request #48834 from vvoland/gounits-alias
all: Remove redundant `units` alias for `go-units`
2024-11-07 19:37:19 +01:00
Paweł Gronowski
c0045476b8 all: Remove redundant units alias for go-units
The alias is not needed as the package is already named `units`.
It was also not aliases consistently across the project.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-07 15:55:16 +01:00
Sebastiaan van Stijn
c8e085b56a volume/mounts: TestConvertTmpfsOptions: fix implicit memory aliasing (gosec)
volume/mounts/linux_parser_test.go:335:38: G601: Implicit memory aliasing in for loop. (gosec)
            data, err := p.ConvertTmpfsOptions(&tc.opt, tc.readOnly)
                                               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:50:20 +01:00
Sebastiaan van Stijn
4ade1b1ac8 Merge pull request #48775 from thaJeztah/anonymous_use_default_driver
volume/service: use local driver as default for anonymous volumes
2024-10-28 16:47:10 +01:00
Sebastiaan van Stijn
c1652ab357 volume/service: use local driver as default for anonymous volumes
Anonymous volumes get a unique, 64-character name, and intended to be a new
volume (not an existing one). While it's theoretically possible for this name
to exist in other volume drivers, this would be very unlikely, so we should
not need to check other drivers to have this volume.

This patch uses the default ("local") volume-driver for anonymous volumes,
unless the user explicitly asked for a specific driver to use. Setting the
driver skips looking up existing volumes in other drivers.

Before this patch:

    DEBU[2024-10-26T15:51:12.681547126Z] container mounted via snapshotter: /var/lib/docker/rootfs/overlayfs/7e947822249514b6239657a0c54d091d90e0fed4b09da472f3f6258f2b4920bc  container=7e947822249514b6239657a0c54d091d90e0fed4b09da472f3f6258f2b4920bc
    DEBU[2024-10-26T15:51:12.681616084Z] Creating anonymous volume                     volume-name=fd46d688247c3e7d39d9bae4532d6b2dc69e82e354c4a3bf305c50bbfb9ebc6c
    DEBU[2024-10-26T15:51:12.681638959Z] Probing all drivers for volume                volume-name=fd46d688247c3e7d39d9bae4532d6b2dc69e82e354c4a3bf305c50bbfb9ebc6c
    DEBU[2024-10-26T15:51:12.681688917Z] Registering new volume reference              driver=local volume-name=fd46d688247c3e7d39d9bae4532d6b2dc69e82e354c4a3bf305c50bbfb9ebc6c

With this patch:

    DEBU[2024-10-27T17:28:28.574956716Z] container mounted via snapshotter: /var/lib/docker/rootfs/overlayfs/7085cb3991b61cbb79edffcb6980ad926f99f6b6b3be617cc3e3b92673cc2eb8  container=7085cb3991b61cbb79edffcb6980ad926f99f6b6b3be617cc3e3b92673cc2eb8
    DEBU[2024-10-27T17:28:28.575002549Z] Creating anonymous volume                     driver=local volume-name=db11c053566362499103213542402af2770a6622fe7a90b9a938a5bed84ca937
    DEBU[2024-10-27T17:28:28.575016299Z] Registering new volume reference              driver=local volume-name=db11c053566362499103213542402af2770a6622fe7a90b9a938a5bed84ca937

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-28 09:11:05 +01:00
Sebastiaan van Stijn
31880791a4 volumes/mounts: test the actual MountConfig returned
Make sure we're asserting the right fields to be propagated, as there
are some fields that shadow top-level fields (by design).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 21:51:25 +01:00
Sebastiaan van Stijn
275609eb37 volumes/mounts: test the actual error returned
Update the tests to have a match for the actual error string returned.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 20:40:59 +01:00
Sebastiaan van Stijn
6b0c4b5216 volumes/mounts: don't set "expected" values for fail cases
ParseMountRaw returns a nil value on error, so there's nothing to
check other than it not returning a value.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 19:07:56 +01:00
Sebastiaan van Stijn
e141be8752 volumes/mounts: remove backticks from test logs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 18:53:36 +01:00
Sebastiaan van Stijn
be7d57367b volumes/mounts: remove backticks from errors
These errors used a backtick, which is not commonly used in our errors.
Change them to use single quotes instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 18:46:18 +01:00
Sebastiaan van Stijn
0b290094b5 volume/mounts: windowsParser.ConvertTmpfsOptions don't use runtime.GOOS
These parsers can be compiled and used cross-platform, but follow platform-
specific semantics. Remove the use of runtime.GOOS, as it would result in
confusing errors ("linux does not support tmpfs").

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 18:44:11 +01:00
Sebastiaan van Stijn
352b4ff2f1 volume: VolumesService.Create: fix log-level for debug logs
These log-entries were added in 10d57fde44,
but it looks like I accidentally left them as Error-logs following some
debugging (whoops!).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-26 17:38:58 +02:00
Sebastiaan van Stijn
10d57fde44 volume/mounts: fix anonymous volume not being labeled
`Parser.ParseMountRaw()` labels anonymous volumes with a `AnonymousLabel` label
(`com.docker.volume.anonymous`) label based on whether a volume has a name
(named volume) or no name (anonymous) (see [1]).

However both `VolumesService.Create()` (see [1]) and `Parser.ParseMountRaw()`
(see [2], [3]) were generating a random name for anonymous volumes. The latter
is called before `VolumesService.Create()` is called, resulting in such volumes
not being labeled as anonymous.

Generating the name was originally done in Create (fc7b904dce),
but duplicated in b3b7eb2723 with the introduction
of the new Mounts field in HostConfig. Duplicating this effort didn't have a
real effect until (`Create` would just skip generating the name), until
618f26ccbc introduced the `AnonymousLabel` in
(v24.0.0, backported to v23.0.0).

Parsing generally should not fill in defaults / generate names, so this patch;

- Removes generating volume names from  `Parser.ParseMountRaw()`
- Adds a debug-log entry to `VolumesService.Create()`
- Touches up some logs to use structured logs for easier correlating logs

With this patch applied:

    docker run --rm --mount=type=volume,target=/toto hello-world

    DEBU[2024-10-24T22:50:36.359990376Z] creating anonymous volume                     volume-name=0cfd63d4df363571e7b3e9c04e37c74054cc16ff1d00d9a005232d83e92eda02
    DEBU[2024-10-24T22:50:36.360069209Z] probing all drivers for volume                volume-name=0cfd63d4df363571e7b3e9c04e37c74054cc16ff1d00d9a005232d83e92eda02
    DEBU[2024-10-24T22:50:36.360341209Z] Registering new volume reference              driver=local volume-name=0cfd63d4df363571e7b3e9c04e37c74054cc16ff1d00d9a005232d83e92eda02

[1]: 032721ff75/volume/service/service.go (L72-L83)
[2]: 032721ff75/volume/mounts/linux_parser.go (L330-L336)
[3]: 032721ff75/volume/mounts/windows_parser.go (L394-L400)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-25 01:57:22 +02:00
Sebastiaan van Stijn
4e840b9e29 volume/service: change some logs to use structured logs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-16 12:48:44 +02:00
Nathan Baulch
59eba0ae13 Fix typos
Signed-off-by: Nathan Baulch <nathan.baulch@gmail.com>
2024-09-06 21:53:09 +10:00
Sebastiaan van Stijn
f434cdd14a volume/testutils: fix non-constant format string in call (govet)
volume/testutils/testutils.go:98:26: printf: non-constant format string in call to fmt.Errorf (govet)
            return nil, fmt.Errorf(opts["error"])
                                   ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:23:40 +02:00
Cory Snider
5e64a7a003 volume/service: switch to Go 1.19 atomics
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-08 11:09:56 -04:00
Sebastiaan van Stijn
3a3bb1cb50 pkg/directory: deprecate, and move to internal
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 20:44:31 +02:00
Sebastiaan van Stijn
81be279c6b daemon/logger, volume/drivers: remove redundant import-aliases
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-30 19:22:17 +02:00
Aleksa Sarai
b4c20da143 volume: use AtomicWriteFile to save volume options
If the system (or Docker) crashes while saivng the volume options, on
restart the daemon will error out when trying to read the options file
because it doesn't contain valid JSON.

In such a crash scenario, the new volume will be treated as though it
has the default options configuration. This is not ideal, but volumes
created on very old Docker versions (pre-1.11[1], circa 2016) do not
have opts.json and so doing some kind of cleanup when loading the volume
store (even if we take care to only delete empty volumes) could delete
existing volumes carried over from very old Docker versions that users
would not expect to disappear.

Ultimately, if a user creates a volume and the system crashes, a volume
that has the wrong config is better than Docker not being able to start.

[1]: commit b05b237075 ("Support mount opts for `local` volume driver")

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-06-19 18:57:51 +10:00
Arash Deshmeh
dd1ca95ef9 Add exec option to API TmpfsOptions
Includes two commits from Arash Deshmeh:

add exec option to API TmpfsOptions and the related volume functions

Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>

feature: daemon handles tmpfs mounts exec option

Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>

Updated by Drew Erny

Signed-off-by: Drew Erny <derny@mirantis.com>
2024-06-14 12:11:20 -05:00
Sebastiaan van Stijn
162ef4f8d1 api/types: move VolumesPruneReport to api/types/volume
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:21:24 +02:00
Paweł Gronowski
294fc9762e volume: Don't decrement refcount below 0
With both rootless and live restore enabled, there's some race condition
which causes the container to be `Unmount`ed before the refcount is
restored.

This makes sure we don't underflow the refcount (uint64) when
decrementing it.

The root cause of this race condition still needs to be investigated and
fixed, but at least this unflakies the `TestLiveRestore`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-03-07 20:42:20 +01:00
Paweł Gronowski
05b883bdc8 mounts/validate: Don't check source exists with CreateMountpoint
Don't error out when mount source doesn't exist and mounts has
`CreateMountpoint` option enabled.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-02-23 11:20:55 +01:00
Paweł Gronowski
250886741b volume/local: Fix cifs url containing spaces
Unescapes the URL to avoid passing an URL encoded address to the kernel.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-01-23 17:42:11 +01:00
Paweł Gronowski
f4beb130b0 volume/local: Add tests for parsing nfs/cifs mounts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-01-23 17:42:09 +01:00
Paweł Gronowski
df43311f3d volume/local: Break early if addr was specified
I made a mistake in the last commit - after resolving the IP from the
passed `addr` for CIFS it would still resolve the `device` part.

Apply only one name resolution

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-01-23 17:17:53 +01:00
Paweł Gronowski
0d51cf9db8 volume/local: Make host resolution backwards compatible
Commit 8ae94cafa5 added a DNS resolution
of the `device` part of the volume option.

The previous way to resolve the passed hostname was to use `addr`
option, which was handled by the same code path as the `nfs` mount type.

The issue is that `addr` is also an SMB module option handled by kernel
and passing a hostname as `addr` produces an invalid argument error.

To fix that, restore the old behavior to handle `addr` the same way as
before, and only perform the new DNS resolution of `device` if there is
no `addr` passed.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-01-23 14:49:05 +01:00