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

[BUG] -1 is not a supported value for ulimits #501

Open
g0dfl3sh opened this issue Jan 20, 2025 · 3 comments
Open

[BUG] -1 is not a supported value for ulimits #501

g0dfl3sh opened this issue Jan 20, 2025 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@g0dfl3sh
Copy link

g0dfl3sh commented Jan 20, 2025

I am writing code that parses a compose file and launches containers based on the keywords found there.

If in my compose file I have the below configuration the code errors out with cannot unmarshal number -1 into Go struct field POSIXRlimit.r_limits.hard of type uin64

ulimits:
    memlock:
         soft: -1
         hard: -1

I have found a workaround by substituting -1 with 18446744073709551615 which shows up as -1 upon running podman inspect <container>, however it would be nice if the library would support passing -1.

podman version
Client: Podman Engine
Version: 5.2.2
API Version: 5.2.2
Go version: go1.22.7 (Red Hat 1.22.7-2.el9_5)
Built: Fri Nov 15 08:49:31 2024
OS/Arch: linux/amd64

Note that this issue does not pop up when running podman compose which is why I think it's an issue with this library. If this needs to be raised in another repo, please let me know.

@inknos
Copy link
Contributor

inknos commented Jan 21, 2025

cannot unmarshal number -1 into Go struct field POSIXRlimit.r_limits.hard of type uin64

This sounds like a podman bug, not podman-py

How did you run your code? If you didn't use python I would suggest you to open an issue here, and link this issue in the new one.

@inknos
Copy link
Contributor

inknos commented Jan 21, 2025

If that's related to python, I would like to know more about how you can reproduce this bug :)

@inknos inknos added the help wanted Extra attention is needed label Jan 21, 2025
@g0dfl3sh
Copy link
Author

@inknos sorry, my wires got crossed and I pasted the wrong code here earlier. Below is the correct Python code to reproduce this issue:

from podman import PodmanClient

def create_container():
      socket_path = "unix:///run/podman/podman.sock"

      with PodmanClient(base_url=socket_path) as client:
             client.images.pull("alpine:latest")
             
             container = client.containers.create(
                           image="alpine:latest",
                           command=["sh", "-c", "for i in 1 2 3; do echo Hello $i; sleep 1; done"],
                           name="security_opt-bug",
                           ulimits=[{"Name": "memlock", "Soft": -1, "Hard": -1}],
                           )
            
             container.start()

if __name__ == "__main__":
     create_container()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants