Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(values): consistent usage of postgresql.adminPasswordKey #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

muja
Copy link

@muja muja commented Sep 20, 2024

Description of the change

Consistently use adminPasswordKey. Overriding this value currently leads to buggy behavior because it is not consistently used everywhere. Specifically the hard-coded postgres-password in one of the extraEnvVars is causing issues and downstream values files cannot override that easily.

Additional Information

Since janus-idp.postgresql.secretName is not used anymore, could be considered to delete it, but it might break downstream charts which use that helper.

Checklist

  • Chart version bumped in Chart.yaml according to semver.
  • Variables are documented in the values.yaml and added to the README.md. The pre-commit utility can be used to generate the necessary content. Use pre-commit run -a to apply changes.
  • JSON Schema template updated and re-generated the raw schema via pre-commit hook.
  • List tests pass for Chart using the Chart Testing tool and the ct lint command.

Copy link
Member

@rm3l rm3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @muja ! Thanks for this contribution.

Error:  templates/: template: backstage/charts/upstream/charts/postgresql/templates/primary/statefulset.yaml:385:16: executing "backstage/charts/upstream/charts/postgresql/templates/primary/statefulset.yaml" at <include "common.tplvalues.render" (dict "value" .Values.primary.extraEnvVars "context" $)>: error calling include: template: backstage/charts/common/templates/_tplvalues.tpl:19:8: executing "common.tplvalues.render" at <tpl $value .context>: error calling tpl: error during tpl function execution for "- name: POSTGRESQL_ADMIN_PASSWORD\n  valueFrom:\n    secretKeyRef:\n      key: '{{- include \"postgresql.adminPasswordKey\" }}'\n      name: '{{- include \"postgresql.v1.secretName\" . }}'": template: backstage/charts/upstream/charts/postgresql/templates/primary/statefulset.yaml:4:16: executing "backstage/charts/upstream/charts/postgresql/templates/primary/statefulset.yaml" at <include>: wrong number of args for include: want 2 got 1

Could you look into the lint issues reported?
https://github.com/redhat-developer/rhdh-chart/actions/runs/10955059451/job/30920518609?pr=44
Thanks.

Copy link

sonarcloud bot commented Oct 8, 2024

@muja
Copy link
Author

muja commented Oct 8, 2024

Hi @rm3l

I believe I was missing a .. Should be fixed now.

@muja
Copy link
Author

muja commented Oct 8, 2024

It seems that the context differs for the two invocations. The invocations on line 111/112 happen from the upstream chart, where the .Values.global look like this (weirdly):

{
    "auth": {
        "backend": {
            "enabled": true,
            "existingSecret": "",
            "value": ""
        }
    },
    "clusterRouterBase": "apps.example.com",
    "dynamic": {
        "includes": [
            "dynamic-plugins.default.yaml"
        ],
        "plugins": []
    },
    "host": "",
    "imagePullSecrets": [],
    "imageRegistry": ""
}

while the invocation in line 239/240 happens from the postgres chart, from who's POV they look like this:

{
    "auth": {
        "backend": {
            "enabled": true,
            "existingSecret": "",
            "value": ""
        }
    },
    "clusterRouterBase": "apps.example.com",
    "dynamic": {
        "includes": [
            "dynamic-plugins.default.yaml"
        ],
        "plugins": []
    },
    "host": "",
    "imagePullSecrets": [],
    "imageRegistry": "",
    "postgresql": {
        "auth": {
            "database": "",
            "existingSecret": "",
            "password": "",
            "postgresPassword": "",
            "secretKeys": {
                "adminPasswordKey": "",
                "replicationPasswordKey": "",
                "userPasswordKey": ""
            },
            "username": ""
        },
        "service": {
            "ports": {
                "postgresql": ""
            }
        }
    },
    "storageClass": ""
}

This causes the error. Any idea how to resolve this?

@muja
Copy link
Author

muja commented Oct 8, 2024

That missing section is defined in the postgres chart's values.yaml file and when the invocation happens in the upstream chart, those values are not yet set/merged. I'm not a helm chart expert so I'm not sure what would be a good way to resolve this other than specifying empty objects in the values file:

global:
  postgresql:
    auth: {}
upstream:
  auth: {}

key: postgres-password
name: '{{- include "janus-idp.postgresql.secretName" . }}'
key: '{{- include "postgresql.adminPasswordKey" . }}'
name: '{{- include "postgresql.v1.secretName" . }}'
Copy link
Author

@muja muja Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using this helper here changes the name property from rhdh-chart-postgresql to rhdh-chart-backstage. Is that a breaking change / problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants