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

Fix HealthCheck log destination, count, and size defaults #25520

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Honny1
Copy link
Member

@Honny1 Honny1 commented Mar 10, 2025

This PR changes HealthLogDestination, HealthMaxLogCount, HealthMaxLogSize of ContainerMiscConfig to pointers. And it removes omitempty from HealthLogDestination, HealthMaxLogCount, HealthMaxLogSize of SpecGenerator.ContainerHealthCheckConfig.

GoLang sets unset values to the default value of the type. This means that the destination of the log is an empty string and the count and size are set to 0. However, this means that size and count are unbounded, and this is not the default behavior.

Fixes: #25473
Fixes: https://issues.redhat.com/browse/RHEL-83262

Does this PR introduce a user-facing change?

Fixed a bug where the default values of the HealthCheck logs were not set correctly, causing the logs to have no restrictions. 

@openshift-ci openshift-ci bot added release-note do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Mar 10, 2025
Copy link
Contributor

openshift-ci bot commented Mar 10, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Honny1
Once this PR has been reviewed and has the lgtm label, please assign mheon for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Mar 10, 2025
@Honny1 Honny1 force-pushed the fix-hc-inf-log branch 2 times, most recently from 0096bde to a2718bf Compare March 10, 2025 16:56
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

For better coverage about the update issue (i.e. libpod config) see test/upgrade. I.e. you can add a inspect test and compare the healtcheck values are using the defaults

Comment on lines 607 to 615
HealthLogDestination *string `json:"healthLogDestination,omitempty"`
// HealthMaxLogCount is maximum number of attempts in the HealthCheck log file.
// ('0' value means an infinite number of attempts in the log file)
HealthMaxLogCount uint `json:"healthMaxLogCount,omitempty"`
// ('0' value means an infinite number of attempts in the log file).
// Nil value means the default value (5).
HealthMaxLogCount *uint `json:"healthMaxLogCount,omitempty"`
// HealthMaxLogSize is the maximum length in characters of stored HealthCheck log
// ("0" value means an infinite log length)
HealthMaxLogSize uint `json:"healthMaxLogSize,omitempty"`
// ("0" value means an infinite log length).
// Nil value means the default value (500).
HealthMaxLogSize *uint `json:"healthMaxLogSize,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Note you cannot change them, specgen is part of our stable API via pkg/bindings.
The pointer change I mentioned is only for the libpod container config as it doesn't have to be stable.

Copy link
Member Author

@Honny1 Honny1 Mar 10, 2025

Choose a reason for hiding this comment

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

Can I at least remove the omitempty?

Copy link
Member

Choose a reason for hiding this comment

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

yes omitempty should be fine to remove (and I guess is needed to make --health-max-log-count 0 work via remote, otherwise the client would not add it top the json and the server thus using the 5 as default)

Copy link
Member Author

@Honny1 Honny1 Mar 11, 2025

Choose a reason for hiding this comment

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

Yes, it is not serialized to httpBody, but parsing from SpecGenerator.ContainerCreateCommand is also an option. You can also add it to the httpBody manually. Which is the better way? @Luap99

Copy link
Member

Choose a reason for hiding this comment

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

Don't parse ContainerCreateCommand, it should not be trusted for these things.

I think removing the omitempty is the best, that means we always pass what the user sets or the default. I hvae done that kind of work around in the past and it worked good enough. Now if we add containers.conf fields for these then this becomes an issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, that simplifies the problem. I guess it depends on what priority containers.conf should have.

@Honny1 Honny1 force-pushed the fix-hc-inf-log branch 2 times, most recently from 3ec3b8d to db63dde Compare March 11, 2025 15:33
@Honny1 Honny1 marked this pull request as ready for review March 12, 2025 10:02
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 12, 2025
HealthMaxLogCount uint `json:"healthMaxLogCount,omitempty"`
// ('0' value means an infinite number of attempts in the log file).
// Nil value means the default value (5).
HealthMaxLogCount uint `json:"healthMaxLogCount"`
Copy link
Member

Choose a reason for hiding this comment

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

also likely want to add a comment that omitempty should not be added and these should be converted to a pointer on the next major release

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we have something like this for employee tracking for the next major release, or is it just TODO?

Copy link
Member

Choose a reason for hiding this comment

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

My personal syntax I use is // TODO (6.0): ...

@Honny1 Honny1 force-pushed the fix-hc-inf-log branch 3 times, most recently from 0c1277b to e098270 Compare March 12, 2025 20:25
GoLang sets unset values to the default value of the type. This means that the destination of the log is an empty string and the count and size are set to 0. However, this means that size and count are unbounded, and this is not the default behavior.

Fixes: containers#25473
Fixes: https://issues.redhat.com/browse/RHEL-83262

Signed-off-by: Jan Rodák <[email protected]>
@Honny1 Honny1 requested a review from Luap99 March 13, 2025 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/api-change Change to remote API; merits scrutiny release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Excessive memory leak due to uncontrolled accumulation of health.log entries in Podman 5.x
2 participants