Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bonzofenix committed Jun 19, 2024
1 parent 3d80cce commit d238e52
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 36 deletions.
7 changes: 7 additions & 0 deletions ci/autoscaler/scripts/deploy-autoscaler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ function setup_autoscaler_uaac(){
local uaac_authorities="cloud_controller.read,cloud_controller.admin,uaa.resource,routing.routes.write,routing.routes.read,routing.router_groups.read"
local autoscaler_secret="autoscaler_client_secret"
local uaa_client_secret=$(credhub get -n /bosh-autoscaler/cf/uaa_admin_client_secret --quiet)
# Check if uaac gem is installed
#
if ! gem list -i "cf-uaac" > /dev/null; then
echo "cf-uaac gem is not installed. Please install it by running 'gem install cf-uaac'"
exit 1
fi

uaac target "https://uaa.${system_domain}" --skip-ssl-validation > /dev/null
uaac token client get admin -s "${uaa_client_secret}" > /dev/null

Expand Down
3 changes: 0 additions & 3 deletions jobs/eventgenerator/spec
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@ properties:
description: "Number of consecutive failure to trip the circuit down"
default: 3

autoscaler.eventgenerator.health.port:
description: "the listening port of health endpoint"
default: 6204
autoscaler.eventgenerator.health.ca_cert:
description: "PEM-encoded CA certificate for the health endpoint"
autoscaler.eventgenerator.health.server_cert:
Expand Down
4 changes: 2 additions & 2 deletions jobs/operator/spec
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ properties:
description: "lock db retry interval"
default: 5s

autoscaler.operator.health.port:
description: "the listening port of health endpoint"
autoscaler.operator.server.port:
description: "the listening port of server"
default: 6208
autoscaler.operator.health.ca_cert:
description: "PEM-encoded CA certificate for the health endpoint"
Expand Down
6 changes: 0 additions & 6 deletions jobs/scalingengine/spec
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ properties:
autoscaler.cf.max_idle_conns_per_host_ms:
description: "Controls the maximum idle (keep-alive) connections to keep pooled per-host. If zero, golang default (2) is used. A negative value will mean no idle connection pool reuse."
default: 200

autoscaler.scalingengine.logging.level:
description: "the level of logging"
default: "info"
Expand All @@ -168,11 +167,6 @@ properties:
description: "PEM-encoded server certificate"
autoscaler.scalingengine.server_key:
description: "PEM-encoded server key"


autoscaler.scalingengine.health.port:
description: "the listening port of health endpoint"
default: 6204
autoscaler.scalingengine.health.ca_cert:
description: "PEM-encoded CA certificate for the health endpoint"
autoscaler.scalingengine.health.server_cert:
Expand Down
15 changes: 0 additions & 15 deletions src/autoscaler/healthendpoint/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/tedsuo/ifrit"
"golang.org/x/crypto/bcrypt"
)

Expand All @@ -59,20 +58,6 @@ func (bam *basicAuthenticationMiddleware) middleware(next http.Handler) http.Han
})
}

// NewServerWithBasicAuth open the healthcheck port with basic authentication.
// Make sure that username and password is not empty
func NewServerWithBasicAuth(conf helpers.HealthConfig, healthCheckers []Checker, logger lager.Logger, gatherer prometheus.Gatherer, time func() time.Time) (ifrit.Runner, error) {
healthRouter, err := NewHealthRouter(conf, healthCheckers, logger, gatherer, time)
if err != nil {
return nil, err
}
httpServerConfig := helpers.ServerConfig{
Port: conf.Port,
TLS: conf.TLS,
}
return helpers.NewHTTPServer(logger, httpServerConfig, healthRouter)
}

func NewHealthRouter(conf helpers.HealthConfig, healthCheckers []Checker, logger lager.Logger, gatherer prometheus.Gatherer, time func() time.Time) (*mux.Router, error) {
var healthRouter *mux.Router
var err error
Expand Down
1 change: 0 additions & 1 deletion src/autoscaler/helpers/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
)

type HealthConfig struct {
ServerConfig `yaml:",inline"`
HealthCheckUsername string `yaml:"username"`
HealthCheckUsernameHash string `yaml:"username_hash"`
HealthCheckPassword string `yaml:"password"`
Expand Down
12 changes: 10 additions & 2 deletions src/autoscaler/operator/cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"flag"
"fmt"
"os"
"time"

"code.cloudfoundry.org/app-autoscaler/src/autoscaler/cf"
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/db"
Expand Down Expand Up @@ -144,7 +143,16 @@ func main() {
})
members = append(grouper.Members{{"db-lock-maintainer", dbLockMaintainer}}, members...)

healthServer, err := healthendpoint.NewServerWithBasicAuth(conf.Health, []healthendpoint.Checker{}, logger.Session("health-server"), promRegistry, time.Now)
healthRouter, err := healthendpoint.NewHealthRouter(conf, healthCheckers, logger, gatherer, time)
if err != nil {
return nil, err
}
httpServerConfig := helpers.ServerConfig{
Port: conf.Server.Port,
TLS: conf.Server.TLS,
}

healthServer, err := helpers.NewHTTPServer(logger, httpServerConfig, healthRouter)
if err != nil {
logger.Error("failed to create health server", err)
os.Exit(1)
Expand Down
16 changes: 9 additions & 7 deletions templates/app-autoscaler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ instance_groups:
client_id: "((cf_client_id))"
secret: "((cf_client_secret))"
skip_ssl_validation: "((skip_ssl_validation))"
sever:
port: &scalingEngineServerPort 6104
scalingengine:
health:
port: &scalingEngineHealthPort 6204
username: scalingengine
password: ((autoscaler_scalingengine_health_password))
logging:
Expand All @@ -209,7 +209,7 @@ instance_groups:
routes:
- name: autoscaler_scalingengine_health
registration_interval: 20s
port: *scalingEngineHealthPort
port: *scalingEngineServerPort
tags:
component: autoscaler_scalingengine_health
uris:
Expand Down Expand Up @@ -377,9 +377,10 @@ instance_groups:
scheduler.host: *scheduler_domain
cf: *cf_credentials
operator:
server:
port: &operatorServerPort 6208
enable_db_lock: true
health:
port: &operatorHealthPort 6208
username: operator
password: ((autoscaler_operator_health_password))
scaling_engine:
Expand All @@ -403,7 +404,7 @@ instance_groups:
routes:
- name: autoscaler_operator_health
registration_interval: 20s
port: *operatorHealthPort
port: *operatorServerPort
tags:
component: autoscaler_operator_health
uris:
Expand All @@ -429,8 +430,9 @@ instance_groups:
policy_db_connection_config: *databaseConnectionConfig
lock_db: *database
eventgenerator:
server:
port: &eventGeneratorServerPort 6105
health:
port: &eventGeneratorHealthPort 6205
username: eventgenerator
password: ((autoscaler_eventgenerator_health_password))
logging:
Expand Down Expand Up @@ -459,7 +461,7 @@ instance_groups:
routes:
- name: autoscaler_eventgenerator_health
registration_interval: 20s
port: *eventGeneratorHealthPort
port: *eventGeneratorServerPort
tags:
component: autoscaler_eventgenerator_health
uris:
Expand Down

0 comments on commit d238e52

Please sign in to comment.