slimtoolkit / slim

Slim(toolkit): Don't change anything in your container image and minify it by up to 30x (and for compiled languages even more) making it secure too! (free and open source)
Apache License 2.0
19.48k stars 730 forks source link

Ability to exit http probe and fail build when any http probe fails #708

Open tylersalminen opened 3 months ago

tylersalminen commented 3 months ago

A new CLI argument and / or environment variable (or modification of --http-probe-exit-on-failure / DSLIM_HTTP_PROBE_EXIT_ON_FAILURE) that allows the build to fail when any single http probe fails.

Current behavior is to fail when every http probe fails i.e. when the following condition is true:

probe.CallCount > 0 && probe.OkCount == 0 && opts.httpProbeOpts.ExitOnFailure
....

Would instead want something like

probe.ErrCount > 0 && opts.httpProbeOpts.ExitOnAnyFailure
....
kcq commented 2 months ago

the new --http-probe-exit-on-failure-count flag in the new release (e.g., ----http-probe-exit-on-failure-count 1) should help with this

tylersalminen commented 2 months ago

I tried this out today, it does not seem to be picking up that one of my http probes returned a 500 status error (you can see in the image that it determined that all probes were successful). This may be a separate issue from this change but thought I would bring this up here

image

kcq commented 2 months ago

Any kind of server response regardless of the http status code is considered to be a success. This is because the goal is to exercise the server app logic. In some cases, the http error codes are used to try different request parameters combinations. This happens with the openAPI spec based requests... mostly with POSTs.

tylersalminen commented 2 months ago

Gotcha that makes sense, thanks for the response

kcq commented 2 months ago

It is possible to have a flag to fail on 5xx status codes.

tylersalminen commented 2 months ago

If you believe it is appropriate to fit such a flag within your current framework I would definitely make use of it. There are some cases with the http probes I am setting up where I would like our deployment to fail if some unbound / unhandled exception occurred so that a possibly faulty image is not deployed.

kcq commented 2 months ago

--http-probe-fail-on-status-5xx will be available in the next release