Skip to content

fission-cli: add 'wait --for=condition' to condition-bearing resources#3402

Merged
sanketsudake merged 6 commits into
mainfrom
cli-wait-condition
May 25, 2026
Merged

fission-cli: add 'wait --for=condition' to condition-bearing resources#3402
sanketsudake merged 6 commits into
mainfrom
cli-wait-condition

Conversation

@sanketsudake
Copy link
Copy Markdown
Member

@sanketsudake sanketsudake commented May 25, 2026

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 <res> wait --name <name> --for=condition=<Type>[=<Status>] [--timeout=<dur>]
  • fission fn wait --name hello --for=condition=Ready --timeout=2m
  • fission pkg wait --name p1 --for=condition=BuildSucceeded
  • fission ht wait --name r1 --for=condition=Ready

Available 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 to True) or condition=<Type>=<Status> (True/False/Unknown).
  • Polls the resource (~1s) until the condition matches or --timeout (default 60s) elapses. A not-found result keeps polling (the resource may appear); other Get errors return immediately.
  • Success: <Kind>/<name> condition met: <Type>=<Status> (exit 0). Timeout: descriptive error with last-seen status (non-zero exit for CI).

Implementation

  • Shared, dependency-light core in pkg/fission-cli/util/wait.go: ParseForCondition, WaitForCondition (poll loop, reuses pkg/conditions.Find; not-found tolerant via util.IsNotFound), and RunWait CLI glue. Poll (not watch) — consistent with the existing spec waitForPackageBuild.
  • New --for / --timeout flags.
  • Each resource gets a thin wait.go (resolve ns+name, build a func(ctx) ([]metav1.Condition, error) closure over its typed client, call util.RunWait) + a registered wait subcommand.

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-check clean on the tracked tree).
  • Unit: util/wait_test.goParseForCondition (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.goWait against a fake clientset (condition met → success; not met + tiny timeout → error).
  • Manual on kind: ht wait/timer wait --for=condition=Readycondition met: Ready=True (exit 0); fn wait --timeout=2s on a never-served function → timeout error, exit 1; invalid --for=Ready rejected.

🤖 Generated with Claude Code


This change is Reviewable

sanketsudake and others added 3 commits May 25, 2026 21:18
…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>
Copilot AI review requested due to automatic review settings May 25, 2026 15:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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, and RunWait, plus --for / --timeout flags.
  • Registers new wait subcommands for function, package, httptrigger, timetrigger, mqtrigger, kubewatch, and canaryconfig.
  • Adds unit tests for the core wait utility and for function wait using 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.

Comment thread pkg/fission-cli/util/wait.go Outdated
Comment thread pkg/fission-cli/util/wait.go
Comment thread pkg/fission-cli/util/wait.go Outdated
Comment thread pkg/fission-cli/cmd/httptrigger/command.go Outdated
Comment thread pkg/fission-cli/util/wait.go
@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

❌ Patch coverage is 55.72139% with 89 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.66%. Comparing base (cdd23f2) to head (c4deb8e).

Files with missing lines Patch % Lines
pkg/fission-cli/cmd/canaryconfig/wait.go 0.00% 13 Missing ⚠️
pkg/fission-cli/cmd/httptrigger/wait.go 0.00% 13 Missing ⚠️
pkg/fission-cli/cmd/kubewatch/wait.go 0.00% 13 Missing ⚠️
pkg/fission-cli/cmd/mqtrigger/wait.go 0.00% 13 Missing ⚠️
pkg/fission-cli/cmd/package/wait.go 0.00% 13 Missing ⚠️
pkg/fission-cli/cmd/timetrigger/wait.go 0.00% 13 Missing ⚠️
pkg/fission-cli/util/wait.go 87.03% 4 Missing and 3 partials ⚠️
pkg/fission-cli/cmd/function/wait.go 69.23% 2 Missing and 2 partials ⚠️
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     
Flag Coverage Δ
unittests 47.66% <55.72%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

sanketsudake and others added 2 commits May 25, 2026 21:37
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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Comment thread pkg/fission-cli/util/wait.go Outdated
Comment thread pkg/fission-cli/flag/flag.go
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>
@sanketsudake sanketsudake merged commit 0fadb8a into main May 25, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants