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

allows controller to be configured via environment variable #31

Merged

Conversation

Peac36
Copy link
Contributor

@Peac36 Peac36 commented Aug 25, 2024

Issue: #11

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 25, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @Peac36!

It looks like this is your first PR to kubernetes-sigs/node-ipam-controller 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/node-ipam-controller has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 25, 2024
@aojea
Copy link
Contributor

aojea commented Aug 25, 2024

let's document this clearly and make sure we are consistent, IMHO flags should always be authoritative , since they are discoverable , environment variables are harder to find ..

@mneverov your thoughts?

Copy link
Member

@mneverov mneverov left a comment

Choose a reason for hiding this comment

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

I suggest to use github.com/jessevdk/go-flags.
It has a succinct syntax, handles errors properly, and arguments have priority over environment variables.

@Peac36 Peac36 force-pushed the start-parsing-confing-from-env branch from ec88908 to 1ad312e Compare September 1, 2024 16:08
@Peac36 Peac36 requested a review from mneverov September 1, 2024 16:08
README.md Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@Peac36 Peac36 force-pushed the start-parsing-confing-from-env branch from 8eb02db to 6399339 Compare September 15, 2024 15:42
main.go Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 16, 2024
@mneverov
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mneverov, Peac36

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

c := logsapi.NewLoggingConfiguration()
logsapi.AddGoFlags(c, flag.CommandLine)
flag.Parse()

conf := config{EnableLeaderElection: true}
Copy link
Contributor

Choose a reason for hiding this comment

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

not familiar with this framework, does the library sets this to false if the flag is set and ignores it if the flag is not set @mneverov

Copy link
Member

Choose a reason for hiding this comment

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

We discussed that by default the controller should run in leader election mode. The go-flags library does not have default values for boolean flags and suggests to use reverted flags like --disable-leader-election which will be on by default and can be overwritten.
To workaround this and provide the same flag semantics as in #20 @Peac36 added the line above such that if --enable-leader-election flag is not provided the controller will still run in leader election mode (again as before).
To disable leader election one can use --enable-leader-election=false.

Copy link
Contributor

Choose a reason for hiding this comment

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

Make sense

/lgtm

Copy link
Contributor

Choose a reason for hiding this comment

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

So the new library differentiate between flag not set and set to false

Copy link
Member

Choose a reason for hiding this comment

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

When --enable-leader-election or --enable-leader-election=true are provided as well as when the flag is not provided at all the controller will start in leader election mode.
Disabling leader election is possible via --enable-leader-election=false

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 21, 2024
@k8s-ci-robot k8s-ci-robot merged commit 0a1e0fd into kubernetes-sigs:main Sep 21, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants