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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nluedema
Copy link

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])

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 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 and others added 4 commits October 15, 2024 17:24
…on order

The FB_DB environment variable depends on the environment variable
NODE_NAME. This variable is currently resolved by Helm, which makes
FB_DB depend on the environment variable definition order.

To fix this, we make NODE_NAME being resolved by Fluent Bit instead of
Helm.
@nluedema
Copy link
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.

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
4 participants