vv9k / podman-api-rs

Rust interface to Podman (libpod).
MIT License
84 stars 12 forks source link

400 Bad Request on Wait for Running #160

Closed atagen closed 1 year ago

atagen commented 1 year ago

Hello,

The following code:

podman.containers().get(&some_ctr_id).wait(
    &ContainerWaitOpts::builder()
        .interval("500ms")
        .conditions([ContainerStatus::Running, ContainerStatus::Exited])
        .build(),
).await?;

results in the output:

error 400 Bad Request - failed to parse parameters for /v4.3.1/libpod/containers/3c682f2314e885205fcec77af539fe55f94a61f7d44793119ee66aa226acf73f/wait?condition=%5B%22running%22%5D&interval=500ms: schema: error converting value for index 0 of "condition": schema: error converting value for index 0 of "condition"

The code

println!(self.podman.info().await?.version.unwrap().api_version.unwrap());

prints "4.5.0" as expected.

However, it appears that:

Calling podman wait some_container --condition running from the CLI works as expected.

Please let me know if there's any further information or testing I can provide, or if there's somewhere I could start looking to fix this - I would very much like to get this working.

Thanks :)

vv9k commented 1 year ago

Thanks for spotting this! There was a problem with how the ContainerWaitOpts::conditions parameter was serialized and it doesn't matter which version you are using. I've create a PR #161 that fixes the issue and adds a test case for Container::wait. Tested locally with version 4.5.0 and before the changes it failed with the error you provided, now the test case works.

atagen commented 1 year ago

Fix works, perfect! Thanks for being so quick :)