Skip to content

Conversation

motatoes
Copy link
Contributor

No description provided.

valueFrom:
secretKeyRef:
name: {{ .Values.digger.postgres.existingSecretName }}
key: {{ .Values.digger.postgres.existingSecretKey }}
{{- else }}
valueFrom:
secretKeyRef:

Choose a reason for hiding this comment

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

I can't leave a comment outside of the diff, but the succeeding if block (lines 49-54) needs to also be removed. It's what breaks the template.

Copy link
Contributor

@dannysauer dannysauer Sep 13, 2024

Choose a reason for hiding this comment

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

rewording for maybe clarity?

https://github.com/diggerhq/helm-charts/pull/15/files#diff-204d7782307a1567576db307ef282e33ef9a56ab6024b064960f777651b15acaR32-R54

The "else" and second if condition with negation of the preceding if conditions result in two valuesFrom blocks when and .Values.digger.postgres.existingSecretName (not .Values.postgres.enabled)

Choose a reason for hiding this comment

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

Yeah, sorry. I had already explained on Slack (and showed the diff on my fork that this PR is based off of) so I figured I didn't need to reiterate it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making sense, removed!

Comment on lines 89 to 92
# DB connection string should be in a key names DATABASE_URL
# compatible with https://github.com/kloeckner-i/db-operator, for example
existingSecretName: "new-pg-creds"
existingSecretName: ""
existingSecretKey: "postgres-password"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the existingSecretKey and the example in the comment should probably match. Obviously I'm partial to DATABASE_URL since that was my example, but consistency is more important. :) Also, I guess I misspelled "named" in that comment. :/

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, this implementation is still somewhat incompatible with the DB Operator mechanism.

When using db-operator to create the database, a secret is created which contains the entire connection URL. One can set up a Secret Template with multiple values, as in the docs, but typically it's preferable to just let the operator or other secret manager (I've used AWS systems manager secret driver and RDS for this before) build the whole connection string and inject that into the namespace.

So the outcome of the prior change is that I'd have to use something like kustomize to patch a secret with some other environment variables post-render. The change introduced in #7 and #8 provides a way for DATABASE_URL to be brought in directly from an external secret. Basically the postgres.existingSecretName was hijacked in #10 to change from actually containing the full URL secret to setting an entirely different environment variable used later to build the connection string. What ideally should've happened was to create two separate configuration mechanisms: one for specifying the connection string components, and a separate one for specifying the complete string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I improved the comment, regarding the DB operator, my basic understanding is that we currently accept individual DB URL string components and form it ourselves. Perhaps to support accepting entire string as a secret we can try to override the value here and accept it as a secret rather than an env variable

But I think it i something for another PR!

Copy link
Contributor

Choose a reason for hiding this comment

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

Accepting the whole URL worked before #10. ;)

I'll submit support again in a new PR since I strongly suspect I'm the only one who currently uses it.

valueFrom:
secretKeyRef:
name: {{ .Values.digger.postgres.existingSecretName }}
key: {{ .Values.digger.postgres.existingSecretKey }}
{{- else }}
Copy link
Contributor

Choose a reason for hiding this comment

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

This conditional applies if postgres is not enabled, which is a bit weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think if the "test purposes" postgres is not enabled (postgres.enabled) then we default to the values of some managed postgres so connection strings are fetched from (digger.postgres.xxxx). I dunno if we should add extra "enabled" flag under digger.postgres since it is already the fallback I guess

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, sure. That's "built-in postgres enabled". I'm gonna blame the variable name for not being clear, but really it's just that I forgot postgres is always used. 😂

This is fine then. My bad.

@motatoes motatoes merged commit ae7f530 into main Sep 16, 2024
@motatoes motatoes deleted the fix/default-values-that-broke-1.5 branch September 16, 2024 09:35
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.

4 participants