Skip to content

feat(httpcheck): add httpcheck stage plugin - #55

Open
Ahmad-Faraj wants to merge 2 commits into
pipe-cd:mainfrom
Ahmad-Faraj:feat/httpcheck-plugin
Open

feat(httpcheck): add httpcheck stage plugin#55
Ahmad-Faraj wants to merge 2 commits into
pipe-cd:mainfrom
Ahmad-Faraj:feat/httpcheck-plugin

Conversation

@Ahmad-Faraj

Copy link
Copy Markdown

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_CHECK stage 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.sh locally, 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 WAIT stage with a guessed duration. ANALYSIS with 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

@Ahmad-Faraj
Ahmad-Faraj requested a review from a team as a code owner August 13, 2026 11:26
@Ahmad-Faraj
Ahmad-Faraj requested review from Warashi, ffjlabo and khanhtc1202 and a lite review from Copilot and removed request for Copilot August 13, 2026 11:26
@Ahmad-Faraj

Copy link
Copy Markdown
Author

@t-kikuc this one is ready for review when you get a chance.

The failing check on it isn't the plugin. go (./plugins/httpcheck) and go (httpcheck) both pass. What's red is go (./plugins/opentofu), and the log looks like CI trouble rather than code: the runner hit a GitHub API rate limit pulling golangci-lint, took a 403 on the download, then fell over on unknown flag: --out-format, which golangci-lint removed in v2.

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>
@Ahmad-Faraj
Ahmad-Faraj force-pushed the feat/httpcheck-plugin branch from 88d008e to 03f0cf7 Compare August 27, 2026 06:19
@Ahmad-Faraj

Copy link
Copy Markdown
Author

@t-kikuc can you approve the workflow run on this one? I re-pushed the same commit to clear the old lint failure, which was a GitHub cache outage on Aug 13 rather than anything in the plugin. The diff is unchanged.

Comment thread plugins/httpcheck/httpcheck.go Outdated
for {
select {
case <-ticker.C:
if ok := checkOnce(ctx, client, opts, slp); ok {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

hey can you check this out, also make a test case for this IMO

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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 armistcxy left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>
Copilot AI lite review requested due to automatic review settings August 30, 2026 16:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Ahmad-Faraj

Copy link
Copy Markdown
Author

@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 action_required. Tests and lint pass locally.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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

Comment thread plugins/httpcheck/go.mod
@@ -0,0 +1,66 @@
module github.com/pipe-cd/community-plugins/plugins/httpcheck

go 1.25.0
Comment on lines +70 to +74
// 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
}
Comment on lines +22 to +24
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[New plugin] httpcheck stage plugin

3 participants