Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go buildpack #3150

Merged
merged 47 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
dee019f
Uses envconfig package to get port from environment variable
bonzofenix Jun 27, 2024
30445c4
Refactor: give priority to env variables over yaml configs
bonzofenix Jun 27, 2024
3b87b76
WIP
bonzofenix Jun 28, 2024
b6383a2
Change build-cf tasks to cf-build to avoid conflicts
bonzofenix Jul 1, 2024
319dc64
Update git ignore to try issue with telescope
bonzofenix Jul 1, 2024
7646711
WIP
bonzofenix Jul 1, 2024
b6abe7c
Merge branch 'main' into metricsforwarder-mtar
bonzofenix Aug 9, 2024
8e3ac4a
Update go-chi/chi to v5.1.0 and add mitchellh/mapstructure v1.1.2 in …
bonzofenix Aug 9, 2024
5c73f35
Refactor error variable names and update associated tests in metricsf…
bonzofenix Aug 9, 2024
75dcb82
Add nosec comment to bypass G101 security warning in metricsforwarder…
bonzofenix Aug 9, 2024
be6e1cc
Remove package-lock.json and package.json from autoscaler module
bonzofenix Aug 9, 2024
ce1d1ef
Change deployment directory and use mta-deploy in deploy-apps.sh
bonzofenix Aug 9, 2024
7b013e5
Merge branch 'main' into metricsforwarder-mtar
bonzofenix Aug 9, 2024
0b3a3b6
merge
bonzofenix Aug 16, 2024
70d33a8
Merge branch 'main' into metricsforwarder-mtar
bonzofenix Aug 16, 2024
0295e54
Remove envconfig dependency
bonzofenix Aug 16, 2024
463beb4
🤖🦾🛠️ go mod tidy & make package-specs
bonzofenix Aug 16, 2024
e70dbea
Refactor config loading and add VCAP_SERVICES support in metricsforwa…
bonzofenix Aug 19, 2024
9959d71
Add early return for existing DB config in metricsforwarder config re…
bonzofenix Aug 19, 2024
405afcd
Refactor metricsforwarder config loading with JSON support
bonzofenix Aug 20, 2024
08caa08
Merge branch 'main' into metricsforwarder-mtar
bonzofenix Aug 21, 2024
ef8ebd0
🤖🦾🛠️ go mod tidy & make package-specs
bonzofenix Aug 21, 2024
10499bd
Refactor deployment scripts and Makefiles for autoscaler
bonzofenix Aug 27, 2024
cc2050b
Refactor VCAPConfiguration and error handling in cf.go
bonzofenix Aug 27, 2024
905bf21
Refactor metricsforwarder config loading and VCAP services handling
bonzofenix Aug 27, 2024
4f29509
Add configutil directory to metricsforwarder package spec
bonzofenix Aug 27, 2024
a1bca62
t push Add error handling for VCAP configuration reading in metricsfo…
bonzofenix Aug 27, 2024
255b63c
Remove unnecessary blank line in config.go and annotate potential sec…
bonzofenix Aug 27, 2024
e7be050
Add nosec comment to suppress G101 warning in metricsforwarder config…
bonzofenix Aug 27, 2024
ee45629
Add nosec comment to suppress false positive in config_test security …
bonzofenix Aug 27, 2024
0e0dbf4
Remove unused error variable and update error handling in VCAP config
bonzofenix Aug 27, 2024
9d5e2a2
Update VCAPConfiguration to return JSON marshaled credential content
bonzofenix Aug 27, 2024
9756c37
fix failing tests
bonzofenix Aug 28, 2024
47f5970
Refactor VCAPConfiguration methods to use service tags instead of names
bonzofenix Aug 28, 2024
3484259
Update go-cfenv package and dependencies
bonzofenix Aug 28, 2024
b62e9fb
Remove cf-build target from go_app Makefile
bonzofenix Aug 28, 2024
1fad7aa
Fix lints
bonzofenix Aug 28, 2024
599a230
Fix issue with metricsforwarder config test
bonzofenix Aug 28, 2024
8e3ca6a
Merge branch 'main' into metricsforwarder-mtar
bonzofenix Aug 28, 2024
2f54db1
Update app autoscaler release tools image source to bonzofenix reposi…
bonzofenix Aug 28, 2024
346a8dc
Update base image in autoscaler-tools Dockerfile to ubuntu:mantic
bonzofenix Aug 28, 2024
cee35f8
Update credhub-cli to 2.9.35 and add plugin_version to ruby in devbo…
bonzofenix Aug 28, 2024
e5116b5
Fix tests run in github ci
bonzofenix Aug 28, 2024
f095fc0
Remove netcat from autoscaler-tools Dockerfile dependencies
bonzofenix Aug 28, 2024
638971b
Merge branch 'main' into metricsforwarder-mtar
bonzofenix Aug 28, 2024
640bb13
Try noble image for ci
bonzofenix Aug 28, 2024
97ebe68
Update app autoscaler release tools image source to ghcr.io
bonzofenix Aug 28, 2024
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
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -453,5 +453,7 @@ go-get-u: $(addsuffix .go-get-u,$(go_modules))
go get -u ./...


mta-deploy:
@make --directory='./src/autoscaler' mta-deploy
deploy-apps:
echo " - deploying apps"
DEBUG="${DEBUG}" ${CI_DIR}/autoscaler/scripts/deploy-apps.sh

4 changes: 4 additions & 0 deletions ci/autoscaler/scripts/deploy-apps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source "${script_dir}/common.sh"
source "${script_dir}/vars.source.sh"

pushd "${bbl_state_path}" > /dev/null
eval "$(bbl print-env)"
popd > /dev/null

function deploy() {
log "Deploying autoscaler apps for bosh deployment '${deployment_name}' "
pushd "${autoscaler_dir}/src/autoscaler" > /dev/null
Expand Down
3 changes: 1 addition & 2 deletions ci/dockerfiles/autoscaler-tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:jammy
FROM ubuntu:noble
MAINTAINER autoscaler-team

ENV DEBIAN_FRONTEND="noninteractive" TZ="Europe/London"
Expand Down Expand Up @@ -36,7 +36,6 @@ RUN apt-get update && \
cf8-cli \
gnupg \
gnupg2 \
netcat \
gh \
make \
mysql-client && \
Expand Down
1 change: 0 additions & 1 deletion ci/infrastructure/scripts/deploy-multiapps-controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function deploy_multiapps_controller() {
mv multiapps-controller-web-war/*.war .
pushd multiapps-controller-web-manifest
cf push -f ./*.yml "${app_name}"

popd
}

Expand Down
2 changes: 1 addition & 1 deletion devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bundix": "latest",
"cloudfoundry-cli": "8.7.11",
"coreutils": "latest",
"credhub-cli": "2.9.29",
"credhub-cli": "2.9.35",
"delve": "latest",
"direnv": "2.34.0",
"fly": "7.10.0",
Expand Down
25 changes: 13 additions & 12 deletions devbox.lock
Original file line number Diff line number Diff line change
Expand Up @@ -313,51 +313,51 @@
}
}
},
"[email protected].29": {
"last_modified": "2024-05-29T10:04:41Z",
"resolved": "github:NixOS/nixpkgs/ac82a513e55582291805d6f09d35b6d8b60637a1#credhub-cli",
"[email protected].35": {
"last_modified": "2024-08-14T11:41:26Z",
"resolved": "github:NixOS/nixpkgs/0cb2fd7c59fed0cd82ef858cbcbdb552b9a33465#credhub-cli",
"source": "devbox-search",
"version": "2.9.29",
"version": "2.9.35",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/20xi78w44q6wn4847jrrlmxddyjycbrn-credhub-cli-2.9.29",
"path": "/nix/store/2xkv0vlafk8zgzjpz3yjagbgyv5kawkn-credhub-cli-2.9.35",
"default": true
}
],
"store_path": "/nix/store/20xi78w44q6wn4847jrrlmxddyjycbrn-credhub-cli-2.9.29"
"store_path": "/nix/store/2xkv0vlafk8zgzjpz3yjagbgyv5kawkn-credhub-cli-2.9.35"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/5hv8vj4dhy521m49sc4wwmaz2q319z9a-credhub-cli-2.9.29",
"path": "/nix/store/r0kkggv2kbdma8l2n177nl0sw4lwvqr5-credhub-cli-2.9.35",
"default": true
}
],
"store_path": "/nix/store/5hv8vj4dhy521m49sc4wwmaz2q319z9a-credhub-cli-2.9.29"
"store_path": "/nix/store/r0kkggv2kbdma8l2n177nl0sw4lwvqr5-credhub-cli-2.9.35"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/c5d2ggn5c819spywi74pzksbzds9ryym-credhub-cli-2.9.29",
"path": "/nix/store/wkgc414d175cv1pa3h257pm264ayk8if-credhub-cli-2.9.35",
"default": true
}
],
"store_path": "/nix/store/c5d2ggn5c819spywi74pzksbzds9ryym-credhub-cli-2.9.29"
"store_path": "/nix/store/wkgc414d175cv1pa3h257pm264ayk8if-credhub-cli-2.9.35"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/3y6r6lgrbaq8521hk3zbalf3gz3albcg-credhub-cli-2.9.29",
"path": "/nix/store/zkmy2g042p75p3i6qib6s1589qymrg3k-credhub-cli-2.9.35",
"default": true
}
],
"store_path": "/nix/store/3y6r6lgrbaq8521hk3zbalf3gz3albcg-credhub-cli-2.9.29"
"store_path": "/nix/store/zkmy2g042p75p3i6qib6s1589qymrg3k-credhub-cli-2.9.35"
}
}
},
Expand Down Expand Up @@ -1666,6 +1666,7 @@
},
"ruby@latest": {
"last_modified": "2024-08-14T11:41:26Z",
"plugin_version": "0.0.2",
"resolved": "github:NixOS/nixpkgs/0cb2fd7c59fed0cd82ef858cbcbdb552b9a33465#ruby_3_3",
"source": "devbox-search",
"version": "3.3.4",
Expand Down
8 changes: 3 additions & 5 deletions operations/use-cf-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
host: ((metricsforwarder_host))
mtls_host: ((metricsforwarder_host))

# Set the same port for metricsforwarder and healthenpoint routes
- type: replace
path: /instance_groups/name=metricsforwarder/jobs/name=route_registrar/properties/route_registrar/routes/name=autoscaler_metricsforwarder_health/port
value: 6201

## add router tcp route for postgres
- type: replace
path: /instance_groups/name=postgres/jobs/-
Expand Down Expand Up @@ -53,3 +48,6 @@
- type: replace
path: /variables/name=postgres_client/options/alternative_names/-
value: ((deployment_name))-postgres.tcp.((system_domain))

- type: remove
path: /instance_groups/name=metricsforwarder
3 changes: 3 additions & 0 deletions packages/metricsforwarder/spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ files:
- autoscaler/*
- autoscaler/vendor/*
- autoscaler/cf/* # gosub
- autoscaler/configutil/* # gosub
- autoscaler/cred_helper/* # gosub
- autoscaler/db/* # gosub
- autoscaler/db/sqldb/* # gosub
Expand Down Expand Up @@ -44,6 +45,7 @@ files:
- autoscaler/vendor/github.com/andybalholm/brotli/matchfinder/* # gosub
- autoscaler/vendor/github.com/beorn7/perks/quantile/* # gosub
- autoscaler/vendor/github.com/cespare/xxhash/v2/* # gosub
- autoscaler/vendor/github.com/cloud-gov/go-cfenv/* # gosub
- autoscaler/vendor/github.com/felixge/httpsnoop/* # gosub
- autoscaler/vendor/github.com/go-logr/logr/* # gosub
- autoscaler/vendor/github.com/go-logr/logr/funcr/* # gosub
Expand Down Expand Up @@ -81,6 +83,7 @@ files:
- autoscaler/vendor/github.com/klauspost/compress/zlib/* # gosub
- autoscaler/vendor/github.com/klauspost/compress/zstd/* # gosub
- autoscaler/vendor/github.com/klauspost/compress/zstd/internal/xxhash/* # gosub
- autoscaler/vendor/github.com/mitchellh/mapstructure/* # gosub
- autoscaler/vendor/github.com/munnerz/goautoneg/* # gosub
- autoscaler/vendor/github.com/openzipkin/zipkin-go/idgenerator/* # gosub
- autoscaler/vendor/github.com/openzipkin/zipkin-go/model/* # gosub
Expand Down
2 changes: 0 additions & 2 deletions src/acceptance/assets/app/go_app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ build: ./build/app ./build/manifest.yml
CGO_ENABLED='${CGO_ENABLED}' GOOS='linux' GOARCH='amd64' go build -o './build/app'
cp './app_manifest.yml' './build/manifest.yml'



.PHONY: build_tests
build_tests: $(addprefix build_test-,$(test_dirs))

Expand Down
11 changes: 4 additions & 7 deletions src/autoscaler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PACKAGE_DIRS = $(shell go list './...' | grep --invert-match --regexp='/vendor/'
DB_HOST ?= localhost
DBURL ?= "postgres://postgres:postgres@${DB_HOST}/autoscaler?sslmode=disable"

METRICSFORWARDER_APPNAME ?= "metricsforwarder"
MAKEFILE_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
EXTENSION_FILE := $(shell mktemp)

export GOWORK=off
Expand Down Expand Up @@ -154,14 +154,12 @@ clean:
.PHONY: mta-deploy
mta-deploy: mta-build build-extension-file
$(MAKE) -f metricsforwarder/Makefile set-security-group
$(MAKE) -f metricsforwarder/Makefile stop-metricsforwarder-vm
@echo "Deploying with extension file: $(EXTENSION_FILE)"
@cf deploy mta_archives/*.mtar -f -e $(EXTENSION_FILE)
@cf deploy mta_archives/*.mtar -f --delete-services -e $(EXTENSION_FILE)

build-extension-file:
cp example.mtaext $(EXTENSION_FILE);
sed -i "s/APP_NAME/$(METRICSFORWARDER_APPNAME)/g" $(EXTENSION_FILE);
echo "EXTENSION_FILE: $(EXTENSION_FILE)"
echo "extension file at: $(EXTENSION_FILE)"
$(MAKEFILE_DIR)/build-extension-file.sh $(EXTENSION_FILE);

mta-logs:
rm -rf mta-*
Expand All @@ -170,7 +168,6 @@ mta-logs:

.PHONY: mta-build
mta-build: mta-build-clean cf-build
$(MAKE) -f metricsforwarder/Makefile fetch-config
mbt build

mta-build-clean:
Expand Down
71 changes: 71 additions & 0 deletions src/autoscaler/build-extension-file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bash
# shellcheck disable=SC2155,SC2034,SC2086

set -e

if [ -z "$1" ]; then
echo "extension file path not provided"
exit 1
else
extension_file_path=$1
fi

if [ -z "${DEPLOYMENT_NAME}" ]; then
echo "DEPLOYMENT_NAME is not set"
exit 1
fi

if [ -z "${PR_NUMBER}" ]; then
echo "PR_NUMBER is not set"
exit 1
fi

export SYSTEM_DOMAIN="autoscaler.app-runtime-interfaces.ci.cloudfoundry.org"
export POSTGRES_ADDRESS="${DEPLOYMENT_NAME}-postgres.tcp.${SYSTEM_DOMAIN}"
export POSTGRES_EXTERNAL_PORT="${PR_NUMBER:-5432}"

export METRICSFORWARDER_HEALTH_PASSWORD="$(credhub get -n /bosh-autoscaler/${DEPLOYMENT_NAME}/autoscaler_metricsforwarder_health_password --quiet)"
export METRICSFORWARDER_APPNAME="${METRICSFORWARDER_APPNAME:-"${DEPLOYMENT_NAME}-metricsforwarder"}"

export POLICY_DB_PASSWORD="$(credhub get -n /bosh-autoscaler/${DEPLOYMENT_NAME}/database_password --quiet)"
export POLICY_DB_SERVER_CA="$(credhub get -n /bosh-autoscaler/${DEPLOYMENT_NAME}/postgres_server --key ca --quiet )"
export POLICY_DB_CLIENT_CERT="$(credhub get -n /bosh-autoscaler/${DEPLOYMENT_NAME}/postgres_server --key certificate --quiet)"
export POLICY_DB_CLIENT_KEY="$(credhub get -n /bosh-autoscaler/${DEPLOYMENT_NAME}/postgres_server --key private_key --quiet)"

export SYSLOG_CLIENT_CA="$(credhub get -n /bosh-autoscaler/cf/syslog_agent_log_cache_tls --key ca --quiet)"
export SYSLOG_CLIENT_CERT="$(credhub get -n /bosh-autoscaler/cf/syslog_agent_log_cache_tls --key certificate --quiet)"
export SYSLOG_CLIENT_KEY="$(credhub get -n /bosh-autoscaler/cf/syslog_agent_log_cache_tls --key private_key --quiet)"

cat <<EOF > "${extension_file_path}"
ID: development
extends: com.github.cloudfoundry.app-autoscaler-release
version: 1.0.0
_schema-version: 3.3.0

modules:
- name: metricsforwarder
parameters:
routes:
- route: ${METRICSFORWARDER_APPNAME}.\${default-domain}

resources:
- name: config
parameters:
config:
metricsforwarder:
health:
password: "${METRICSFORWARDER_HEALTH_PASSWORD}"
- name: policydb
parameters:
config:
uri: "postgres://postgres:${POLICY_DB_PASSWORD}@${POSTGRES_ADDRESS}:${POSTGRES_EXTERNAL_PORT}/autoscaler?application_name=metricsforwarder&sslmode=verify-full"
client_cert: "${POLICY_DB_CLIENT_CERT//$'\n'/\\n}"
client_key: "${POLICY_DB_CLIENT_KEY//$'\n'/\\n}"
server_ca: "${POLICY_DB_SERVER_CA//$'\n'/\\n}"
- name: syslog-client
parameters:
config:
client_cert: "${SYSLOG_CLIENT_CERT//$'\n'/\\n}"
client_key: "${SYSLOG_CLIENT_KEY//$'\n'/\\n}"
server_ca: "${SYSLOG_CLIENT_CA//$'\n'/\\n}"
EOF
Loading
Loading