-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Quadlet container mount - support non key=val options #20149
Quadlet container mount - support non key=val options #20149
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the underlying problem of having two separate functions to parse essentially the same thing remains. That implies a risk of code divergence and subtle errors.
Did you consider recycling the Podman-internal function to parse mounts and change it in a way that we can re-use it in Quadlet?
My idea was to limit the parsing to only what Quadlet really needs and that is resolving the
I think that reusing the Podman parser code might raise other issues. For example, Quadlet is not supposed to do any validity checks. But, now, it will. |
Exactly, --mount flag uses csv not split at comma, this behaves differently for special chars so it is important to use the same code. And for the future someone might change the --mount parsing and then will not update quadlet so it will diverge again. The only way to address this is to directly share the code. |
That's a fair argument. I think we mostly avoid validation to avoid code duplication/divergence. But if we manage to share the same function we could do it. But I guess it would at some dependencies to Quadlet (likely runtime spec). |
you can just use podman/pkg/specgenutil/volumes.go Line 145 in a2434a9
That should already work for both use cases podman and quadlet. Simply move this function to a new package without all the extra imports as that would bloat quadlet otherwise. |
f07a6b6
to
3daf8c1
Compare
@vrothberg @Luap99 Done. PTAL |
pkg/systemd/quadlet/quadlet.go
Outdated
tokens = append([]string{fmt.Sprintf("type=%s", mountType)}, tokens...) | ||
return strings.Join(tokens, ","), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will still fail when the value contains special chars, you must again encode this via the csv lib in order to encode this back into the right format. Consider a a filepath with comma:
--mount=type=bind,src=/tmp,"dst=/path,1"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch. Once fixed, can we also add a test case for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the test case is the first step in writing the fix :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like Batman, you are not the maintainer we deserve but the one we need :^)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Wow, making the test work was more complicated than the code fix :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
804854d
to
b6fc0cf
Compare
Some keys, e.g. ro do not have values. The current implementation crashed looking for the = sign Externalize findMountType in a new package Parse mount command using FindMountType Rebuild parameter string using csv Add test case and adjust the test framework Signed-off-by: Ygal Blum <[email protected]>
b6fc0cf
to
f0eb456
Compare
Does this failure block the merge: |
Yes but we can overwrite with the label, given this is so close I am good with it. You already split out the function to not require unnecessary imports so I assume this is the best we can do and the grow is mostly caused by the CSV parser. |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vrothberg, ygalblum The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm Thanks |
Some keys, e.g. ro do not have values.
The current implementation crashed looking for the = sign
Externalize findMountType in a new package
Parse mount command using FindMountType
Add test case and adjust the test framework
Does this PR introduce a user-facing change?
Yes
Resolves: #20104