bitnami / charts

Bitnami Helm Charts
https://bitnami.com
Other
8.84k stars 9.13k forks source link

[bitnami/keycloak] setting initdbScripts causes startup error #29194

Closed p4block closed 4 days ago

p4block commented 2 weeks ago

Name and Version

bitnami/keycloak

What architecture are you using?

amd64

What steps will reproduce the bug?

Set initDbScripts

Are you using any custom parameters or values?

keycloak:
  auth:
    adminUser: admin
    existingSecret: keycloak-env
    passwordSecretKey: admin-password
  production: true
  proxy: edge
  replicaCount: 1
  service:
    type: ClusterIP
  ingress:  
    enabled: true
    annotations:
      # https://stackoverflow.com/a/68811151/1581433
      nginx.ingress.kubernetes.io/proxy-buffer-size: "128k"
    ingressClassName: nginx-public
    hostname: our-domain
    tls: true

  initdbScripts:
    move-providers.sh: |
      #!/bin/bash
      echo true

  metrics:
    enabled: true

What is the expected behavior?

Container starts

What do you see instead?

Container start fails with

keycloak 09:25:29.01 INFO  ==> Loading user's custom files from /docker-entrypoint-initdb.d ...
touch: cannot touch '/bitnami/keycloak/.user_scripts_initialized': No such file or directory

Additional information

Seen previously at #3537

bvis commented 5 days ago

I've seen this bug has been introduced in this change: https://github.com/bitnami/charts/commit/3d04a655e59ce25587d84b1a2a44844dfcf19de3

jotamartos commented 5 days ago

Thanks for the information @bvis. We are going to review the latest security changes we applied to the chart, we probably missed something in the configuration. The change you mentioned was made to resolve another issue

jotamartos commented 5 days ago

Hi @p4block,

I just created a PR to solve the issue you reported. I used this simple script to test the changes

diff --git a/bitnami/keycloak/values.yaml b/bitnami/keycloak/values.yaml
index abe71381a7..846f9d216c 100644
--- a/bitnami/keycloak/values.yaml
+++ b/bitnami/keycloak/values.yaml
@@ -261,7 +261,10 @@ enableDefaultInitContainers: true
 ##      #!/bin/bash
 ##      echo "Do something."
 ##
-initdbScripts: {}
+initdbScripts:
+   my_init_script.sh: |
+      #!/bin/bash
+      echo "Do something."
 ## @param initdbScriptsConfigMap ConfigMap with the initdb scripts (Note: Overrides `initdbScripts`)
 ##
 initdbScriptsConfigMap: ""

and the deployment worked as expected

keycloak 13:31:24.75 INFO  ==> 
keycloak 13:31:24.75 INFO  ==> Welcome to the Bitnami keycloak container
keycloak 13:31:24.76 INFO  ==> Subscribe to project updates by watching https://github.com/bitnami/containers
keycloak 13:31:24.76 INFO  ==> Submit issues and feature requests at https://github.com/bitnami/containers/issues
keycloak 13:31:24.76 INFO  ==> Upgrade to Tanzu Application Catalog for production environments to access custom-configured and pre-packaged software components. Gain enhanced features, including Software Bill of Materials (SBOM), CVE scan result reports, and VEX documents. To learn more, visit https://bitnami.com/enterprise
keycloak 13:31:24.76 INFO  ==> 
keycloak 13:31:24.77 INFO  ==> ** Starting keycloak setup **
keycloak 13:31:24.78 INFO  ==> Validating settings in KEYCLOAK_* env vars...
keycloak 13:31:24.80 INFO  ==> Trying to connect to PostgreSQL server keycloak-postgresql...
timeout reached before the port went into state "inuse"
keycloak 13:31:44.86 INFO  ==> Found PostgreSQL server listening at keycloak-postgresql:5432
keycloak 13:31:44.86 INFO  ==> Configuring database settings
keycloak 13:31:44.90 INFO  ==> Enabling statistics
keycloak 13:31:44.91 INFO  ==> Enabling health endpoints
keycloak 13:31:44.92 INFO  ==> Configuring http settings
keycloak 13:31:44.94 INFO  ==> Configuring hostname settings
keycloak 13:31:44.94 INFO  ==> Configuring cache count
keycloak 13:31:44.95 INFO  ==> Configuring log level
keycloak 13:31:44.97 INFO  ==> Loading user's custom files from /docker-entrypoint-initdb.d ...
Do something.

keycloak 13:31:44.98 INFO  ==> ** keycloak setup finished! **
keycloak 13:31:45.02 INFO  ==> ** Starting keycloak **
...