Skip to content

Remove Shutdown Hooks and Dump Admin State on Startup - #474

Merged
codefromthecrypt merged 2 commits into
masterfrom
no_shutdown
Jul 21, 2025
Merged

Remove Shutdown Hooks and Dump Admin State on Startup#474
codefromthecrypt merged 2 commits into
masterfrom
no_shutdown

Conversation

@codefromthecrypt

@codefromthecrypt codefromthecrypt commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

This simplifies func-e's lifecycle by removing shutdown hooks and collecting admin state on startup instead. Essential xDS configuration data is captured when Envoy's dispatch loop starts, making it available immediately when needed. This makes things more coherent and allows us to leverage CommandContext for signal propagation.

This also aligns exit behavior with native Envoy (code 0 on graceful shutdown/interrupt). This allows api.Run to return nil on effective success (context canceled or exit code zero), increasing the signal of the error return.

Impact

  • Breaking: No archived run dirs or shutdown files; Run returns nil on interrupts (vs. prior errors).
  • Benefits: Reduced complexity/leaks; reliable cross-platform; smaller binary; essential xDS data available when running.

Key Changes

The key improvement is that essential xDS data is now captured reliably during startup when Envoy's admin API becomes available, rather than attempting complex shutdown coordination. This provides the necessary configuration visibility with significantly less complexity and better cross-platform reliability

  • Startup: Collect config dump with comprehensive xDS data (LDS/RDS/CDS/EDS/SDS) via admin API after "main dispatch loop" starts. Essential configuration state available immediately.
  • Shutdown: Remove hooks (admin/node data archiving). Return nil on clean exits/interrupts.
  • Interrupts: Handle multiples (e.g., Ctrl+C x2) gracefully; add e2e test.
  • Run Dir: Now holds stdout.log, stderr.log, envoy.pid, config_dump.json with full xDS snapshot. No archiving.
  • Platform: Simplify proc attrs (Pdeathsig on Linux only); fix macOS zombie issues.
  • Testing: Add access logging to configs which allows us to test envoy's stdout; verify logs/run dir in e2e. Rename TestRun_MinimalListener to TestRun_RunDirectory.
  • Cleanup: Remove golang.org/x/sync; update docs/help (no hooks/archiving mentions).
  • Version: Update to 1.34.3 in code/docs.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
Comment thread internal/cmd/run_test.go

func init() {
// Don't let urfave quit the current test process on cancel!
cli.OsExiter = func(code int) { log.Printf("urfave called exit: %d", code) }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm sure @mathetake and @anuraaga could guess the rage level when I finally figured out what was quitting the whole test process.

@codefromthecrypt
codefromthecrypt marked this pull request as draft July 20, 2025 14:06
@codefromthecrypt

Copy link
Copy Markdown
Contributor Author

there's a race between admin hook finishing and envoy being canceled. I have work in progress and will push tomorrow

Signed-off-by: Adrian Cole <adrian@tetrate.io>
@codefromthecrypt
codefromthecrypt marked this pull request as ready for review July 21, 2025 03:59
@codefromthecrypt

Copy link
Copy Markdown
Contributor Author

ps after this change I will look into allowing the user to supply their own StartupHook or ability to remove the default one.

@codefromthecrypt
codefromthecrypt merged commit 7efac33 into master Jul 21, 2025
7 checks passed
@codefromthecrypt
codefromthecrypt deleted the no_shutdown branch July 21, 2025 05:02
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