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

Make all the aws vpc cni environmental variables case insensitive #2334

Merged
merged 2 commits into from
Apr 24, 2023

Conversation

jerryhe1999
Copy link
Contributor

What type of PR is this?
feature

Which issue does this PR fix:
#2311

What does this PR do / Why do we need it:
Originally, we have several aws-vpc-cni environmental variables with the type Boolean as a String which against good coding standards. Having case insensitive values for Boolean can avoid users meet situation that spend 2+ weeks to figure out the case sensitivity cause the problem.

Testing done on this change:
Manually tested the code change in testing cluster with setting environmental variables in case insensitivity. Both unit tests and integration tests passed

Automation added to e2e:
N/A

Will this PR introduce any new dependencies?:
No

Will this break upgrades or downgrades. Has updating a running cluster been tested?:
No

Does this change require updates to the CNI daemonset config files to work?:
No

Does this PR introduce any user-facing change?:
No

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jerryhe1999 jerryhe1999 requested a review from jdn5126 March 29, 2023 21:15
@jerryhe1999 jerryhe1999 requested a review from a team as a code owner March 29, 2023 21:15
Copy link
Contributor

@jdn5126 jdn5126 left a comment

Choose a reason for hiding this comment

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

This helps environment variables read in cmd/aws-vpc-cni/main.go, but we need to be more thorough and do case-insensitive compare everywhere a boolean environment variable is accessed.

Also, this same function is in cmd/aws-vpc-cni-init/main.go

You'll need to go through each "Boolean as a String" environment variable in https://github.com/aws/amazon-vpc-cni-k8s#cni-configuration-variables and ensure that everywhere it is read in the code does a case-insensitive compare.

cmd/aws-vpc-cni-init/main.go Outdated Show resolved Hide resolved
utils/getenv/getenv.go Outdated Show resolved Hide resolved
utils/getenv/getenv.go Outdated Show resolved Hide resolved
utils/getenv/getenv.go Outdated Show resolved Hide resolved
utils/utils.go Outdated Show resolved Hide resolved
utils/utils.go Outdated Show resolved Hide resolved
utils/utils_test.go Outdated Show resolved Hide resolved
cmd/aws-vpc-cni-init/main.go Outdated Show resolved Hide resolved
utils/utils.go Outdated Show resolved Hide resolved
utils/utils.go Outdated Show resolved Hide resolved
utils/utils.go Outdated Show resolved Hide resolved
utils/utils.go Outdated Show resolved Hide resolved
utils/utils_test.go Show resolved Hide resolved
utils/utils_test.go Outdated Show resolved Hide resolved
utils/utils_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@jdn5126 jdn5126 left a comment

Choose a reason for hiding this comment

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

Just a few more nits and then this should be good to go. @jerryhe1999 can you also rebase and squash this into one commit?

utils/utils.go Outdated Show resolved Hide resolved
utils/utils_test.go Outdated Show resolved Hide resolved
utils/utils_test.go Outdated Show resolved Hide resolved
utils/utils_test.go Outdated Show resolved Hide resolved
utils/utils_test.go Outdated Show resolved Hide resolved
utils/utils_test.go Outdated Show resolved Hide resolved
made environmental flags managed by aws-vpc-cni-init/main.go case insensitive

refactor getEnv function in cmd/aws-vpc-cni and cmd/aws-vpc-cni-init

fixed logic issue and added unit tests for utils package

fixed import function name with Capital initial

log the error message instead of return it

removed unnecessary log
@jerryhe1999 jerryhe1999 force-pushed the feature-flag-insensitive branch from 2ac819f to 89ac30d Compare April 24, 2023 19:40
@jdn5126 jdn5126 merged commit d944328 into aws:master Apr 24, 2023
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