Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mounting issue with single character volume on windows #25323

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

axel7083
Copy link

@axel7083 axel7083 commented Feb 14, 2025

Fixes #25218

Does this PR introduce a user-facing change?

None

cc @l0rd

@openshift-ci openshift-ci bot added release-note-none do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Feb 14, 2025
Copy link
Contributor

openshift-ci bot commented Feb 14, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: axel7083
Once this PR has been reviewed and has the lgtm label, please assign vrothberg for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@axel7083 axel7083 force-pushed the fix/single-character-volume branch from a593ab2 to 021d30c Compare February 14, 2025 12:27
@axel7083 axel7083 marked this pull request as ready for review February 14, 2025 14:32
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 14, 2025
"github.com/stretchr/testify/assert"
)

func TestSplitVolumeString(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.

tyvm for adding a unit test, kudos

@@ -217,6 +218,20 @@ func SplitVolumeString(vol string) []string {
n = 4
}

// Determine if the last part is an option (e.g., "ro", "z")
Copy link
Member

Choose a reason for hiding this comment

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

@mheon really want your review on this ...

@baude
Copy link
Member

baude commented Feb 14, 2025

@axel7083 thanks for the PR ... kudos for adding system tests and unittests. really appreciate that. I did a flyby and it looked with the expectation that others will be doing a more indepth review.

Comment on lines +148 to +159
It("podman run with single character volume", func() {
// 1. create single character volume
session := podmanTest.Podman([]string{"volume", "create", "a"})
session.WaitWithDefaultTimeout()
volName := session.OutputToString()
Expect(session).Should(ExitCleanly())

// 2. create container with volume
session = podmanTest.Podman([]string{"run", "--volume", volName + ":/data", ALPINE, "sh", "-c", "echo hello world"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
})
Copy link
Member

Choose a reason for hiding this comment

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

This test is not actually testing your change, in particular the new code path is never executed on normal linux only when run inside the podman WSL machine because shouldResolveWinPaths().

While this test does not hurt and covers the normal linux flow it is not testing your particular bug/code change, this must be tested in the machine test suite pkg/machine/e2e instead.

Copy link
Author

Choose a reason for hiding this comment

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

I added a test in pkg/machine/e2e/basic_test.go

@@ -0,0 +1,77 @@
package specgen
Copy link
Member

Choose a reason for hiding this comment

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

friendly remainder that we never run windows or macos unit tests anywhere in CI, someone must hook that up.
I mentioned to @l0rd nefore.

That is nothing against your test and we keep it but a windows maintainer must manually verify them, I don't have access to such machine so I cannot do that.

Copy link
Member

Choose a reason for hiding this comment

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

I was able to run these tests successfully on Windows

Comment on lines 221 to 222
// Determine if the last part is an option (e.g., "ro", "z")
hasOption := !strings.HasPrefix(parts[len(parts)-1], "/")
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 the comment and code are rather confusing, it took me a while to understand what you are doing. I think that is a valid solution but the comment should that we actually check if the last parts is an absolute path. If it is not we know it must be options. Generally speaking there is no need to invert that here at all. Just name the var lastPartisPath and then switch the conditions below. That removes the negation here,

Copy link
Author

Choose a reason for hiding this comment

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

I updated the logic, to follow your recommendation

@Luap99
Copy link
Member

Luap99 commented Feb 14, 2025

Also somewhat related, we should consider blocking creating single letter volumes, docker doesn't allow this ref #23943. That of course is a breaking change so we cannot do that right now so the fix here still is great to have in the meantime but I would generally strongly recommend against using single letter volume names for the problems shown in the isue

@baude
Copy link
Member

baude commented Feb 14, 2025

is it worth noting somewhere this will likely be deprecated or at least in the man page something that says dont do this.

@mheon
Copy link
Member

mheon commented Feb 14, 2025

Code LGTM

Copy link
Member

@l0rd l0rd left a comment

Choose a reason for hiding this comment

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

Very nice job @axel7083. Thank you for adding all these tests. Unfortunately, the machine e2e tests are failing, and you must fix it. Apart from that, LGTM 🎉

Expect(err).ToNot(HaveOccurred())
Expect(volumeCreate).To(Exit(0))

run, err := mb.setCmd(bm.withPodmanCommand([]string{"run", "-v", "a:/test:Z", "quay.io/libpod/alpine_nginx"})).run()
Copy link
Member

Choose a reason for hiding this comment

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

This is failing. The container default command doesn't return, and the test times out.

You can run the test locally (and I recommend it):

# Build podman
./winmake.ps1 podman

# Install ginkgo
cd ./test/tools
go build -o build/ginkgo.exe ./vendor/github.com/onsi/ginkgo/v2/ginkgo
cd -

# Run the test
$remotetags = "remote exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp"
$focus_file = "basic_test.go"
$focus_test = "Single character volume mount"
./test/tools/build/ginkgo.exe `
  -v --tags "$remotetags" -timeout=90m --trace --no-color `
  --focus-file  $focus_file `
  --focus "$focus_test" `
  ./pkg/machine/e2e/.

@@ -0,0 +1,77 @@
package specgen
Copy link
Member

Choose a reason for hiding this comment

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

I was able to run these tests successfully on Windows

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.

podman run cannot mount volume named with single character on windows
5 participants