Skip to content

Commit

Permalink
Merge pull request #18 from synackd/doc-env-vars
Browse files Browse the repository at this point in the history
Document env vars in Dockerfile, fix default debug flag, remove unused function
  • Loading branch information
synackd authored Feb 20, 2024
2 parents 3573b32 + df0fadb commit 11d3aaa
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 35 deletions.
86 changes: 79 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,98 @@ STOPSIGNAL SIGTERM

RUN apk add --no-cache tini

# URL of SMD (needed for confirming node existence).
ENV HSM_URL=http://smd:27779
# URL of notification daemon.
ENV NFD_URL=http://cray-hmnfd

# For cloud-init
# Address of cloud-init server to be added to kernel parameters.
ENV BSS_ADVERTISE_ADDRESS=localhost

# Use an insecure (no TLS) connection to Etcd or Postgres (whichever is used).
# WARNING: Our containers currently do not have certificates set up correctly
# to allow for https connections to other containers. Therefore, we
# will use an insecure connection. This needs to be corrected before
# release. Once the certificates are properly set up, the --insecure
# option needs to be removed.
# release. Once the certificates are properly set up, this can be
# set to false.
ENV BSS_INSECURE=true

# Seconds to sleep before retrying boot in iPXE boot script if boot fails
# for some reason.
ENV BSS_RETRY_DELAY=30
# Seconds to sleep before retrying iPXE boot in default boot script.
# This is for when Etcd is being used and we need to wait for node state to
# be updated before trying to boot.
ENV BSS_HSM_RETRIEVAL_DELAY=10

# Other potentially useful env variables:
# BSS_IPXE_SERVER defaults to "api-gw-service-nmn.local"
# BSS_CHAIN_PROTO defaults to "https"
# BSS_GW_URI defaults to "/apis/bss"
# Other potentially useful variables with default values:
#
# iPXE server to point nodes to.
# BSS_IPXE_SERVER=api-gw-service-nmn.local
#
# Protocol to use for chains in boot scripts.
# BSS_CHAIN_PROTO=https
#
# The name of BSS.
# BSS_SERVICE_NAME=boot-script-service
#
# Where BSS should listen to requests.
# BSS_HTTP_LISTEN=:27778
#
# URL to listen for notifications on.
# BSS_ENDPOINT_HOST=""
#
# URL of SPIRE token service (not necessary to run BSS).
# SPIRE_TOKEN_URL=https://spire-tokens.spire:54440

# Etcd variables with default values:
#
# Base URL of KV datastore (could alternatively specify by ETCD_HOST and
# ETCD_PORT below). By default, the in-memory datastore is used (all variables
# empty).
# DATASTORE_BASE=""
# ETCD_HOST=""
# ETCD_PORT=""
#
# Number of times to attempt connection to datastore before giving up.
# ETCD_RETRY_COUNT=10
#
# Seconds between connection attempts.
# ETCD_RETRY_WAIT=5

# Postgres variables with default values:
#
# Configure BSS to use Postgres instead of Etcd.
# Required to be true for the following variables to be used. Note that Postgres
# is disabled and Etcd is enabled by default.
# BSS_USESQL=false
#
# Enable BSS debugging messages.
# BSS_DEBUG=false
#
# Location of Postgres server.
# BSS_DBHOST=localhost
#
# Port of Postgres server.
# BSS_DBPORT=5432
#
# Name of BSS database in Postgres to connect to.
# BSS_DBNAME=bssdb
#
# Database options to pass to Postgres.
# BSS_DBOPTS=""
#
# Postgres username.
# BSS_DBUSER=bssuser
#
# Postgres user password.
# BSS_DBPASS=bssuser
#
# How many times to try to connect to Postgres before giving up.
# BSS_SQL_RETRY_COUNT=10
#
# Number of seconds between connection attempts to Postgres.
# BSS_SQL_RETRY_WAIT=5

# Include curl in the final image.
RUN set -ex \
Expand Down
29 changes: 1 addition & 28 deletions cmd/boot-script-service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var (
// this well known IP.
advertiseAddress = "" // i.e. http://{IP to reach this service}
insecure = false
debugFlag = true
debugFlag = false
kvstore hmetcd.Kvi
retryDelay = uint(30)
hsmRetrievalDelay = uint(10)
Expand Down Expand Up @@ -172,33 +172,6 @@ func kvDefaultRetryConfig() (retryCount uint64, retryWait uint64, err error) {
return retryCount, retryWait, nil
}

// Try to read SQL_RETRY_COUNT and SQL_RETRY_WAIT environment variables.
// If either variable contains an invalid value, return the default values of both.
func sqlDefaultRetryConfig() (retryCount uint64, retryWait uint64, err error) {
retryCount = sqlDefaultRetryCount
retryWait = sqlDefaultRetryWait

envRetryCount := os.Getenv("SQL_RETRY_COUNT")
if envRetryCount != "" {
retryCount, err = strconv.ParseUint(envRetryCount, 10, 64)
if err != nil {
err = fmt.Errorf("ERROR: unable to parse SQL_RETRY_COUNT environment variable: %v", err)
return kvDefaultRetryCount, kvDefaultRetryWait, err
}
}

envRetryWait := os.Getenv("SQL_RETRY_WAIT")
if envRetryWait != "" {
retryWait, err = strconv.ParseUint(envRetryWait, 10, 64)
if err != nil {
err = fmt.Errorf("ERROR: unable to parse SQL_RETRY_WAIT environment variable: %v", err)
return kvDefaultRetryWait, kvDefaultRetryWait, err
}
}

return retryCount, retryWait, nil
}

func kvOpen(url, opts string, retryCount, retryWait uint64) (err error) {
ix := uint64(1)
for ; ix <= retryCount; ix++ {
Expand Down

0 comments on commit 11d3aaa

Please sign in to comment.