Skip to content

Conversation

@jasonoh11
Copy link

@jasonoh11 jasonoh11 commented Dec 11, 2025

… healthcheck

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

None

This fixes #27651, which raises the issue in which containers hold a stale "starting" status even though no healthchecks are configured.

As @mheon pointed out, the bug lies in the following condition:

if c.config.HealthCheckConfig != nil && (len(c.config.HealthCheckConfig.Test) != 1 || c.config.HealthCheckConfig.Test[0] != "NONE")

In the case of a non-nil HealthCheckConfig and a nil or empty HealthCheckConfig.Test, the condition incorrectly enters the code path that handles when a health check is actually configured.

These conditions seem to arise when building a container with --rootfs as opposed to building from an image.

I extended HasHealthCheck() to correctly evaluate the various combinations of HealthCheckConfig and HealthCheckConfig.Test, and used this function to replace repeated, incorrect code causing both podman inspect rootfs-test --format '{{json .State.Health}}' and podman ps to incorrectly return stale statuses.

I also included a unit test for HasHealthCheck

@Yarboa
Copy link

Yarboa commented Dec 11, 2025

/packit test --identifier cockpit-revdeps

@packit-as-a-service
Copy link

Account Yarboa has no write access nor is author of PR!

@Yarboa
Copy link

Yarboa commented Dec 11, 2025

/packit test --identifier cockpit-revdeps

@jasonoh11 please ask someone to rerun failed test as above
It seems like machine gets to error before tests start to run

Copy link
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

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

LGTM! I have just one small nit.

@jasonoh11
Copy link
Author

Hi @Honny1 thanks for reviewing! I pushed an update according to your suggestion. It says there's still a workflow waiting for approval from a maintainer, is there any more action needed on my end or is this ready for approval?

Also, @Yarboa mentioned a failed test, does this need to be resolved?

Thanks!

pkg/ps/ps.go Outdated
return err
}


Copy link
Member

Choose a reason for hiding this comment

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

CI is not happy.

+ ./bin/golangci-lint run --build-tags=apparmor,seccomp,selinux
pkg/ps/ps.go:230:1: File is not properly formatted (gofumpt)

^
1 issues:
* gofumpt: 1

Copy link
Author

Choose a reason for hiding this comment

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

I cleaned up the spacing, thanks!

@Honny1
Copy link
Member

Honny1 commented Dec 12, 2025

Some tests are flaky. I can re-run them for you.

…with empty healthcheck

Signed-off-by: Jason Oh <jasonoh@utexas.edu>
pkg/ps/ps.go Outdated
return err
}

Copy link
Member

Choose a reason for hiding this comment

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

+ ./bin/golangci-lint run --build-tags=apparmor,seccomp,selinux
pkg/ps/ps.go:229:1: File is not properly formatted (gofumpt)
		
^
1 issues:
* gofumpt: 1

Copy link
Author

Choose a reason for hiding this comment

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

Fixed, thanks

@packit-as-a-service
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

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.

Container shows "Health": {"Status": "starting"} even though no healthcheck is defined

3 participants