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

Add support to ShmSize in Pods with Quadlet #24899

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

Conversation

Odilhao
Copy link
Contributor

@Odilhao Odilhao commented Dec 23, 2024

This closes #22915

Add support for ShmSize in Pods created with Quadlet.
Add e2e tests.
Add new Docs entry.

Does this PR introduce a user-facing change?

Users are now able to define the ShmSize value on Pod Units for containers created with quadlets.

@Odilhao Odilhao force-pushed the pod-shm-size-issue branch 3 times, most recently from 8307a36 to a083f93 Compare December 23, 2024 21:01
@rhatdan
Copy link
Member

rhatdan commented Dec 24, 2024

/approve
LGTM
Thanks @Odilhao

Copy link
Contributor

openshift-ci bot commented Dec 24, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Odilhao, 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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 24, 2024
@@ -1650,6 +1651,11 @@ func ConvertPod(podUnit *parser.UnitFile, name string, unitsInfoMap map[string]*
execStartPre.add("--infra-name", fmt.Sprintf("%s-infra", podName))
execStartPre.add("--name", podName)

shmSize := podUnit.LookupAll(PodGroup, KeyShmSize)
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC you are looking for all the occurrences of KeyShmSize and then use the first one. This does not align with the expected behaviour in which the last value takes precedence.
Instead of calling LookupAll and using the first element of the array, you should use Lookup (which returns the last occurrence) and use the returned value if exists.
Alternatively, you can create a map and use the lookupAndAddString function. Yes, it is an overkill for a single key, but it's the start for supporting more keys

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed from LookupAll to Lookup, I tried a to implement the map using the stringsKeys that is already created and it failed on my e2e assertions tests, tried also to create a new map just for sanity and it failed as well, if we really need to use map I can give a try later this week.

Copy link
Contributor

Choose a reason for hiding this comment

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

I added a comment on the new code. We'll change the code to use a map later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The map problem was in my e2e test, instead of using assert-podman-pre-args "--shm-size=5g" I'm now using assert-podman-pre-args "--shm-size" "5g" this made the test pass.

I also changed the stringKeys function from lookupAndAddAllStrings to lookupAndAddString.

@@ -1650,6 +1651,11 @@ func ConvertPod(podUnit *parser.UnitFile, name string, unitsInfoMap map[string]*
execStartPre.add("--infra-name", fmt.Sprintf("%s-infra", podName))
execStartPre.add("--name", podName)

shmSize, exists := podUnit.Lookup(PodGroup, KeyShmSize)
if exists {
Copy link
Contributor

Choose a reason for hiding this comment

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

To align with other checks, please also check that there's a value:

Suggested change
if exists {
if exists && len(shmSize) > 0 {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Podman v5 Quadlet .pod support for "ShmSize=" parameter
3 participants