-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
libpod/define/container_inspect.go
Outdated
Error string `json:"Error"` // TODO | ||
StartedAt time.Time `json:"StartedAt"` | ||
FinishedAt time.Time `json:"FinishedAt"` | ||
Health *HealthCheckResults `json:"Health,omitempty"` |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
c3310bb
to
2124c77
Compare
Fixed: containers#18792 This will match Docker behaviour. ` Signed-off-by: Daniel J Walsh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@Luap99 PTAL
[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 |
@@ -43,7 +43,7 @@ function _check_health { | |||
|
|||
_check_health "All healthy" " | |||
Status | \"healthy\" | |||
FailingStreak | 0 | |||
FailingStreak | null |
There was a problem hiding this comment.
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"` |
There was a problem hiding this comment.
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.
Let's wait for comments on #18792, I am not sure if this would actually help the user in its current form. |
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. |
Fixed: #18792
This will match Docker behaviour.
`
Does this PR introduce a user-facing change?