-
Notifications
You must be signed in to change notification settings - Fork 39.9k
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
loads kubeconfig only once #71117
loads kubeconfig only once #71117
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
/milestone v1.13 |
staging/src/k8s.io/cli-runtime/pkg/genericclioptions/config_flags.go
Outdated
Show resolved
Hide resolved
/hold is this method expected to be self mutating? previously, it was non-mutating and theadsafe |
@liggitt @smarterclayton I don't think it is a good idea to load/parse the same config file again and again. That is time-consuming. And errors will occurr if we are changing the config file while the cli command is invoked. This method is and will be only used by the command line. And only one such declaration is defined currently.
I know your concern about thread safe. But kubectl only got one such declaration. |
To be clear, I'm fine with kubectl updating to use a method that explicitly loads only once (or with kubectl updating to load once itself and propagate the config to the places that need it, rather than calling this method multiple times)
This method is in an exported repo intended to be used by arbitrary command line tools. Searching only in the kubernetes/kubernetes repo does not indicate all usage. |
@liggitt Okay, I got it. I will have another alternative method to keep this peristent config.
Agree. |
6820c9d
to
bf54d21
Compare
bf54d21
to
f630648
Compare
@liggitt @smarterclayton I've added a flag for persistent client config and made it thread safe. And this change won't break current behavoirs. For kubectl, we are switching using persistent client config. |
staging/src/k8s.io/cli-runtime/pkg/genericclioptions/config_flags.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/cli-runtime/pkg/genericclioptions/config_flags.go
Outdated
Show resolved
Hide resolved
23f63c8
to
9d4e6f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two more nits and you'll be good to go.
staging/src/k8s.io/cli-runtime/pkg/genericclioptions/config_flags.go
Outdated
Show resolved
Hide resolved
9d4e6f9
to
34fda1b
Compare
staging/src/k8s.io/cli-runtime/pkg/genericclioptions/config_flags.go
Outdated
Show resolved
Hide resolved
34fda1b
to
4b524ef
Compare
Kindly ping @soltysh to get this merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
Thanks for the patience
/hold cancel |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dixudx, soltysh 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 |
/retest Review the full test history for this PR. Silence the bot with an |
/retest |
/retest Review the full test history for this PR. Silence the bot with an |
Would it be possible to get this fix cherry-picked to a released version? I've been experiencing performance problems using kubectl with a large kubeconfig + large resource counts, so I would love to have this before 1.14 (It'd be great to see it in 1.11.x in fact). |
We prefer to cherry-pick only bug fixes, this is not quite that. It's more like a feature than a bug fix. Sorry. |
@soltysh this issue did not exist in kubectl 1.10, and it has affected production systems where we rely on kubectl. I would call that a bug. We are using 1.11 because of the recent cve patch, so it would be good to have it in 1.11. |
What type of PR is this?
/kind bug
/sig cli
/area kubectl
What this PR does / why we need it:
Currently a single kubeconfig file will be loaded several times, which should be parsed for only once.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #69856
Special notes for your reviewer:
/cc @kubernetes/sig-cli-bugs
/assign soltysh
Does this PR introduce a user-facing change?: