Skip to content

add health check to dockerfiles #4346

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wenyang-cao
Copy link

Pull Request Template

Description

One of the important security triads is availability. Adding HEALTHCHECK instruction to your container image ensures that the docker engine periodically checks the running container instances against that instruction to ensure that the instances are still working.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Build and run the images (except the ones for k8s, since k8s has its own liveness probe and I cannot really see if health check is working in this case, but adding health check to k8s images is still required for twistlick) locally to verify the health check is working.

Additional Context (Please include any Screenshots/gifs if relevant)

...

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings
  • I have tagged the reviewers in a comment below incase my pull request is ready for a review
  • I have signed the commit message to agree to Developer Certificate of Origin (DCO) (to certify that you wrote or otherwise have the right to submit your contribution to the project.) by adding "--signoff" to my git commit command.

@wenyang-cao wenyang-cao force-pushed the fix-vul-healthcheck branch from 90528f9 to ea90b05 Compare May 22, 2025 12:19
@@ -6,3 +6,4 @@ ADD cloud-sync-service /cloud-sync-service/

CMD ["/cloud-sync-service/cloud-sync-service"]

HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD grep -q css_start.sh /proc/1/cmdline || exit 1
Copy link

Choose a reason for hiding this comment

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

[general] put HEALTHCHECK before CMD.

Copy link
Author

Choose a reason for hiding this comment

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

OK. I'll update this for all images later.

@@ -6,3 +6,4 @@ ADD cloud-sync-service /cloud-sync-service/

CMD ["/cloud-sync-service/cloud-sync-service"]

HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD grep -q css_start.sh /proc/1/cmdline || exit 1
Copy link

Choose a reason for hiding this comment

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

in some images you use grep ... /proc/1/cmdline, in other pgrep - could this be unified?

Copy link
Author

@wenyang-cao wenyang-cao May 26, 2025

Choose a reason for hiding this comment

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

Some images don't have pgrep. Nor do they have ps so I cannot use ps to get the process name. That is why I am using grep ... /proc/1/cmdline for these images

Wenyang Cao added 2 commits May 28, 2025 07:41
Signed-off-by: Wenyang Cao <[email protected]>
@wenyang-cao wenyang-cao force-pushed the fix-vul-healthcheck branch from ea90b05 to a7f2e7d Compare May 28, 2025 14:41
@dlarson04
Copy link
Contributor

@omordyk @wenyang-cao Can we go ahead and cancel this PR ? Health checks are provided elsewhere

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.

4 participants