-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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 Windows credential provider cannot find binary #120291
Fix Windows credential provider cannot find binary #120291
Conversation
/test pull-kubernetes-node-e2e-containerd |
@dchen1107 @derekwaynecarr could you please take a look at the PR?Thank you. |
@@ -98,7 +98,10 @@ func RegisterCredentialProviderPlugins(pluginConfigFile, pluginBinDir string) er | |||
registerMetrics() | |||
|
|||
for _, provider := range credentialProviderConfig.Providers { | |||
pluginBin := filepath.Join(pluginBinDir, provider.Name) | |||
pluginBin, err := exec.LookPath(filepath.Join(pluginBinDir, provider.Name)) |
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.
could you also add comments here, and also it's better having a ut coverage for this. thanks.
btw, is this a regression? does external windows credential provider never work?
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.
Sure.
Since external credential provider is relatively new feature I think (?) and it is also Windows (fewer users), I'm not sure if other clouds have started using it.
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.
I added a comment there. The reason that I don't add a UT is that UT tests are still run on linux, not the OS of this change.
4abdc2f
to
bdbc87f
Compare
// Considering Windows binary with suffix ".exe", LookPath() helps to find the correct path. | ||
pluginBin, err := exec.LookPath(filepath.Join(pluginBinDir, provider.Name)) | ||
if err != nil { | ||
return fmt.Errorf("error finding binary path of plugin provider %s: %w", provider.Name, err) |
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.
original logic does not return error while this PR would returns error, and in L106, it's already returning error if pluginBin not found
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.
I combined the code with the code below because LookPath calls os.Stat
Windows credential provider binary path may have ".exe" suffix so it is better to use LookPath() to support it flexibly. Signed-off-by: Zhecheng Li <[email protected]>
bdbc87f
to
6102357
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.
/lgtm
/kind bug
/priority important-soon
/sig cloud-provider
/area provider/azure
/triage accepted
LGTM label has been added. Git tree hash: ecd127f4903ba71e2dfb5521c1e375836e1dfad9
|
/retest |
@andrewsykim can you take a look at this PR? thanks. |
btw, I think the PR title should be |
@andrewsykim could you please review or refer someone to help? Thx. |
@dims could you please help review? |
/assign @nckturner @andrewsykim |
@nckturner @andrewsykim could you take a look? thanks |
/approve cc @liggitt in case there were some lingering concerns around |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andyzhangx, dims, lzhecheng 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 |
// Considering Windows binary with suffix ".exe", LookPath() helps to find the correct path. | ||
// LookPath() also calls os.Stat(). | ||
pluginBin, err := exec.LookPath(filepath.Join(pluginBinDir, provider.Name)) | ||
if err != nil { | ||
if os.IsNotExist(err) { |
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.
does LookPath wrap errors? do we need to call errors.Is(err, os.ErrNotExist)
instead?
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.
LookPath
calls findExecutable
which wraps os.Stat
.
However, I think it is better to follow the suggestion in comments to use errors.Is
.
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.
/cherrypick release-1.29 |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Fix Windows credential provider cannot find binary. Windows credential provider binary path may have ".exe" suffix so it is better to use LookPath() to support it flexibly.
Which issue(s) this PR fixes:
Fixes #kubernetes-sigs/cloud-provider-azure#4533
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: