Skip to content

api/pre-1.44: Default ReadOnlyNonRecursive to true#47391

Merged
thaJeztah merged 2 commits intomoby:masterfrom
vvoland:rro-backwards-compatible
Feb 27, 2024
Merged

api/pre-1.44: Default ReadOnlyNonRecursive to true#47391
thaJeztah merged 2 commits intomoby:masterfrom
vvoland:rro-backwards-compatible

Conversation

@vvoland
Copy link
Contributor

@vvoland vvoland commented Feb 15, 2024

Don't change the behavior for older clients and keep the same behavior.

- How to verify it
TestContainerBindMountReadOnlyDefault

- Description for the changelog

- To preserve backwards compatibility, read-only mounts are not recursive by default when using older clients (API version < v1.44).

- A picture of a cute animal (not mandatory but encouraged)

return errdefs.InvalidParameter(errors.New("BindOptions.ReadOnlyForceRecursive needs API v1.44 or newer"))
} else {
bo = &mount.BindOptions{}
hostConfig.Mounts[idx].BindOptions = bo
Copy link
Contributor Author

@vvoland vvoland Feb 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This is needed, because m.BindOptions = ... would only overwrite the BindOptions in the m variable which is a local copy of the original mount and not a reference to the Mount in hostConfig.Mounts.

@vvoland
Copy link
Contributor Author

vvoland commented Feb 15, 2024

Failure related, test needs adjustment:

=== Failed
=== FAIL: amd64.integration-cli TestDockerCLIRunSuite/TestRunMount (0.08s)
    docker_cli_run_test.go:4396: assertion failed: err is not nil: got error while creating a container with [--mount type=bind,src=/tmp/mount1181042325/mnt1,dst=/foo --mount type=bind,src=/tmp/mount1181042325/mnt2,dst=/bar] (mount-0-0)
    --- FAIL: TestDockerCLIRunSuite/TestRunMount (0.08s)

EDIT: Oh, actually it's not the test, ReadOnlyNonRecursive was set true also for non-readonly mounts which made it error out. Changed the default to only apply for m.ReadOnly mounts.

@vvoland vvoland force-pushed the rro-backwards-compatible branch from 16bafea to c247ce3 Compare February 16, 2024 14:42
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@vvoland vvoland force-pushed the rro-backwards-compatible branch from c247ce3 to c12c8b0 Compare February 16, 2024 14:48
@vvoland
Copy link
Contributor Author

vvoland commented Feb 16, 2024

Looks like some failures are related:

      Command:  /usr/local/cli-integration/docker run -d -v /vol1 -v /tmp/test-put-container-archive-err-symlink-in-volume-to-read-only-rootfs-1579682919:/vol2 -v /tmp/test-put-container-archive-err-symlink-in-volume-to-read-only-rootfs-1579682919/vol3:/vol3 -v /tmp/test-put-container-archive-err-symlink-in-volume-to-read-only-rootfs-1579682919/vol_ro:/vol_ro:ro --read-only busybox /bin/sh -c #(nop)
        ExitCode: 125
        Error:    exit status 125
        Stdout:   
        Stderr:   /usr/local/cli-integration/docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /tmp/test-put-container-archive-err-symlink-in-volume-to-read-only-rootfs-1579682919/vol_ro.
        See '/usr/local/cli-integration/docker run --help'.

Parsing added by this PR doesn't return-early in case of error, so not sure yet why that happens..

@vvoland vvoland force-pushed the rro-backwards-compatible branch 2 times, most recently from 6694464 to 8057434 Compare February 19, 2024 13:04
continue
}
}
newBinds = append(newBinds, b)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this clear the Binds field after they've been migrated?

Also wondering if this migration should always happen, so also on current API versions 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't migrate all Binds (yet), only the read-only ones to reduce potential blast area.

Was planning to make a separate PR that would also deprecate the Binds field and transform all of them to Mounts.

@vvoland vvoland force-pushed the rro-backwards-compatible branch 3 times, most recently from f4db0f9 to 1f7ccf9 Compare February 20, 2024 10:47
@vvoland
Copy link
Contributor Author

vvoland commented Feb 20, 2024

This looks green now, failures are unrelated and are caused by Docker Hub search API being down.

@vvoland vvoland force-pushed the rro-backwards-compatible branch from 1f7ccf9 to 020b64e Compare February 21, 2024 10:10
@vvoland vvoland force-pushed the rro-backwards-compatible branch 2 times, most recently from 8539542 to 6e21f36 Compare February 22, 2024 10:23
@vvoland vvoland requested a review from cpuguy83 February 22, 2024 19:22
assert.Equal(t, mountsBefore, mountsAfter)
}

func TestContainerBindMountReadOnlyDefault(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a to check if rro is supported on the kernel for the test to function properly.

Alternatively, we could just check the registered mountpoints in the API to see if the option is set as expected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also sorry, one more check, test should be skipped if api version is < 1.44.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? It also tests that the behavior doesn't change when <1.44 API is requested.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So yes technically the 1.43 test should pass on an older daemon.
But the 1.44 test would fail since it is not a supported version.

Copy link
Contributor Author

@vvoland vvoland Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.44 test will be skipped: 0f8270b#diff-0ac47068153ec59b77b2044bd459fb6395f028e6e112dc03645f7ba72f324bf2R456

But yeah the version: "" would fail, updated it to also be skipped.

Also, added the test for api.MinSupportedAPIVersion client version.

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>
@vvoland vvoland force-pushed the rro-backwards-compatible branch from 6e21f36 to 0f8270b Compare February 23, 2024 10:21
Don't change the behavior for older clients and keep the same behavior.
Otherwise client can't opt-out (because `ReadOnlyNonRecursive` is
unsupported before 1.44).

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland force-pushed the rro-backwards-compatible branch from 0f8270b to 4323903 Compare February 26, 2024 10:37
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable upgrading RO mounts to RRO when a client speaks API older than v1.44 (Docker v25)

4 participants