kubernetes-client / python-base

Apache License 2.0
70 stars 185 forks source link

Run kubeconfig exec commands in the correct directory #275

Closed aschleck closed 2 years ago

aschleck commented 2 years ago

What type of PR is this?

/kind bug

What this PR does / why we need it:

Kubeconfigs with exec specifications should invoke them so that referenced relative paths are relative to the config itself: https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#file-references . The current implementation in this library does not do so, so this PR fixes it.

I am not sure how to fix the config/kube_config_test.py tests because they patch kubernetes.config.kube_config.ExecProvider rather than the ExecProvider implementation in this PR, and for a similar reason I suspect the current from kubernetes.config.exec_provider import ExecProvider in config/kube_config.py will cause problems. But once this submodule is updated I think this should work fine, so not sure if there's anything I need to do.

Which issue(s) this PR fixes:

I didn't find a filed bug about this.

Does this PR introduce a user-facing change?

NONE
k8s-ci-robot commented 2 years ago

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
k8s-ci-robot commented 2 years ago

Welcome @aschleck!

It looks like this is your first PR to kubernetes-client/python-base 🎉. 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/python-base 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. :smiley:

aschleck commented 2 years ago

I believe I've signed the CLA

yliaog commented 2 years ago

kubernetes/config -> base/config (https://github.com/kubernetes-client/python/blob/master/kubernetes/config), kubernetes/config is a link to base/config, so kubernetes.config.kube_config.ExecProvider is the ExecProvider in this PR.

could you add tests to verify the fix works?

aschleck commented 2 years ago

Sorry I am not very clear on the workflow with this repository. When making this PR I cloned python-base/ only, are you saying that I should I clone the python/ repository as a whole and then somehow make the PR by modifying the submodule?

When I looked into adding tests for kube_config.py, it seemed difficult because the existing ExecProvider tests don't actually test anything about the ExecProvider. Would the best thing be to see if I can add a side-effect to the run() invocation and maybe be able to verify the property is set correctly? Are there better ways? Obviously I already added tests for the ExecProvider itself.

yliaog commented 2 years ago

this PR is fine, no need to create a new PR. when you try to run the tests locally, you may need to clone the python repo with the base submodule.

since kube_config_test is a unittest, i think it is fine to do what you suggested, i.e. add a side-effect to the run() invocation and verify the property is set correctly

aschleck commented 2 years ago

Added a test to kube_config_test.py

yliaog commented 2 years ago

/lgtm /approve

k8s-ci-robot commented 2 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aschleck, yliaog

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: - ~~[OWNERS](https://github.com/kubernetes-client/python-base/blob/master/OWNERS)~~ [yliaog] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment