Skip to content

Fix healthcheck kwargs for container.create()#647

Open
inknos wants to merge 1 commit into
containers:mainfrom
inknos:rhel-140716
Open

Fix healthcheck kwargs for container.create()#647
inknos wants to merge 1 commit into
containers:mainfrom
inknos:rhel-140716

Conversation

@inknos

@inknos inknos commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

The health_* kwargs were being passed as snake_case in the JSON payload, but /libpod/containers/create endpoint expects nested objects.

Assemble kwargs into proper structures:

  • healthconfig: {Test, Interval, Timeout, Retries, StartPeriod}
  • startupHealthConfig: {Test, Interval, Timeout, Retries, Successes}
  • healthLogDestination, healthMaxLogCount, healthMaxLogSize (camelCase)
  • health_on_failure string mapped to health_check_on_failure_action int

Also, it's possible to pass duration values as go-style strings ("30s", "1m", "500ms") and integers as nanoseconds.

Fixes: https://redhat.atlassian.net/browse/RHEL-140716


keeping as draft since I want to sleep on the code before saying it's ready

@inknos inknos marked this pull request as ready for review June 9, 2026 14:52

@giuseppe giuseppe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@Honny1 Honny1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have some comments. Moust of them are small improvments.

Comment thread podman/api/parse_utils.py Outdated
f"Use Go-style durations like '30s', '1m', '500ms', '1h30m'."
)
num_str, unit = match.groups()
total_ns += int(float(num_str) * DURATION_UNITS_NS[unit])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well, using float feels odd. Why not int?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

("1" -> 1.0000000001 could happen)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was thinking of "1.5s" being valid but we could do integers only. I see the validation is wrong anyway so doing ints seems ok. WDYT?

Comment thread podman/api/parse_utils.py
Comment thread podman/domain/containers_create.py Outdated
Comment thread podman/tests/integration/test_container_create.py
The health_* kwargs were being passed as snake_case in the JSON
payload, but /libpod/containers/create endpoint expects nested objects.

Assemble kwargs into proper structures:
- healthconfig: {Test, Interval, Timeout, Retries, StartPeriod}
- startupHealthConfig: {Test, Interval, Timeout, Retries, Successes}
- healthLogDestination, healthMaxLogCount, healthMaxLogSize (camelCase)
- health_on_failure string mapped to health_check_on_failure_action int

Also, it's possible to pass duration values as go-style strings
("30s", "1m", "500ms") and integers as nanoseconds.

Fixes: https://redhat.atlassian.net/browse/RHEL-140716

Signed-off-by: Nicola Sella <nsella@redhat.com>

@Honny1 Honny1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants