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

can MountPath contain ":" ? #129453

Open
ningmingxiao opened this issue Jan 2, 2025 · 17 comments
Open

can MountPath contain ":" ? #129453

ningmingxiao opened this issue Jan 2, 2025 · 17 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/windows Categorizes an issue or PR as relevant to SIG Windows.

Comments

@ningmingxiao
Copy link

ningmingxiao commented Jan 2, 2025

What happened?

https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/types.go#L2110-L2113

	RecursiveReadOnly *RecursiveReadOnlyMode
	// Required. If the path is not an absolute path (e.g. some/path) it
	// will be prepended with the appropriate root prefix for the operating
	// system.  On Linux this is '/', on Windows this is 'C:\'.
	MountPath string

but
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/api/core/v1/types.go#L2283

	// Path within the container at which the volume should be mounted.  Must
	// not contain ':'.
	MountPath string `json:"mountPath" protobuf:"bytes,3,opt,name=mountPath"`

some people use mountpath:/etc/localtime:ro (k8s should use readonly:true) will not work on containerd but work on docker.

What did you expect to happen?

mountPath can't contain ":"

How can we reproduce it (as minimally and precisely as possible)?

set mountpath:/etc/localtime:ro

Anything else we need to know?

No response

Kubernetes version

any

Cloud provider

no

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, ...) and versions (if applicable)

@ningmingxiao ningmingxiao added the kind/bug Categorizes issue or PR as related to a bug. label Jan 2, 2025
@k8s-ci-robot k8s-ci-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jan 2, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jan 2, 2025
@pacoxu
Copy link
Member

pacoxu commented Jan 3, 2025

cc @carlory

@ningmingxiao
Copy link
Author

this pr may fix #129466

@carlory
Copy link
Member

carlory commented Jan 3, 2025

I think it is a documentation issue. #31707 removed the limit.

Can you update the related comment in the code and then run make update?

@carlory
Copy link
Member

carlory commented Jan 3, 2025

#22204 added the limit but it was removed later.

/cc @thockin @jsafrane

Can you have a look?

related comments why it is removed: #31707 (comment)

@thockin
Copy link
Member

thockin commented Jan 3, 2025

I am confused about this issue - why would the mounth path - literally the directory we intend to mount the volume on - contain ":ro" or ":rw" ?

If you want to mount it read-only, we have a field for that -- it's not embedded in the string.

@carlory
Copy link
Member

carlory commented Jan 3, 2025

@thockin "a:b" is a vaild path on linux. so I think the mountPath can't contain ":" maybe not accepted.
image

@carlory
Copy link
Member

carlory commented Jan 3, 2025

If you want to mount it read-only, we have a field for that -- it's not embedded in the string.

Agreed. We don't support <path>:<mount option>.

@ningmingxiao
Copy link
Author

ningmingxiao commented Jan 3, 2025

aaaaa
some user use wrong yaml but works on docker. (k8s with docker )
when use it with containerd containerd will create a file "localtime:ro" (k8s with containerd)
So I think we can prevent to use ":ro" or ":rw"

@thockin
Copy link
Member

thockin commented Jan 3, 2025

We don't support colons in the path, or we shouldn't, because runtimes like docker do the wrong thing. Have those all been fixed? I do not think special-casing ":ro" makes a lot sense. Runtimes should fix support for colons, or not support them at all.

@carlory
Copy link
Member

carlory commented Jan 3, 2025

/sig node
/sig storage
/sig windows

@k8s-ci-robot k8s-ci-robot added sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/windows Categorizes an issue or PR as relevant to SIG Windows. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 3, 2025
@carlory
Copy link
Member

carlory commented Jan 3, 2025

cc @brendandburns @pires
Can you have a look? because you are main reviewers of #31707

@pires
Copy link
Contributor

pires commented Jan 3, 2025

What @thockin said.

@thockin
Copy link
Member

thockin commented Jan 3, 2025

Is the issue here about Windows? I don't have any first hand background here - if we needed to special case colons on Windows, to manage drive letters, I could maybe understand that. But I thought that was a solved problem already?

@carlory
Copy link
Member

carlory commented Jan 6, 2025

I think this issue is related to the windows because the constraint is removed when kubeneretes support windows nodes. And there're a lot of e2e tests and unit tests which uses c:/ as mount path's prefix.

: is valid character in windows or linux path. so it's acceptable to use it in kubernetes. We should treat it as a part of path. it doesn't represent any special meaning (i.e. mount options). It is different from docker.

The CRI standard said that the mount path is the path of the mount within the container. So the issue should be fixed in the CRI implementation, not in the kubernetes.

@carlory
Copy link
Member

carlory commented Jan 6, 2025

Runtimes should fix support for colons, or not support them at all.

+1. It should depend on the implementation of container runtime. I don't have more knowledge about docker cri since docker shim was removed from in-tree.

@thockin
Copy link
Member

thockin commented Jan 6, 2025

I don't mean to flip on this one, but it's a very long-standing issue.

My feeling is that we should do what the most commonly used runtimes support . It seems like docker has a way to mount on paths with colons via the API, now. Presumably that means containers, too. Does CRI-O?

On Windows, colon has two meanings - one is drive letters, which is obvious, but the other is file streams, which is NOT what we want. A quick Google suggests that colons are NOT allowed in directory names on Windows

If someone wants to champion this, we will need details about how each runtime supports colons as part of the analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/windows Categorizes an issue or PR as relevant to SIG Windows.
Projects
Status: Triage
Development

No branches or pull requests

6 participants