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(kuma-dp): fix incorrect dataplane name due to mangled env vars #8199

Conversation

bartsmykla
Copy link
Contributor

Kubernetes workloads may have their environment variables mangled by other components outside of our control. This can cause the POD_NAME or POD_NAMESPACE variables to be defined after the KUMA_DATAPLANE_NAME variable, which results in an incorrect dataplane name.

This commit fixes this issue by checking for the POD_NAME and POD_NAMESPACE variables directly during Kuma dataplane runtime initialization if KUMA_DATAPLANE_NAME is empty or contains the characters $(){}, which suggests that the dependent variables were not present before its definition. This involved adding a PostProcess method to the Config interface.

Checklist prior to review

  • Link to relevant issue as well as docs and UI issues
    • there is no relevant issue
  • This will not break child repos: it doesn't hardcode values (.e.g "kumahq" as a image registry) and it will work on Windows, system specific functions like syscall.Mkfifo have equivalent implementation on the other OS
    • it won't
  • Tests (Unit test, E2E tests, manual test on universal and k8s)
    • unit tests were added
    • manually tested on local k3d cluster
    • Don't forget ci/ labels to run additional/fewer tests
  • Do you need to update UPGRADE.md?
    • there is no need
  • Does it need to be backported according to the backporting policy? (this GH action will add "backport" label based on these file globs, if you want to prevent it from adding the "backport" label use no-backport-autolabel label)
    • it does

Kubernetes workloads may have their environment variables mangled
by other components outside of our control. This can cause the
`POD_NAME` or `POD_NAMESPACE` variables to be defined after the
`KUMA_DATAPLANE_NAME` variable, which results in an incorrect
dataplane name.

This commit fixes this issue by checking for the `POD_NAME` and
`POD_NAMESPACE` variables directly during Kuma dataplane runtime
initialization if `KUMA_DATAPLANE_NAME` is empty or contains the
characters `$(){}`, which suggests that the dependent variables
were not present before its definition. This involved adding a
`PostProcess` method to the `Config` interface.

Signed-off-by: Bart Smykla <[email protected]>
@bartsmykla bartsmykla requested a review from a team as a code owner October 31, 2023 05:55
@bartsmykla bartsmykla requested review from michaelbeaumont and lobkovilya and removed request for a team October 31, 2023 05:55
@bartsmykla bartsmykla changed the title fix(kuma-dp) fix incorrect dataplane name due to mangled env vars fix(kuma-dp): fix incorrect dataplane name due to mangled env vars Oct 31, 2023
Signed-off-by: Bart Smykla <[email protected]>
@bartsmykla bartsmykla requested a review from lahabana October 31, 2023 09:33
Copy link
Contributor

@lahabana lahabana left a comment

Choose a reason for hiding this comment

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

missing zoneProxy helm chart configuration change.

@bartsmykla bartsmykla enabled auto-merge (squash) October 31, 2023 13:37
@bartsmykla bartsmykla requested a review from lahabana October 31, 2023 13:38
Copy link
Contributor

@lahabana lahabana left a comment

Choose a reason for hiding this comment

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

Approved! THough I'm not sure we should backport this as it changes quite a lot.

@bartsmykla bartsmykla disabled auto-merge October 31, 2023 13:57
@bartsmykla bartsmykla enabled auto-merge (squash) October 31, 2023 13:58
@bartsmykla bartsmykla merged commit c3afa4a into kumahq:master Oct 31, 2023
@bartsmykla bartsmykla deleted the fix/dataplane-name-when-env-vars-are-mangled branch November 1, 2023 04:27
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