Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,34 @@ jobs:
- uses: golangci/golangci-lint-action@v9
with:
working-directory: src/brats/

bosh-monitor-lint:
name: bosh-monitor lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v6
with:
go-version-file: src/bosh-monitor/go.mod
- uses: golangci/golangci-lint-action@v9
with:
working-directory: src/bosh-monitor/

bosh-monitor-test:
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
name: bosh-monitor test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v6
with:
go-version-file: src/bosh-monitor/go.mod
- name: Run tests
working-directory: src/bosh-monitor
run: go test ./...
- name: Build binary
working-directory: src/bosh-monitor
run: go build -o bin/bosh-monitor .
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
1 change: 0 additions & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ jobs:
matrix:
sub_project:
- common:parallel
- monitor:parallel
- nats_sync:parallel
- release
steps:
Expand Down
28 changes: 27 additions & 1 deletion ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1321,14 +1321,22 @@ jobs:
- get: bosh
- get: golang-release
- get: integration-image
- task: bump-deps
- task: bump-brats-deps
file: golang-release/ci/tasks/shared/bump-deps.yml
input_mapping:
input_repo: bosh
output_mapping:
output_repo: bosh-out
params:
SOURCE_PATH: src/brats/
- task: bump-bosh-monitor-deps
file: golang-release/ci/tasks/shared/bump-deps.yml
input_mapping:
input_repo: bosh-out
output_mapping:
output_repo: bosh-out
params:
SOURCE_PATH: src/bosh-monitor/
- task: lint-brats
file: bosh-ci/ci/tasks/lint-brats.yml
image: integration-image
Expand All @@ -1346,6 +1354,8 @@ jobs:
- get: bosh-ci
- get: integration-image
- get: bosh
- get: golang-release
trigger: true
- get: nginx-release
trigger: true
- get: mariadb-connector-c-resource
Expand Down Expand Up @@ -1450,6 +1460,22 @@ jobs:
credentials_source: static
json_key: '((gcp_json_key))'
RUBY_VERSION_PATH: src/.ruby-version
- task: bump-golang-package
file: golang-release/ci/tasks/shared/bump-golang-package.yml
input_mapping:
input_repo: bosh-out
output_mapping:
output_repo: bosh-out
params:
GIT_USER_NAME: *git_user_name
GIT_USER_EMAIL: *git_user_email
PACKAGES: '["golang-1.26-linux"]'
PACKAGES_TO_REMOVE: '[]'
PRIVATE_YML: |
blobstore:
options:
credentials_source: static
json_key: '((gcp_json_key))'
- task: bump-bosh-blobstore-dav
file: bosh-ci/ci/tasks/bump-blobstore-cli.yml
image: integration-image
Expand Down
1 change: 0 additions & 1 deletion jobs/health_monitor/spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ templates:

packages:
- health_monitor
- director-ruby-3.3

properties:
#
Expand Down
10 changes: 3 additions & 7 deletions jobs/health_monitor/templates/bpm.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<%=
health_monitor_config = {
"name" => "health_monitor",
"executable" => "/var/vcap/jobs/health_monitor/bin/health_monitor",
"executable" => "/var/vcap/packages/health_monitor/bin/bosh-monitor",
"args" => ["-c", "/var/vcap/jobs/health_monitor/config/health_monitor.yml"],
"env" => {
"BUNDLE_GEMFILE" => "/var/vcap/packages/health_monitor/Gemfile",
"GEM_HOME" => "/var/vcap/packages/health_monitor/gem_home/ruby/3.3.0",
"PATH" => "/var/vcap/packages/health_monitor/bin:/bin:/usr/bin:/sbin:/usr/sbin",
},
"unsafe" => {
"unrestricted_volumes" => [
Expand All @@ -13,10 +13,6 @@ health_monitor_config = {
# without this we don't know which "version" of a job to use
"path" => "/var/vcap/jobs",
},
{
"path" => "/var/vcap/data/jobs/*/*/bin/bosh-monitor",
"allow_executions" => true,
},
{
"path" => "/var/vcap/sys/log",
"writable" => true,
Expand Down
1 change: 0 additions & 1 deletion jobs/health_monitor/templates/health_monitor
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash

source /var/vcap/packages/director-ruby-3.3/bosh/runtime.env
exec /var/vcap/packages/health_monitor/bin/bosh-monitor -c /var/vcap/jobs/health_monitor/config/health_monitor.yml
3 changes: 3 additions & 0 deletions jobs/health_monitor/templates/health_monitor.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ params = {
},
{
'name' => 'event_logger',
'executable' => 'hm-event-logger',
'events' => [
'alert',
],
Expand Down Expand Up @@ -162,6 +163,7 @@ end
if p('hm.datadog_enabled')
datadog_plugin = {
'name' => 'data_dog',
'executable' => 'hm-datadog',
'events' => [
'alert',
'heartbeat',
Expand Down Expand Up @@ -206,6 +208,7 @@ end
if p('hm.consul_event_forwarder_enabled')
consul_event_forwarder_plugin = {
'name' => 'consul_event_forwarder',
'executable' => 'hm-consul',
'events' => [
'alert',
'heartbeat',
Expand Down
42 changes: 23 additions & 19 deletions packages/health_monitor/packaging
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
set -e

mkdir -p ${BOSH_INSTALL_TARGET}/{bin,gem_home}
# Use the Go toolchain from a vendored golang BOSH package if available.
# When the golang-1.26-linux package is present, source its compile.env
# to set PATH/GOROOT/etc. the same way other BOSH releases do.
for pkg in "${BOSH_PACKAGES_DIR}"/golang-*; do
if [ -f "${pkg}/bosh/compile.env" ]; then
# shellcheck disable=SC1091
source "${pkg}/bosh/compile.env"
break
fi
done

source /var/vcap/packages/director-ruby-3.3/bosh/compile.env
if ! command -v go >/dev/null 2>&1; then
echo "ERROR: Go toolchain not found." >&2
echo " Add a golang-* BOSH package as a dependency in packages/health_monitor/spec" >&2
echo " or ensure 'go' is available on PATH." >&2
exit 1
fi

cat > Gemfile <<EOF
# Explicitly require vendored version to avoid requiring builtin json gem
gem 'json', '~>2'
gem 'bosh-monitor'
EOF
echo "Using $(go version)"
mkdir -p "${BOSH_INSTALL_TARGET}/bin"

for gemspec in $( find . -maxdepth 2 -name *.gemspec ); do
gem_name="$( basename "$( dirname "$gemspec" )" )"
gem_spec="$( basename "$gemspec" )"
cd bosh-monitor
go build -o "${BOSH_INSTALL_TARGET}/bin/bosh-monitor" .

pushd "$gem_name"
gem build "$gem_spec"
mv *.gem ../vendor/cache
popd > /dev/null
for plugin_dir in cmd/plugins/hm-*; do
plugin_name="$(basename "${plugin_dir}")"
go build -o "${BOSH_INSTALL_TARGET}/bin/${plugin_name}" "./${plugin_dir}"
Comment thread
aramprice marked this conversation as resolved.
done

bosh_bundle_local

cp Gemfile ${BOSH_INSTALL_TARGET}
cp Gemfile.lock ${BOSH_INSTALL_TARGET}
5 changes: 0 additions & 5 deletions packages/health_monitor/spec
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
---
name: health_monitor
dependencies:
- director-ruby-3.3

files:
- bosh-monitor/**/*
- bosh-common/**/*
- vendor/cache/*.gem
- vendor/cache/extensions/**
1 change: 0 additions & 1 deletion src/Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
source 'https://rubygems.org'

gem 'bosh-director', path: 'bosh-director'
gem 'bosh-monitor', path: 'bosh-monitor'
gem 'bosh-nats-sync', path: 'bosh-nats-sync'
gem 'bosh-common', path: 'bosh-common'

Expand Down
21 changes: 0 additions & 21 deletions src/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,6 @@ PATH
tzinfo-data
unix-crypt

PATH
remote: bosh-monitor
specs:
bosh-monitor (0.0.0)
async
async-http
bosh-common
cf-uaa-lib
dogapi
io-stream
logging
nats-pure
net-smtp
openssl
ostruct
puma
riemann-client
securerandom
sinatra

PATH
remote: bosh-nats-sync
specs:
Expand Down Expand Up @@ -348,7 +328,6 @@ DEPENDENCIES
async-rspec
bosh-common!
bosh-director!
bosh-monitor!
bosh-nats-sync!
bundle-audit
factory_bot
Expand Down
24 changes: 24 additions & 0 deletions src/bosh-monitor/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "2"

linters:
default: standard

settings:
errcheck:
exclude-functions:
- (io.Closer).Close
- (io.ReadCloser).Close
- (net.Conn).Close
- (net.Listener).Close
- (*os.File).Close
- (os/exec.Cmd).Wait

exclusions:
rules:
- path: _test\.go
linters:
- errcheck

formatters:
enable:
- goimports
Loading
Loading