Skip to content

Commit

Permalink
AJ-1219: Convert application.properties to YAML (#324)
Browse files Browse the repository at this point in the history
Convert application.properties to YAML

In keeping with DSP standardizing on YAML, this converts the two props files in WDS to YML format.

It was tested by diffing the properties before/after conversion and visually inspecting the results using the following testing mechanism which was temporarily introduced to support this verification:
```
DUMP_PROPERTIES=true ./gradlew bootRun
```

That tool can be found in the deletion commit if it's lost in the squash/merge commit: 5743b05

Additionally, the following properties were not referred to from anywhere else in https://github.com/DataBiosphere, so they are removed.
* `sam.healthcheck.pingTTL`
* `twds.clientId`

Finally, an outdated comment referring to data.sql is removed from the configuration property.
  • Loading branch information
jladieu authored Aug 15, 2023
1 parent e1fedfb commit 63dcb73
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 95 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.databiosphere.workspacedataservice;

import io.sentry.Sentry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
Expand All @@ -13,8 +15,8 @@

@Configuration
@PropertySource("classpath:git.properties")
@PropertySource("classpath:application.properties")
public class SentryInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger(SentryInitializer.class);

@Value("${sentry.dsn}")
String dsn;
Expand Down Expand Up @@ -42,6 +44,7 @@ public class SentryInitializer {
@Bean
public SmartInitializingSingleton initialize() {
String env = urlToEnv(samurl);

return () ->
Sentry.init(options -> {
options.setEnvironment(env);
Expand All @@ -53,7 +56,6 @@ public SmartInitializingSingleton initialize() {
});
}


/**
* Extracts an environment (e.g. "dev" or "prod") from a Sam url.
* Looks for ".dsde-${env} and returns ${env} if found.
Expand Down
92 changes: 0 additions & 92 deletions service/src/main/resources/application.properties

This file was deleted.

124 changes: 124 additions & 0 deletions service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# These values are used more than once, so we'll set them here with appropriate defaults
env:
wds:
db:
host: ${WDS_DB_HOST:localhost}
port: ${WDS_DB_PORT:5432}
name: ${WDS_DB_NAME:wds}
password: ${WDS_DB_PASSWORD:wds}
user: ${WDS_DB_USER:wds}
# When running on Azure in k8s with workload identity set ADDITIONAL_JDBC_URL_PARAMS to
# sslmode=require&authenticationPluginClassName=com.azure.identity.extensions.jdbc.postgresql.AzurePostgresqlAuthenticationPlugin
additionalUrlParams: ${ADDITIONAL_JDBC_URL_PARAMS:}

management:
endpoint:
info:
enabled: true
health:
enabled: true
show-details: ALWAYS
probes:
enabled: true
group:
liveness:
include: livenessState,db
endpoints:
enabled-by-default: false
web:
exposure.include: info,health
base-path: /
path-mapping:
info: version
health: status
# additional keys to expose in the actuator info endpoint:
info:
env:
enabled: true

info:
app:
chart-version: ${HELM_CHART:unknown}
image: ${WDS_IMAGE:unknown}

spring:
cache:
jcache:
config: classpath:ehcache.xml

datasource:
hikari:
jdbc-url: jdbc:postgresql://${env.wds.db.host}:${env.wds.db.port}/${env.wds.db.name}?reWriteBatchedInserts=true&${env.wds.db.additionalUrlParams}
username: ${env.wds.db.user}
password: ${env.wds.db.password}
maximum-pool-size: 7
minimum-idle: 7
servlet:
multipart.max-request-size: 5GB
multipart.max-file-size: 5GB
sql:
init:
mode: never
# Run Liquibase instead
liquibase:
change-log: classpath:liquibase/changelog.yaml
# # activate the "local" profile to turn on CORS response headers,
# # which may be necessary for local development.
# profiles:
# active: local

# set hikari logging to DEBUG or even TRACE to troubleshoot connection pool issues
logging:
level:
com.zaxxer.hikari.HikariConfig: INFO
com.zaxxer.hikari: INFO

server:
error:
include-stacktrace: never
include-message: always

twds:
write.batch.size: 5000
streaming.fetch.size: 5000
instance:
# Workspace Id for launching instance
workspace-id: ${WORKSPACE_ID:}
source-workspace-id: ${SOURCE_WORKSPACE_ID:}
# short-lived credentials to use during cloning
startup-token: ${STARTUP_TOKEN:}

pg_dump:
path: ${PGDUMP_PATH:/usr/bin/pg_dump}
psqlPath: ${PSQL_PATH:/usr/bin/psql}
port: ${env.wds.db.port}
user: ${env.wds.db.user}
dbName: ${env.wds.db.name}
password: ${env.wds.db.password}
host: ${env.wds.db.host}
# When running on Azure in k8s with workload identity set PGDUMP_USE_AZURE_IDENTITY to true
useAzureIdentity: ${PGDUMP_USE_AZURE_IDENTITY:true}

sentry:
dsn: https://[email protected]/4504299946835968
samurl: ${SAM_URL:}
mrg: ${LZ_MRG:}
releasename: ${RELEASE_NAME:}

sam:
retry:
maxAttempts: 5
backoff:
delay: 500
multiplier: 1.5

api:
retry:
maxAttempts: 10
backoff:
delay: 150
multiplier: 1.5

datarepourl: ${DATA_REPO_URL:}
workspacemanagerurl: ${WORKSPACE_MANAGER_URL:}
leoUrl: ${LEONARDO_URL:}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# Sam client underneath that dao. In order for SamConfig to create the HttpSamDao,
# we need a valid workspace id.
# This is the example uuid from https://en.wikipedia.org/wiki/Universally_unique_identifier
twds.instance.workspace-id=123e4567-e89b-12d3-a456-426614174000
twds:
instance:
workspace-id: 123e4567-e89b-12d3-a456-426614174000

0 comments on commit 63dcb73

Please sign in to comment.