feat(httpcheck): add httpcheck stage plugin - #55
Conversation
|
@t-kikuc this one is ready for review when you get a chance. The failing check on it isn't the plugin. Want me to open a separate issue for that? |
A stage plugin that polls an HTTP endpoint until it returns the expected status code or a timeout passes. Intended as a smoke test gate between stages, for example checking a service answers before promoting it. Built on the piped plugin SDK and the Go standard library. Signed-off-by: Ahmed Faraj <ahmedfrag4040@gmail.com>
88d008e to
03f0cf7
Compare
|
@t-kikuc can you approve the workflow run on this one? I re-pushed the same commit to clear the old |
| for { | ||
| select { | ||
| case <-ticker.C: | ||
| if ok := checkOnce(ctx, client, opts, slp); ok { |
There was a problem hiding this comment.
as far as I remember, this checkOnce might be a block function that could cause case where already timeout but still need to wait checkOnce() => maybe timeout is only 10s but if checkOnce() happens at 8th second and returns successfully at 13 seconds
There was a problem hiding this comment.
hey can you check this out, also make a test case for this IMO
There was a problem hiding this comment.
Confirmed. Fixed with a context deadline, test is TestCheck_TimeoutWhileProbeInFlight.
First probe still uses the parent ctx so a restart gets one attempt. Want validate() to reject interval >= timeout too?
armistcxy
left a comment
There was a problem hiding this comment.
Maybe there's a bug, can you check it out
The ticker branch ran checkOnce to completion, so the select could not take the timeout case while a probe was still waiting for a response. A probe that answered after the budget had passed still returned Success. Use a deadline context counted from initialStart and pass it to checkOnce, so the request is cancelled when the budget ends. Signed-off-by: Ahmed Faraj <ahmedfrag4040@gmail.com>
|
@t-kikuc can you approve the workflow run again? armistcxy found a bug in the timeout handling, I pushed the fix so the checks went back to |
There was a problem hiding this comment.
🟡 Changes recommended
The plugin’s go.mod Go version conflicts with CI and the initial HTTP probe currently bypasses the stage timeout deadline, which can cause the stage to exceed the configured timeout.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 13/14 changed files
- Comments generated: 3
- Review effort level: Lite
| @@ -0,0 +1,66 @@ | |||
| module github.com/pipe-cd/community-plugins/plugins/httpcheck | |||
|
|
|||
| go 1.25.0 | |||
| // The first probe uses ctx so that a stage restarted after its budget | ||
| // passed still gets one attempt at a healthy endpoint. | ||
| if ok := checkOnce(ctx, client, opts, slp); ok { | ||
| return sdk.StageStatusSuccess | ||
| } |
| It uses only the plugin SDK and the Go standard library. There is no deploy | ||
| target and no plugin scope configuration, so it can be added to a pipeline of any | ||
| application kind. |
What this PR does
Adds
httpcheck, a stage plugin that polls an HTTP endpoint until it returns the expected status code or a timeout passes.The
HTTP_CHECKstage takes a url, an expected status code, a timeout and a poll interval. It probes once immediately then on the interval. Start time is kept in stage metadata, so a piped restart does not reset the timeout.I ran
hack/init-plugin.shlocally, so the scaffold and the CODEOWNERS and labeler entries are included here rather than coming from a separate workflow run.Why we need it / Without this PR, what is the problem?
Today the way to wait for a service to answer after a rollout is a
WAITstage with a guessed duration.ANALYSISwith an http provider runs for its full duration and only exits early on failure, so it does not work as a gate that passes as soon as the endpoint is healthy.Which issue(s) this PR fixes
Fixes #46