Skip to content

Commit

Permalink
Flytte maximumPoolSize innstillingen til NAIS config (#72)
Browse files Browse the repository at this point in the history
* Flyttet maximumPoolSize innstilling til NAIS config fil

* Flyttet innstillinger til riktig tjenesten
  • Loading branch information
OleksandrChmyrNAV authored Dec 19, 2024
1 parent cc4d5a9 commit c228d48
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .nais/cpa-repo-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,7 @@ spec:
value: truststore_test.p12
- name: EMOTTAK_LOGGING_LEVEL
value: DEBUG
- name: MAX_CONNECTION_POOL_SIZE_FOR_USER
value: "4"
- name: MAX_CONNECTION_POOL_SIZE_FOR_ADMIN
value: "1"
4 changes: 4 additions & 0 deletions .nais/cpa-repo-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,7 @@ spec:
value: jdbc:postgresql://A01DBVL037.adeo.no:5432/
- name: TRUSTSTORE_PATH
value: truststore_prod.p12
- name: MAX_CONNECTION_POOL_SIZE_FOR_USER
value: "10"
- name: MAX_CONNECTION_POOL_SIZE_FOR_ADMIN
value: "2"
4 changes: 4 additions & 0 deletions .nais/ebms-provider-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ spec:
value: /var/run/secrets/ebms-keystore-signering/signering-key.p12
- name: EMOTTAK_LOGGING_LEVEL
value: DEBUG
- name: MAX_CONNECTION_POOL_SIZE_FOR_USER
value: "4"
- name: MAX_CONNECTION_POOL_SIZE_FOR_ADMIN
value: "1"
envFrom:
- secret: ebms-payload-secret
filesFrom:
Expand Down
4 changes: 4 additions & 0 deletions .nais/ebms-provider-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ spec:
value: key.decrypt.p12.b64.2022
- name: VIRKSOMHETSSERTIFIKAT_CREDENTIALS
value: credentials.2022
- name: MAX_CONNECTION_POOL_SIZE_FOR_USER
value: "4"
- name: MAX_CONNECTION_POOL_SIZE_FOR_ADMIN
value: "2"
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ data class VaultConfig(
)

fun VaultConfig.configure(role: String): HikariConfig {
val maxPoolSizeForUser = getEnvVar("MAX_CONNECTION_POOL_SIZE_FOR_USER", "4").toInt()
val maxPoolSizeForAdmin = getEnvVar("MAX_CONNECTION_POOL_SIZE_FOR_ADMIN", "1").toInt()

val hikariConfig = HikariConfig().apply {
jdbcUrl = this@configure.jdbcUrl + databaseName
driverClassName = "org.postgresql.Driver"
this.maximumPoolSize = maxPoolSizeForUser
if (role == "admin") {
this.maximumPoolSize = 2
this.maximumPoolSize = maxPoolSizeForAdmin
val vault = VaultUtil.getInstance().client
val path: String = this@configure.vaultMountPath + "/creds/$databaseName-$role"
log.info("Fetching database credentials for role admin")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ data class VaultConfig(
)

fun VaultConfig.configure(role: String): HikariConfig {
val maxPoolSizeForUser = getEnvVar("MAX_CONNECTION_POOL_SIZE_FOR_USER", "4").toInt()
val maxPoolSizeForAdmin = getEnvVar("MAX_CONNECTION_POOL_SIZE_FOR_ADMIN", "1").toInt()

val hikariConfig = HikariConfig().apply {
jdbcUrl = this@configure.jdbcUrl + databaseName
driverClassName = "org.postgresql.Driver"
this.maximumPoolSize = 4
this.maximumPoolSize = maxPoolSizeForUser
if (role == "admin") {
this.maximumPoolSize = 1
this.maximumPoolSize = maxPoolSizeForAdmin
val vault = VaultUtil.getInstance().client
val path: String = this@configure.vaultMountPath + "/creds/$databaseName-$role"
log.info("Fetching database credentials for role admin")
Expand Down

0 comments on commit c228d48

Please sign in to comment.