docker-maven-plugin icon indicating copy to clipboard operation
docker-maven-plugin copied to clipboard

Runtime healthcheck definition support

Open poikilotherm opened this issue 1 year ago • 5 comments

This PR will add support to add a healthcheck to a container when it is created, not just when its image is built.

  • Add <healthCheck> to <run> as known from <build>
  • Add healthcheck to a compose file service definition

Closes #1733 Closes #1580

TODOs

  • [ ] More tests?
  • [ ] Add Compose support and tests
  • [ ] Extend docs to explain the differences in both places on adding a check
  • [ ] Add integration tests
  • [ ] Fix integration tests and examples for build-time healthchecks

Discussion points

  • While retaining backward compatibility, prior versions of DMP did not see a missing <cmd> for a build time healthcheck as a wrong configuration when <mode> was set to cmd. This PR alters this behavior and requests a user to give a command when setting mode to cmd. Is this a valid exception to backward compatibility? (What use is having mode CMD and not give a command? Giving no command does not express "inherit" - at least the documentation doesn't say so and trying to build such a Dockerfile results in Docker complaining about Missing command after HEALTHCHECK CMD for me)

poikilotherm avatar Dec 14 '23 21:12 poikilotherm

Codecov Report

Merging #1736 (d629ffe) into master (452123d) will increase coverage by 0.15%. Report is 5 commits behind head on master. The diff coverage is 76.14%.

:exclamation: Current head d629ffe differs from pull request most recent head a809bed. Consider uploading reports for the commit a809bed to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1736      +/-   ##
============================================
+ Coverage     65.31%   65.47%   +0.15%     
- Complexity     2280     2312      +32     
============================================
  Files           172      173       +1     
  Lines         10184    10279      +95     
  Branches       1406     1434      +28     
============================================
+ Hits           6652     6730      +78     
- Misses         2983     2997      +14     
- Partials        549      552       +3     
Files Coverage Δ
...bric8/maven/docker/assembly/DockerFileBuilder.java 92.76% <100.00%> (+0.88%) :arrow_up:
...o/fabric8/maven/docker/config/HealthCheckMode.java 100.00% <100.00%> (ø)
...ic8/maven/docker/access/ContainerCreateConfig.java 84.88% <0.00%> (-1.00%) :arrow_down:
...8/maven/docker/config/BuildImageConfiguration.java 84.67% <50.00%> (-0.27%) :arrow_down:
...config/handler/property/PropertyConfigHandler.java 86.17% <0.00%> (ø)
...va/io/fabric8/maven/docker/service/RunService.java 67.65% <33.33%> (-0.35%) :arrow_down:
.../maven/docker/config/HealthCheckConfiguration.java 92.59% <92.15%> (+13.64%) :arrow_up:
...ic8/maven/docker/config/RunImageConfiguration.java 87.83% <27.27%> (-3.29%) :arrow_down:
...aven/docker/access/ContainerHealthCheckConfig.java 65.38% <65.38%> (ø)

... and 2 files with indirect coverage changes

codecov[bot] avatar Dec 14 '23 21:12 codecov[bot]

Hi @rhuss @rohanKanojia ,

I created this draft PR to give you a chance for early feedback on the overall approach. The missing pieces are more of non-essential nature and the feature does work already.

Please let me know what you think about what I did so far. Thanks in advance!

poikilotherm avatar Dec 14 '23 21:12 poikilotherm

@poikilotherm : Hello, thanks a lot for your PR. I gave a quick look at your PR and I think it will be a valuable addition.

Would this change be backward compatible with existing users?

rohanKanojia avatar Jan 06 '24 05:01 rohanKanojia

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

2 New issues
0 Security Hotspots
81.8% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Jan 08 '24 11:01 sonarqubecloud[bot]

Hi @rohanKanojia!

Would this change be backward compatible with existing users?

I absolutely intend to do that! So far I have only found one point where I would like to implement more strict behaviour, that might be seen as breaking backward compatibility. (See initial post.)

Right now I am still working on the compose part of things, but looking forward to get this PR out of draft by end of the week.

poikilotherm avatar Jan 08 '24 11:01 poikilotherm