Replace Ruby bosh-monitor with Go implementation#2747
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
e611365 to
56da280
Compare
56da280 to
327b3f9
Compare
There was a problem hiding this comment.
Pull request overview
This PR replaces the legacy Ruby-based bosh-monitor with a Go-based implementation and updates packaging, CI, and integration test scaffolding to build and run the new binary + out-of-process plugins.
Changes:
- Introduces a new Go
bosh-monitorbinary with supporting packages (server, event processing, NATS monitoring, plugin host/protocol, etc.) and Ginkgo/Gomega tests. - Updates BOSH release packaging/job templates to run the Go binary instead of the Ruby runtime/gem.
- Updates integration support to build the Go binary/plugins and adjusts integration specs/configs for the new log/config formats.
Reviewed changes
Copilot reviewed 156 out of 160 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/spec/integration/health_monitor/hm_stateless_spec.rb | Updates integration log parsing to match Go slog output format. |
| src/spec/integration_support/sandbox.rb | Builds the Go monitor for integration tests and runs it with updated PATH/env. |
| src/spec/integration_support/bosh_monitor_manager.rb | Adds integration helper to build Go bosh-monitor + plugin binaries. |
| src/spec/assets/sandbox/health_monitor_without_resurrector.yml.erb | Adjusts sandbox HM config to match new Go monitor expectations. |
| src/Gemfile.lock | Removes Ruby bosh-monitor gem from bundle. |
| src/Gemfile | Removes Ruby bosh-monitor gem entry. |
| src/bosh-monitor/test/integration/integration_suite_test.go | Adds Go integration test suite scaffold (Ginkgo). |
| src/bosh-monitor/spec/unit/bosh/monitor/protocols/tcp_connection_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/plugins/tsdb_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/plugins/riemann_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/plugins/resurrector_helper_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/plugins/paging_datadog_client_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/plugins/pagerduty_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/plugins/logger_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/plugins/json_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/plugins/graphite_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/plugins/event_logger_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/plugins/email_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/plugins/dummy_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/plugins/base_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/metric_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/instance_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/events/base_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/events/alert_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/event_processor_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/director_monitor_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/config_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/unit/bosh/monitor/agent_spec.rb | Removes Ruby monitor unit tests (legacy implementation removed). |
| src/bosh-monitor/spec/support/uaa_helpers.rb | Removes Ruby monitor test support (legacy implementation removed). |
| src/bosh-monitor/spec/support/host_authorizatin.rb | Removes Ruby monitor test support (legacy implementation removed). |
| src/bosh-monitor/spec/support/buffered_logger.rb | Removes Ruby monitor test support (legacy implementation removed). |
| src/bosh-monitor/spec/spec_helper.rb | Removes Ruby monitor spec helper (legacy implementation removed). |
| src/bosh-monitor/spec/gemspec_spec.rb | Removes Ruby gemspec tests (legacy implementation removed). |
| src/bosh-monitor/spec/functional/notifying_plugins_spec.rb | Removes Ruby functional tests (legacy implementation removed). |
| src/bosh-monitor/spec/assets/sample_config.yml | Removes Ruby sample config (legacy implementation removed). |
| src/bosh-monitor/spec/assets/dummy_plugin_config.yml | Removes Ruby dummy plugin config (legacy implementation removed). |
| src/bosh-monitor/pkg/server/server.go | Adds Go HTTP API server implementation (healthz + agent endpoints). |
| src/bosh-monitor/pkg/server/server_test.go | Adds Go tests for server endpoints. |
| src/bosh-monitor/pkg/server/server_suite_test.go | Adds Ginkgo suite for server package. |
| src/bosh-monitor/pkg/resurrection/resurrection_suite_test.go | Adds Ginkgo suite for resurrection package. |
| src/bosh-monitor/pkg/resurrection/manager_test.go | Adds resurrection manager rule parsing/behavior tests. |
| src/bosh-monitor/pkg/processor/processor_suite_test.go | Adds Ginkgo suite for processor package. |
| src/bosh-monitor/pkg/processor/event_processor.go | Adds Go event processor (validation, dedupe, pruning, dispatch). |
| src/bosh-monitor/pkg/processor/event_processor_test.go | Adds tests for Go event processor. |
| src/bosh-monitor/pkg/pluginproto/protocol_suite_test.go | Adds Ginkgo suite for plugin protocol package. |
| src/bosh-monitor/pkg/pluginhost/pluginhost_suite_test.go | Adds Ginkgo suite for plugin host package. |
| src/bosh-monitor/pkg/pluginhost/host_test.go | Adds tests for plugin host command handling and startup behavior. |
| src/bosh-monitor/pkg/nats/nats_suite_test.go | Adds Ginkgo suite for NATS package. |
| src/bosh-monitor/pkg/nats/director_monitor.go | Adds Go director-alert subscription monitor. |
| src/bosh-monitor/pkg/nats/director_monitor_test.go | Adds initial unit tests for director monitor (needs strengthening). |
| src/bosh-monitor/pkg/nats/client.go | Adds Go NATS client with TLS and startup retry logic. |
| src/bosh-monitor/pkg/instance/instance.go | Adds Go instance model + formatting helpers. |
| src/bosh-monitor/pkg/instance/instance_suite_test.go | Adds Ginkgo suite for instance package. |
| src/bosh-monitor/pkg/instance/deployment.go | Adds Go deployment model and agent/instance bookkeeping. |
| src/bosh-monitor/pkg/instance/agent.go | Adds Go agent model and timeout/rogue logic. |
| src/bosh-monitor/pkg/events/metric.go | Adds Go metric model. |
| src/bosh-monitor/pkg/events/events_suite_test.go | Adds Ginkgo suite for events package. |
| src/bosh-monitor/pkg/events/base.go | Adds Go event factory/validation helpers. |
| src/bosh-monitor/pkg/director/director_suite_test.go | Adds Ginkgo suite for director package. |
| src/bosh-monitor/pkg/director/auth.go | Adds Go auth provider logic (basic + UAA token flow, CA selection). |
| src/bosh-monitor/pkg/config/config.go | Adds Go config loader with defaults/validation. |
| src/bosh-monitor/pkg/config/config_suite_test.go | Adds Ginkgo suite for config package. |
| src/bosh-monitor/main.go | Adds Go entrypoint (-c config) with slog logging and signal handling. |
| src/bosh-monitor/lib/bosh/monitor/yaml_helper.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/version.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/resurrection_manager.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/protocols/tsdb_connection.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/protocols/tcp_connection.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/protocols/graphite_connection.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/tsdb.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/riemann.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/resurrector_helper.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/README.md | Removes Ruby plugin README (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/paging_datadog_client.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/pagerduty.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/logger.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/json.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/http_request_helper.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/graphite.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/event_logger.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/email.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/dummy.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/datadog.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/plugins/base.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/metric.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/instance.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/events/heartbeat.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/events/base.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/events/alert.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/event_processor.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/errors.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/director.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/director_monitor.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/deployment.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/core_ext.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/config.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/auth_provider.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/api_controller.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor/agent.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/lib/bosh/monitor.rb | Removes Ruby monitor implementation (deleted). |
| src/bosh-monitor/go.mod | Adds Go module definition for new monitor. |
| src/bosh-monitor/cmd/plugins/pluginlib/pluginlib.go | Adds shared plugin runtime library for out-of-process plugins. |
| src/bosh-monitor/cmd/plugins/pluginlib/pluginlib_test.go | Adds tests for plugin runtime library. |
| src/bosh-monitor/cmd/plugins/pluginlib/pluginlib_suite_test.go | Adds Ginkgo suite for pluginlib package. |
| src/bosh-monitor/cmd/plugins/hm-tsdb/main.go | Adds TSDB plugin (Go) implementation. |
| src/bosh-monitor/cmd/plugins/hm-riemann/main.go | Adds Riemann plugin (Go) implementation. |
| src/bosh-monitor/cmd/plugins/hm-pagerduty/main.go | Adds PagerDuty plugin (Go) implementation. |
| src/bosh-monitor/cmd/plugins/hm-logger/main.go | Adds logger plugin (Go) implementation. |
| src/bosh-monitor/cmd/plugins/hm-json/main.go | Adds JSON fanout plugin (Go) implementation. |
| src/bosh-monitor/cmd/plugins/hm-graphite/main.go | Adds Graphite plugin (Go) implementation. |
| src/bosh-monitor/cmd/plugins/hm-event-logger/main.go | Adds event-logger plugin (Go) implementation. |
| src/bosh-monitor/cmd/plugins/hm-dummy/main.go | Adds dummy plugin (Go) implementation. |
| src/bosh-monitor/cmd/plugins/hm-datadog/main.go | Adds Datadog plugin (Go) implementation. |
| src/bosh-monitor/.golangci.yml | Adds golangci-lint config for the new Go module. |
| packages/health_monitor/spec | Updates package spec to remove Ruby dependencies and ship new monitor sources. |
| packages/health_monitor/packaging | Updates packaging to build Go binary + plugins. |
| jobs/health_monitor/templates/health_monitor | Updates job launcher to run the Go binary (removes Ruby env). |
| jobs/health_monitor/templates/bpm.yml | Updates BPM config to run Go binary with args, removes Ruby env vars/volumes. |
| jobs/health_monitor/spec | Removes Ruby package dependency from health_monitor job. |
| .github/workflows/ruby.yml | Removes the Ruby monitor test matrix entry. |
| .github/workflows/go.yml | Adds lint/test jobs for the new Go bosh-monitor module. |
Comments suppressed due to low confidence (1)
packages/health_monitor/spec:6
go buildis invoked in this package, but the package spec declares no dependency that would provide a Go toolchain during BOSH compilation. Unless the compilation environment already hasgoavailable, this will fail to compile the release. Consider either (a) adding agolang-*package dependency, or (b) shipping prebuilt binaries (like other packages in this release) and removing the compile-timego buildrequirement.
---
name: health_monitor
files:
- bosh-monitor/**/*
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
327b3f9 to
704df82
Compare
e88928d to
ca33a76
Compare
018013f to
9607fdc
Compare
a3a6c01 to
847679e
Compare
|
|
78f1f97 to
9e76d88
Compare
efe2265 to
db540af
Compare
31ec8b3 to
6e664c9
Compare
Vendor the golang-1.26-linux package from bosh-package-golang-release and declare it as a dependency of the health_monitor package so the Go toolchain is available during bosh release compilation. Also add bump-golang-package and bump-deps jobs to the CI pipeline. ai-assisted=yes [TNZ-113909] Convert BOSH health monitor job to Golang
6e664c9 to
b17d803
Compare
Replace the Ruby bosh-monitor implementation with an idiomatic Go binary,
removing all Ruby source, Gemfile, and bundler configuration. The Go binary
is built and deployed through the existing BOSH health_monitor job and
package, with no changes to the BOSH release interface.
Authentication and security:
- Mirror Ruby AuthProvider behaviour: prefer uaa_ca_cert over director_ca_cert
for UAA token requests when the file exists and is non-empty
- Mirror Ruby UAAToken decode_options: when uaa_public_key is configured,
verify the UAA JWT RS256 signature; when empty, skip verification
- verifyJWTRS256 parses PEM public key and checks PKCS1v15 signature
- Use proper TLS peer verification (no VERIFY_NONE) via tlsConfigForCAFile
- Retry NATS connections up to connection_wait_timeout (default 60 s) so
the monitor survives a slow NATS start
Go test coverage for all major components:
- NATS client TLS configuration and connection retry
- DirectorMonitor message handling
- AuthProvider UAA token flow, CA cert selection, JWT RS256 verification
- AlertTracker meltdown logic
- Agent timeout and rogue agent thresholds
- Heartbeat team-change tracking and manager event processing
- All 11 bosh-monitor plugins
- Runner startup and signal handling
Bug fixes for parity and correctness:
- Fix resurrector meltdown: pass total_agent_count in deployment_health
alert so the resurrector computes an accurate unhealthy percentage
- Fix critical concurrency, liveness, and packaging issues
- Fix email plugin: use STARTTLS; correct severity mapping
- Fix TOCTOU double file-read in tlsConfigForCAFile
- Cache UAA http.Client to prevent connection pool leaks
- Guard email goroutine sends with context cancellation
- Reset restartAttempts after long-lived successful run
- Scope resurrector unhealthy count per deployment
- Emit explicit alert when resurrection is disabled
- Change Agent.NumberOfProcesses to *int for Ruby parity
- Fix race: resurrector must not recreate during delete-deployment
Idiomatic Go improvements:
- Type the director API response boundary (deployments/instances)
- Type the event-processing seam and plugin alert contract
- Remove dead Attributes()/Attrs map; type NumberOfProcesses field
- Document *int fields, name channel constants, use NotifyContext
- Make HTTP server bind address configurable via http.host
- Eliminate 30-second mutex hold in AuthProvider using double-checked locking
- Use ordered slice for NATS subjects; unsubscribe on failure
- Multi-error config validation using errors.Join
- Narrow Event interface to {ID, Kind, Validate}
- Type the emit_alert payload in the plugin protocol
- Replace sync.Map with map+Mutex for HTTP response tracking
- Add optional ca_cert support to PagerDuty plugin
Also fix integration spec compatibility:
- Add number_of_processes to EventData; filter heartbeats in spec
- Fix hm_stateless_spec.rb loop to use inline filter and include matcher
ai-assisted=yes
[TNZ-113909] Convert BOSH health monitor job to Golang
Add rake fly:bats task that uses Concourse fly execute to run acceptance tests against the local branch without a full pipeline trigger. Includes a workaround for a Go 1.26.3 compilation issue in the inline Concourse compile step. ai-assisted=yes [TNZ-113909] Convert BOSH health monitor job to Golang
b17d803 to
a4fa7ea
Compare
Summary
This PR replaces the Ruby `bosh-monitor` implementation with a new Go-based binary that provides the same functionality, including:
Changes
Test plan