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

[newrelic-logging] Adjust order of env list in daemonset to fix dependency reference #1441

Merged
merged 2 commits into from
Oct 28, 2024

Conversation

nluedema
Copy link
Contributor

Is this a new chart

No

What this PR does / why we need it:

When using persistentVolume mode, the env variable FB_DB references NODE_NAME. This reference is currently not resolved, because NODE_NAME is defined after FB_DB. Therefore, only a single database file named '$(NODE_NAME)-fb.db' is created in the persistent volume, instead of one file for each node. #1408 traced the problem down to this change, which moved the definition of NODE_NAME after the definition of FB_DB.

This PR fixes this, by moving the definition of NODE_NAME before the definition of FB_DB again.

The behavior of kubernetes for dependent environment variables is documented here.

Which issue this PR fixes

Special notes for your reviewer:

I was thinking about a test that checks if NODE_NAME is defined before FB_DB, but I wasn't able to come up with a way to do this using helm-unittest.

Checklist

  • Chart Version bumped
  • Variables are documented in the README.md
  • Title of the PR starts with chart name (e.g. [mychartname])

@nluedema nluedema requested a review from a team as a code owner July 25, 2024 16:06
@CLAassistant
Copy link

CLAassistant commented Jul 25, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@jsubirat jsubirat left a comment

Choose a reason for hiding this comment

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

Hi @nluedema ,

Thank you for identifying this issue. Indeed, I didn't realize that moving NODE_NAME would affect FB_DB when using persistent volumes due to ordering. The reason this is happening though is because that environment variable uses $(NODE_NAME) instead of ${NODE_NAME}, which means that it is Helm resolving the value of these variables rather than Fluent Bit when it starts.

To fix this, I would suggest to leave NODE_NAME untouched and instead fix FB_DB. We don't want environment variable definition to be dependent on order. To achieve this, could you please:

  • Move NODE_NAME back to where it was
  • Modify this:
- name: FB_DB
   value: "/db/$(NODE_NAME)-fb.db"

to this:

- name: FB_DB
 value: "/db/${NODE_NAME}-fb.db"

This will ensure that environment variable definitions stay order-insensitive and that it is actually the Fluent Bit process that resolves NODE_NAME upon start rather than Helm.

@nluedema
Copy link
Contributor Author

Hi @jsubirat,

Thanks for the feedback! I didn't know that Fluent Bit is able to resolve environment variables. Doing it that way is of course a lot more elegant. I updated the PR according to your suggestions.

@nr-rkallempudi
Copy link
Contributor

Hi @nluedema , We have validated your PR and found that Fluent Bit is not resolving the variable name ${NODE_NAME} as it doesn't support nested environment variable interpolation. So we agreed internally to do with your previous code changes for now even though it keeps order dependency.

Can you update code to previous one with curved braces and also add a comment mentioning the order dependency to have that variable resolved. So we can proceed with merging your PR.

Copy link
Contributor

@nr-rkallempudi nr-rkallempudi left a comment

Choose a reason for hiding this comment

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

Hi @nluedema , We have validated your PR and found that Fluent Bit is not resolving the variable name ${NODE_NAME} as it doesn't support nested environment variable interpolation. So we agreed internally to do with your previous code changes for now even though it keeps order dependency.

Can you update code to previous one with curved braces and also add a comment mentioning the order dependency to have that variable resolved. So we can proceed with merging your PR.

When using persistentVolume mode, the env variable FB_DB references NODE_NAME. This reference is currently not resolved, because NODE_NAME is defined after FB_DB. This commit fixes this, by moving the definition of NODE_NAME before the definition of FB_DB.
@nluedema
Copy link
Contributor Author

@nr-rkallempudi @jsubirat
I updated the PR to only include the initial changes. Let me know what you think! A pity that nested environment variable interpolation doesn't work.

Copy link
Contributor

@jsubirat jsubirat left a comment

Choose a reason for hiding this comment

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

Thanks folks, and apologies for the confusion!

@voorepreethi voorepreethi merged commit a02a800 into newrelic:master Oct 28, 2024
10 checks passed
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.

[newrelic-logging] BREAKING Bug in env values order
6 participants