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

Strip key/values of external quotes #21000

Merged
merged 1 commit into from
Feb 2, 2024

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Dec 13, 2023

Does this PR introduce a user-facing change?

quadlet will strips quotes around values in quadlets.

Fixes: #20992

@openshift-ci openshift-ci bot added release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 13, 2023
@ygalblum
Copy link
Contributor

I also looked at this issue. The problem is that some keys do require keeping the double quotes. See the hostname.container test which fails.

@rhatdan
Copy link
Member Author

rhatdan commented Dec 13, 2023

I was wondering that.

@rhatdan
Copy link
Member Author

rhatdan commented Dec 13, 2023

After looking at the failures, I think the new code is correct, stripping the quotes. I believe this matches better with systemd.

Comment on lines 1 to 6
## assert-podman-final-args localhost/imagename
## assert-podman-args "RemoveQuotesName"

[Container]
Image="localhost/imagename"
Name="RemoveQuotesName"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
## assert-podman-final-args localhost/imagename
## assert-podman-args "RemoveQuotesName"
[Container]
Image="localhost/imagename"
Name="RemoveQuotesName"
## assert-podman-final-args localhost/imagename
## assert-podman-args "--name=RemoveQuotes\"Name"
[Container]
Image="localhost/imagename"
ContainerName="RemoveQuotes"Name"

@ygalblum
Copy link
Contributor

After looking at the failures, I think the new code is correct, stripping the quotes. I believe this matches better with systemd.

You're right. Not sure why, but when I ran it yesterday without the quotes the hostname was not set. I've tested it again and it even makes more sense now. Don't know what went wrong

@Luap99
Copy link
Member

Luap99 commented Dec 14, 2023

But is striping the quotes actually the problem? I would think systemd uses some form of escape logic similar to the shell so just stripping does not sounds right. https://www.freedesktop.org/software/systemd/man/latest/systemd.syntax.html

If you look at pkg/systemd/parser/split.go there is already a bunch of code to take care of thie escaping AFAICT so I would assume you would need to use that to correctly parse values.

@rhatdan
Copy link
Member Author

rhatdan commented Dec 15, 2023

@Luap99 I don't see anything obvious there. Most of those look like something that splits a string into a series of arguments, similar to shlex.

@Luap99
Copy link
Member

Luap99 commented Jan 3, 2024

extractFirstWord() for example. LookupAllStrv() already handles this correctly because it calls into that.

@rhatdan
Copy link
Member Author

rhatdan commented Jan 27, 2024

I don't have time to work on this and it is a simple enough change, that I think we should just merge, and if you want to open an issue to create a better fix in the future lets open that.

@vrothberg @giuseppe @Luap99 @ashley-cui @mheon @baude @ygalblum @umohnani8 PTAL

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

openshift-ci bot commented Jan 29, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe, rhatdan

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@markstos
Copy link
Contributor

markstos commented Feb 1, 2024

Thanks for this fix! It seems ready to merge, although some MAc and Windows checks failed.

@mheon
Copy link
Member

mheon commented Feb 1, 2024

Needs a rebase to fix Windows CI, Mac is an expected failure

@rhatdan rhatdan added the lgtm Indicates that a PR is ready to be merged. label Feb 2, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 7cb0c2e into containers:main Feb 2, 2024
90 of 92 checks passed
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label May 3, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators May 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

quadlet fails to handle quoting properly in .container files
6 participants