Skip to content

Use Path.DirectorySeparatorChar to have ServiceAccountPath start from root #342

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

Conversation

darobs
Copy link
Contributor

@darobs darobs commented Dec 31, 2019

The path constructed in KubernetesClientConfiguration::ServiceAccountPath is a relative path, and this works fine as long as CWD is the root directory.

This PR uses Path.DirectorySeparatorChar to have ServiceAccountPath start from root, instead of a relative path.

This should work fine on Linux containers, but it still assumes the Windows container working drive is "C:"

…om root, instead of a relative path.

This should work fine on Linux containers, but it still assumes the Windows container working drive is "C:"
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 31, 2019
@k8s-ci-robot
Copy link
Contributor

Welcome @darobs!

It looks like this is your first PR to kubernetes-client/csharp 🎉. 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-client/csharp 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/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Dec 31, 2019
@tg123
Copy link
Member

tg123 commented Jan 4, 2020

do you mean c:/var/xxxx ?

@darobs
Copy link
Contributor Author

darobs commented Jan 6, 2020

do you mean c:/var/xxxx ?

In Windows, this pathname resolves to \var\run\secrets\kubernetes.io\serviceaccount, which will resolve to the root of the current working drive.

Example:

PS C:\temp> type a.txt
Hello world!
PS C:\temp> type \temp\a.txt
Hello world!
PS C:\temp> d:
PS D:\Windows> type \temp\a.txt
type : Cannot find path 'D:\temp\a.txt' because it does not exist.

So this PR works fine if the current working directory in the Windows container is on the same drive as \var\run\secrets\kubernetes.io is mounted. It fixes the problem for Linux.

@tg123
Copy link
Member

tg123 commented Jan 6, 2020

@darobs
is there any thing in C:\var\run\secrets\kubernetes.io\serviceaccount?
those are inject by system, I am not sure if it still there on Windows

IHMO, we need to find out a Windows way to do so.

@brendandburns
Copy link
Contributor

/lgtm
/approve

Regardless of windows or not this is an improvement on the current code.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 6, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, darobs

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 6, 2020
@k8s-ci-robot k8s-ci-robot merged commit 3c3c6ca into kubernetes-client:master Jan 6, 2020
@darobs darobs deleted the darobs/use-path-directory-separator-to-root-path branch January 7, 2020 22:04
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/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants