-
Notifications
You must be signed in to change notification settings - Fork 643
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
Runtime healthcheck definition support #1736
base: master
Are you sure you want to change the base?
Conversation
…r language issues - Use parameterized tests instead repeating test methods, easier to maintain and extend, and more expressive - Add toString() for better test outputs - Fix unnecessary casting - Fix config in builder not being final
With the goal of validating and transforming durations given by a user from various sources, a parser is necessary to validate and process given strings. Using a regular expression is the easiest and safest but maybe not the fastest way to get there.
Docker Compose and Docker API distinguish between cmd (array of args) and cmd-shell (command string) mode, so we need to add this as a mode for our goal to enable runtime defined healthchecks. Users will need to pay attention which mode they use in runtime defined checks, as the Dockerfile buildtime check is not making this difference!
…checks for retries and durations
… configuration fabric8io#1733 Enable adding <healthCheck> XML declaration as seen in <build> sections before now also in <run>.
…abric8io#1733 Transforming the internal healthcheck model into a JSON object the Docker API understands when added to the larger create container JSON object.
…ld time fabric8io#1733 Technically, we reuse the HealthCheckConfiguration for both build and runtime added checks. Yet the syntax is slightly different: for runtime checks, we need to specify whether we want CMD or SHELL, for build time checks Docker figures that out itself.
Codecov Report
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
|
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! |
In case a user provides a healthcheck specification as part of runtime configuration or compose, the intent might be to alter the options only and no the test itself. An explicit mode that needs to be added to the XML config or determined by the Compose handler makes users' intentions clearer and easier to validate. Also merging shell case in DockerFileBuilder to default as we have two invalid nodes now.
By opening the immutable HealthCheckConfiguration to allow setting a default if no mode was configured, we can have different defaults depending on context. Validation now fails when no mode is selected, imperative to use the new HealthCheckConfiguration.setModeIfNotPresent() method right before validation (in RunImageConfiguration and BuildImageConfiguration).
@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? |
… edge cases - Enable using "0" as value with no unit (meaning inherit) - Fix broken duration regex due to extra } - Fix broken duration regex not recognizing 00, 10, and 20h because of wrong intervals
As unit tests for DockerFileBuilder do not execute BuildImageConfiguration.initAndValidate(), be safe and execute defaulting to CMD mode in build context again. To avoid diverging settings, introduce a constant reused in both places. Left a comment as well.
… to private constructor
Although a builder pattern is present (and now used within the codebase), the deserialization from the Maven XML config requires a public constructor.
…tion fails To help identify which of potentially many image configurations in a Maven file has an ill-formed configuration, while iterating through the images also add the name/alias when validation fails.
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 2 New issues |
Hi @rohanKanojia!
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. |
This PR will add support to add a healthcheck to a container when it is created, not just when its image is built.
<healthCheck>
to<run>
as known from<build>
healthcheck
to a compose file service definitionCloses #1733
Closes #1580
TODOs
Discussion points
<cmd>
for a build time healthcheck as a wrong configuration when<mode>
was set tocmd
. This PR alters this behavior and requests a user to give a command when setting mode tocmd
. 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 aboutMissing command after HEALTHCHECK CMD
for me)