Skip to content

Commit 327b3f9

Browse files
committed
Golang bosh-monitor via Cursor
Replace the Ruby bosh-monitor implementation with a Go-based binary. Changes: - Add Go bosh-monitor implementation under src/bosh-monitor/ - Delete Ruby bosh-monitor source (lib/, spec/, bin/, gemspec) - Remove bosh-monitor gem from src/Gemfile and Gemfile.lock - Update jobs/health_monitor/ to use Go binary (remove director-ruby-3.3 dep) - Update packages/health_monitor/ to compile Go binary via go build - Update .github/workflows/go.yml to test and lint src/bosh-monitor/ - Update .github/workflows/ruby.yml to remove monitor:parallel (Ruby deleted) - Add integration test support: BoshMonitorManager builds Go binary for sandbox - Fix hm-logger plugin output format to match Ruby logger for integration tests - Update hm_stateless_spec.rb JSON heartbeat parsing to match Go slog format - Fix sandbox health_monitor_without_resurrector.yml.erb (remove nats plugin) - Ensure TLS peer verification with director_ca_cert and uaa_ca_cert - Implement NATS connection retry logic during startup - Align DataDog pagerduty_service_name routing with Ruby implementation - Align Riemann severity string mapping with Ruby implementation
1 parent 9bc7d9d commit 327b3f9

160 files changed

Lines changed: 7953 additions & 9599 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/go.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,34 @@ jobs:
1313
- uses: golangci/golangci-lint-action@v9
1414
with:
1515
working-directory: src/brats/
16+
17+
bosh-monitor-lint:
18+
name: bosh-monitor lint
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
steps:
23+
- uses: actions/checkout@v7
24+
- uses: actions/setup-go@v6
25+
with:
26+
go-version-file: src/bosh-monitor/go.mod
27+
- uses: golangci/golangci-lint-action@v9
28+
with:
29+
working-directory: src/bosh-monitor/
30+
31+
bosh-monitor-test:
32+
name: bosh-monitor test
33+
runs-on: ubuntu-latest
34+
permissions:
35+
contents: read
36+
steps:
37+
- uses: actions/checkout@v7
38+
- uses: actions/setup-go@v6
39+
with:
40+
go-version-file: src/bosh-monitor/go.mod
41+
- name: Run tests
42+
working-directory: src/bosh-monitor
43+
run: go test ./...
44+
- name: Build binary
45+
working-directory: src/bosh-monitor
46+
run: go build -o bin/bosh-monitor .

.github/workflows/ruby.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ jobs:
88
matrix:
99
sub_project:
1010
- common:parallel
11-
- monitor:parallel
1211
- nats_sync:parallel
1312
- release
1413
steps:

jobs/health_monitor/spec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ templates:
1313

1414
packages:
1515
- health_monitor
16-
- director-ruby-3.3
1716

1817
properties:
1918
#

jobs/health_monitor/templates/bpm.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
<%=
22
health_monitor_config = {
33
"name" => "health_monitor",
4-
"executable" => "/var/vcap/jobs/health_monitor/bin/health_monitor",
5-
"env" => {
6-
"BUNDLE_GEMFILE" => "/var/vcap/packages/health_monitor/Gemfile",
7-
"GEM_HOME" => "/var/vcap/packages/health_monitor/gem_home/ruby/3.3.0",
8-
},
4+
"executable" => "/var/vcap/packages/health_monitor/bin/bosh-monitor",
5+
"args" => ["-c", "/var/vcap/jobs/health_monitor/config/health_monitor.yml"],
6+
"env" => {},
97
"unsafe" => {
108
"unrestricted_volumes" => [
119
{
1210
# contains the symlinks to the actual jobs under /var/vcap/data/jobs/[name]/[sha]/...
1311
# without this we don't know which "version" of a job to use
1412
"path" => "/var/vcap/jobs",
1513
},
16-
{
17-
"path" => "/var/vcap/data/jobs/*/*/bin/bosh-monitor",
18-
"allow_executions" => true,
19-
},
2014
{
2115
"path" => "/var/vcap/sys/log",
2216
"writable" => true,
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#!/bin/bash
22

3-
source /var/vcap/packages/director-ruby-3.3/bosh/runtime.env
43
exec /var/vcap/packages/health_monitor/bin/bosh-monitor -c /var/vcap/jobs/health_monitor/config/health_monitor.yml

packages/health_monitor/packaging

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
set -e
22

3-
mkdir -p ${BOSH_INSTALL_TARGET}/{bin,gem_home}
3+
mkdir -p "${BOSH_INSTALL_TARGET}/bin"
44

5-
source /var/vcap/packages/director-ruby-3.3/bosh/compile.env
5+
cd bosh-monitor
6+
go build -o "${BOSH_INSTALL_TARGET}/bin/bosh-monitor" .
67

7-
cat > Gemfile <<EOF
8-
# Explicitly require vendored version to avoid requiring builtin json gem
9-
gem 'json', '~>2'
10-
gem 'bosh-monitor'
11-
EOF
12-
13-
for gemspec in $( find . -maxdepth 2 -name *.gemspec ); do
14-
gem_name="$( basename "$( dirname "$gemspec" )" )"
15-
gem_spec="$( basename "$gemspec" )"
16-
17-
pushd "$gem_name"
18-
gem build "$gem_spec"
19-
mv *.gem ../vendor/cache
20-
popd > /dev/null
8+
for plugin_dir in cmd/plugins/hm-*; do
9+
plugin_name="$(basename "${plugin_dir}")"
10+
go build -o "${BOSH_INSTALL_TARGET}/bin/${plugin_name}" "./${plugin_dir}"
2111
done
22-
23-
bosh_bundle_local
24-
25-
cp Gemfile ${BOSH_INSTALL_TARGET}
26-
cp Gemfile.lock ${BOSH_INSTALL_TARGET}

packages/health_monitor/spec

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
---
22
name: health_monitor
3-
dependencies:
4-
- director-ruby-3.3
53

64
files:
75
- bosh-monitor/**/*
8-
- bosh-common/**/*
9-
- vendor/cache/*.gem
10-
- vendor/cache/extensions/**

src/Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
source 'https://rubygems.org'
22

33
gem 'bosh-director', path: 'bosh-director'
4-
gem 'bosh-monitor', path: 'bosh-monitor'
54
gem 'bosh-nats-sync', path: 'bosh-nats-sync'
65
gem 'bosh-common', path: 'bosh-common'
76

src/Gemfile.lock

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,6 @@ PATH
3737
tzinfo-data
3838
unix-crypt
3939

40-
PATH
41-
remote: bosh-monitor
42-
specs:
43-
bosh-monitor (0.0.0)
44-
async
45-
async-http
46-
bosh-common
47-
cf-uaa-lib
48-
dogapi
49-
io-stream
50-
logging
51-
nats-pure
52-
net-smtp
53-
openssl
54-
ostruct
55-
puma
56-
riemann-client
57-
securerandom
58-
sinatra
59-
6040
PATH
6141
remote: bosh-nats-sync
6242
specs:
@@ -348,7 +328,6 @@ DEPENDENCIES
348328
async-rspec
349329
bosh-common!
350330
bosh-director!
351-
bosh-monitor!
352331
bosh-nats-sync!
353332
bundle-audit
354333
factory_bot

src/bosh-monitor/.golangci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: "2"
2+
3+
linters:
4+
default: standard
5+
6+
settings:
7+
errcheck:
8+
exclude-functions:
9+
- (io.Closer).Close
10+
- (io.ReadCloser).Close
11+
- (net.Conn).Close
12+
- (net.Listener).Close
13+
- (*os.File).Close
14+
- (os/exec.Cmd).Wait
15+
16+
exclusions:
17+
rules:
18+
- path: _test\.go
19+
linters:
20+
- errcheck
21+
22+
formatters:
23+
enable:
24+
- goimports

0 commit comments

Comments
 (0)