fission-cli: add 'wait --for=condition' to condition-bearing resources#3402
Conversation
…ondition, RunWait) + flags Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…igger/mqtrigger/watch/canary Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new wait --for=condition=... subcommand across condition-bearing Fission CLI resources, enabling scripts/CI to block until a CRD status condition matches (kubectl-wait style), with shared parsing/polling logic in pkg/fission-cli/util.
Changes:
- Introduces shared wait core:
ParseForCondition,WaitForCondition, andRunWait, plus--for/--timeoutflags. - Registers new
waitsubcommands for function, package, httptrigger, timetrigger, mqtrigger, kubewatch, and canaryconfig. - Adds unit tests for the core wait utility and for
function waitusing a fake clientset.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/fission-cli/util/wait.go | Core implementation for parsing --for and polling conditions with timeout. |
| pkg/fission-cli/util/wait_test.go | Unit tests for parsing, polling behavior (including NotFound tolerance), and CLI glue. |
| pkg/fission-cli/flag/key/key.go | Adds new flag keys for --for and --timeout. |
| pkg/fission-cli/flag/flag.go | Defines new WaitFor and WaitTimeout flags. |
| pkg/fission-cli/cmd/function/wait.go | Adds fission fn wait implementation using typed client + shared wait util. |
| pkg/fission-cli/cmd/function/wait_test.go | Tests fn wait against a fake clientset. |
| pkg/fission-cli/cmd/function/command.go | Registers the wait subcommand under function. |
| pkg/fission-cli/cmd/package/wait.go | Adds fission pkg wait implementation. |
| pkg/fission-cli/cmd/package/command.go | Registers the wait subcommand under package. |
| pkg/fission-cli/cmd/httptrigger/wait.go | Adds fission ht wait implementation. |
| pkg/fission-cli/cmd/httptrigger/command.go | Registers the wait subcommand under httptrigger. |
| pkg/fission-cli/cmd/timetrigger/wait.go | Adds fission timetrigger wait implementation. |
| pkg/fission-cli/cmd/timetrigger/command.go | Registers the wait subcommand under timetrigger. |
| pkg/fission-cli/cmd/mqtrigger/wait.go | Adds fission mqtrigger wait implementation. |
| pkg/fission-cli/cmd/mqtrigger/command.go | Registers the wait subcommand under mqtrigger. |
| pkg/fission-cli/cmd/kubewatch/wait.go | Adds fission kubewatch wait implementation. |
| pkg/fission-cli/cmd/kubewatch/command.go | Registers the wait subcommand under kubewatch. |
| pkg/fission-cli/cmd/canaryconfig/wait.go | Adds fission canaryconfig wait implementation. |
| pkg/fission-cli/cmd/canaryconfig/command.go | Registers the wait subcommand under canaryconfig. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3402 +/- ##
==========================================
+ Coverage 47.57% 47.66% +0.09%
==========================================
Files 250 258 +8
Lines 20137 20331 +194
==========================================
+ Hits 9580 9691 +111
- Misses 9197 9274 +77
- Partials 1360 1366 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
util/wait.go:
- distinguish deadline vs cancellation in the terminal message ("timed out" vs
"canceled while") via waitTimeoutError + errors.Is(ctx.Err(), Canceled).
- if the in-flight get is interrupted by the wait ctx ending, fall through to
the timeout path (preserving last-seen) instead of returning the raw error.
- poll with a single time.Ticker instead of allocating time.After each loop.
- reuse the exported NoneValue constant for the initial last-seen value.
httptrigger: grammar "a HTTP trigger" -> "an HTTP trigger".
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…erver Reuses minimalFunction/smokeConditionType from conditions_test.go: drives a smoke condition True via UpdateStatus, asserts 'fn wait' succeeds, and that waiting for an unreached status times out (non-zero exit). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Export util.DefaultWaitTimeout and reference it from the --timeout flag default so the 60s value lives in one place instead of being duplicated. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
What
Adds a
kubectl wait-style subcommand so scripts/CI/GitOps can block until a resource reaches a status condition. Second of the CLI-UX follow-ups built on RFC-0003 conditions + #3397.fission fn wait --name hello --for=condition=Ready --timeout=2mfission pkg wait --name p1 --for=condition=BuildSucceededfission ht wait --name r1 --for=condition=ReadyAvailable on the 7 resources that write conditions: function, package, httptrigger, timetrigger, mqtrigger, watch (kubewatch), canaryconfig. Environment is omitted (it intentionally writes no conditions, so a wait could never succeed).
Behavior
--for=condition=<Type>(status defaults toTrue) orcondition=<Type>=<Status>(True/False/Unknown).--timeout(default 60s) elapses. A not-found result keeps polling (the resource may appear); other Get errors return immediately.<Kind>/<name> condition met: <Type>=<Status>(exit 0). Timeout: descriptive error with last-seen status (non-zero exit for CI).Implementation
pkg/fission-cli/util/wait.go:ParseForCondition,WaitForCondition(poll loop, reusespkg/conditions.Find; not-found tolerant viautil.IsNotFound), andRunWaitCLI glue. Poll (not watch) — consistent with the existingspec waitForPackageBuild.--for/--timeoutflags.wait.go(resolve ns+name, build afunc(ctx) ([]metav1.Condition, error)closure over its typed client, callutil.RunWait) + a registeredwaitsubcommand.Backward compatible — new subcommand + flags only.
Test
go build ./...,golangci-lint(0 issues), full CLI test suite pass; SPDX headers on all new files (make license-checkclean on the tracked tree).util/wait_test.go—ParseForCondition(valid/invalid/status),WaitForCondition(met immediately / after N polls / tolerates NotFound / timeout reports last-seen / non-notfound error surfaced),RunWait(success / invalid --for / timeout wraps kind/name).function/wait_test.go—Waitagainst a fake clientset (condition met → success; not met + tiny timeout → error).ht wait/timer wait --for=condition=Ready→condition met: Ready=True(exit 0);fn wait --timeout=2son a never-served function → timeout error, exit 1; invalid--for=Readyrejected.🤖 Generated with Claude Code
This change is