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

Inspecting Containers without health checks return health nil #18807

Closed
wants to merge 1 commit into from

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Jun 6, 2023

Fixed: #18792

This will match Docker behaviour.
`

Does this PR introduce a user-facing change?

Inspecting containers without healthchecks will return nil for heath field.

@openshift-ci openshift-ci bot added do-not-merge/release-note-label-needed Enforce release-note requirement, even if just None approved Indicates a PR has been approved by an approver from all required OWNERS files. release-note and removed do-not-merge/release-note-label-needed Enforce release-note requirement, even if just None labels Jun 6, 2023
Error string `json:"Error"` // TODO
StartedAt time.Time `json:"StartedAt"`
FinishedAt time.Time `json:"FinishedAt"`
Health *HealthCheckResults `json:"Health,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

This is part of InspectContainerData which is exposed in pkg/bindings.
We should not break these types as they must be considered stable.

I wonder why omitempty is not working already, AFAIK it doesn't need to be a pointer for that?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe this is better:

diff --git a/libpod/define/container_inspect.go b/libpod/define/container_inspect.go
index 0309a8dde..c015349fa 100644
--- a/libpod/define/container_inspect.go
+++ b/libpod/define/container_inspect.go
@@ -239,11 +239,11 @@ func (s *InspectContainerState) Healthcheck() HealthCheckResults {
 // HealthCheckResults describes the results/logs from a healthcheck
 type HealthCheckResults struct {
        // Status starting, healthy or unhealthy
-       Status string `json:"Status"`
+       Status string `json:"Status,omitempty"`
        // FailingStreak is the number of consecutive failed healthchecks
-       FailingStreak int `json:"FailingStreak"`
+       FailingStreak int `json:"FailingStreak,omitempty"`
        // Log describes healthcheck attempts and results
-       Log []HealthCheckLog `json:"Log"`
+       Log []HealthCheckLog `json:"Log,omitempty"`
 }
 
 // HealthCheckLog describes the results of a single healthcheck

Of course this would still show as "Health": {}, in the inspect json but I think that is good enough? In any case don't think we should break this type.

@rhatdan rhatdan force-pushed the info branch 2 times, most recently from c3310bb to 2124c77 Compare June 9, 2023 17:05
Fixed: containers#18792

This will match Docker behaviour.
`
Signed-off-by: Daniel J Walsh <[email protected]>
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM
@Luap99 PTAL

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 13, 2023

[APPROVALNOTIFIER] This PR is APPROVED

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

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

@@ -43,7 +43,7 @@ function _check_health {

_check_health "All healthy" "
Status | \"healthy\"
FailingStreak | 0
FailingStreak | null
Copy link
Member

Choose a reason for hiding this comment

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

ah, I think this might not be a good idea then after all.
If we hide the FailingStreak 0 even when there is a health check we could break parsers.

// FailingStreak is the number of consecutive failed healthchecks
FailingStreak int `json:"FailingStreak"`
FailingStreak int `json:"FailingStreak,omitzero,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

omitzero is not needed, please remove it. Only the toml parser uses omitzero.

@Luap99
Copy link
Member

Luap99 commented Jun 13, 2023

Let's wait for comments on #18792, I am not sure if this would actually help the user in its current form.

@Luap99
Copy link
Member

Luap99 commented Jun 14, 2023

Based on the comments in #18792 I don't think it makes sense to move forward with this. It will not fix the issue reporters problem and likely cause unwanted side effect for the FailingStreak field.
Your original patch of changing this to a pointer makes sense but should wait for podman 5.0 IMO.

@rhatdan rhatdan closed this Jun 14, 2023
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 13, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2023
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. 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.

Running containers without defined or disabled health checks should not return "Health": {}
3 participants