Skip to content

Add SIGUSR1 signal handler for runtime configuration dumps

Summary

Implements #1301 (closed) - Add support for dumping current kube-vip configuration when SIGUSR1 signal is received.

This feature allows operators to inspect the runtime configuration of kube-vip without restarting the process or accessing configuration files.

Changes

Core Implementation

  • Signal Handling: Added SIGUSR1 handling across all manager start methods (ARP, BGP, Wireguard, Table mode)
  • Configuration Dump: Implemented dumpConfiguration() with 7 specialized helper methods:
    • dumpConfigSection() - VIP, interface, port, namespace settings
    • dumpBGPSection() - BGP AS, router ID, peers configuration
    • dumpARPSection() - ARP/NDP broadcast settings
    • dumpServicesSection() - Services and load balancer configuration
    • dumpNetworkInterfacesSection() - Network interface manager status
    • dumpLeaderElectionSection() - Leader election type and lease details
    • dumpRuntimeSection() - Load balancer, Prometheus, health check settings
  • Pattern Update: Refactored signal handlers to use switch statement pattern for cleaner multi-signal handling

Testing

  • Unit Tests: 5 comprehensive tests covering all dump methods (pkg/manager/manager_dump_test.go)
  • E2E Test: Validates signal handling and non-disruptive behavior (testing/e2e/e2e_sigusr1_test.go)
  • Quality: All tests pass, code formatted with gofmt, go vet clean

Documentation

  • Added CHANGELOG.md following Keep a Changelog format
  • Comprehensive inline documentation for all new methods

Implementation Details

  • Thread-Safe: Uses mutex protection for concurrent access safety
  • Non-Disruptive: Process continues running after configuration dump
  • Output Format: Human-readable plaintext via fmt.Printf() to stdout
  • Compatible: Works with all kube-vip start modes (ARP, BGP, Wireguard, Table)

Usage Example

# Send SIGUSR1 to running kube-vip process
kill -SIGUSR1 <pid>

# Or using kubectl (for kube-vip in pod)
kubectl exec -n kube-system <kube-vip-pod> -- kill -SIGUSR1 1

Test Results

✅ Code Formatting (gofmt)    - PASSED
✅ Static Analysis (go vet)   - PASSED
✅ Unit Tests (5 tests)       - PASSED (0.018s)
✅ Build Verification         - PASSED

Files Changed

Modified (5 files):

  • pkg/manager/manager.go - Added dump methods and SIGUSR1 handling
  • pkg/manager/manager_arp.go - Updated signal handler pattern
  • pkg/manager/manager_bgp.go - Updated signal handler pattern
  • pkg/manager/manager_table.go - Updated signal handler pattern
  • pkg/manager/manager_wireguard.go - Updated signal handler pattern

Added (3 files):

  • CHANGELOG.md - Project changelog
  • pkg/manager/manager_dump_test.go - Unit tests
  • testing/e2e/e2e_sigusr1_test.go - E2E test

Related Issues

Closes #1301 (closed)


Co-authored-by: SteveYi steveyiyo@steveyi.net

Merge request reports

Loading