407 Commits

Author SHA1 Message Date
Matthieu MOREL
6d737371b8 fix comparison rule from errorlint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-13 08:26:56 +00:00
Sebastiaan van Stijn
0069360e3b volume/mounts: windowsDetectMountType: rewrite using switch
Mostly for readability, and to avoid linters suggesting to move the
default condition outside of the if/else.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-10 13:19:25 +02:00
Matthieu MOREL
bc9ec5fc02 fix emptyStringTest from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Sebastiaan van Stijn
3bbb38f1d2 volume: remove // import comments
These comments were added to enforce using the correct import path for
our packages ("github.com/docker/docker", not "github.com/moby/moby").
However, when working in go module mode (not GOPATH / vendor), they have
no effect, so their impact is limited.

Remove these imports in preparation of migrating our code to become an
actual go module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-30 15:59:14 +02:00
Matthieu MOREL
37caf3881a volume: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:41:53 +00:00
Sebastiaan van Stijn
48733b0751 Merge pull request #47883 from dmcgowan/errdefs-check-containerd
Update errdefs package to use containerd/errdefs
2025-05-16 18:20:41 +02:00
Matthieu MOREL
205ba05feb fix usestdlibvars
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-15 18:24:58 +02:00
Derek McGowan
5c16f2d091 Use standard library interface to unwrap errors
The `Cause()` function is not part of the standard library and should
not be used or relied on. `pkg/errors` already has compatibility with
the standard library.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-05-15 08:05:52 -07:00
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