Skip to content

feat: add await-condition task with height polling and SIGTERM action#36

Merged
bdchatham merged 1 commit intomainfrom
feature/await-condition-task
Mar 18, 2026
Merged

feat: add await-condition task with height polling and SIGTERM action#36
bdchatham merged 1 commit intomainfrom
feature/await-condition-task

Conversation

@bdchatham
Copy link
Contributor

Summary

  • Adds await-condition task type for the PreInitPlan bootstrap flow. The sidecar polls the local CometBFT /status RPC at 100ms intervals until latest_block_height >= targetHeight, then optionally sends SIGTERM to seid with SIGKILL escalation after 30s.
  • Introduces sidecar/rpc package (StatusClient for CometBFT status queries) and sidecar/actions package (process discovery via /proc and GracefulStop with context cancellation and isProcessGone handling).
  • Adds signal.NotifyContext to the serve command for graceful sidecar shutdown on pod termination.

New packages

Package Purpose
sidecar/rpc CometBFT /status RPC client (500ms context timeout, no competing http.Client timeout)
sidecar/actions Process discovery (/proc scanning, requires shareProcessNamespace: true) and graceful stop orchestration

Kubernetes notes

  • Pod spec must set shareProcessNamespace: true and restartPolicy: Never
  • terminationGracePeriodSeconds should exceed DefaultGracePeriod (30s) to allow the sidecar to serve the final task status
  • Containers must share the same UID or seictl needs CAP_KILL
  • seid must be launched directly (not via shell wrapper) for /proc/*/cmdline matching

Test plan

  • Height polling: reaches target, already past target, transient RPC errors, context cancellation
  • Input validation: missing/unknown condition, zero/negative/missing targetHeight, unknown action
  • Target height parsing: float64, int64, json.Number
  • GracefulStop: immediate exit, SIGKILL escalation, context cancellation
  • Process-gone handling: ESRCH on FindPID, ErrProcessDone on SIGTERM, ESRCH on SIGKILL
  • firstArg /proc cmdline parsing edge cases
  • StatusClient: happy path, catching up, HTTP errors, connection refused, malformed JSON, invalid block height
  • AwaitConditionTask client: validation, ToTaskRequest, JSON round-trip

Implements the await-condition task type for the PreInitPlan bootstrap
flow. The sidecar polls the local CometBFT /status RPC until a target
block height is reached, then optionally sends SIGTERM to seid with
SIGKILL escalation.

New packages:
- sidecar/rpc: StatusClient for CometBFT /status queries
- sidecar/actions: process discovery via /proc and graceful stop
  with SIGTERM→SIGKILL escalation, context-cancellable

Changes:
- Add TaskAwaitCondition type and handler registration
- Add AwaitConditionTask client struct with validation
- Add signal.NotifyContext for graceful sidecar shutdown
- Bump openapi.yaml to v0.6.0
@bdchatham bdchatham force-pushed the feature/await-condition-task branch from 0f06797 to e0f28c1 Compare March 18, 2026 23:15
@bdchatham bdchatham marked this pull request as ready for review March 18, 2026 23:20
@bdchatham bdchatham merged commit b80f5ce into main Mar 18, 2026
2 checks passed
@bdchatham bdchatham deleted the feature/await-condition-task branch March 18, 2026 23:20
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.

1 participant