Skip to content
This repository has been archived by the owner on Mar 13, 2022. It is now read-only.

fix cfg is none, load kube config error #198

Merged
merged 2 commits into from
Jun 25, 2020

Conversation

ACXLM
Copy link
Contributor

@ACXLM ACXLM commented Jun 2, 2020

This PR fixed
kubernetes/kubernetes#84503 changed the behaviour of kubectl config unset slightly that if no users left in kubeconfig after user run kubectl config unset users., the value of users field in kubeconfig would be set to null rather than [].

since users set to null, kubernetes.config.kube_config.load_kube_config() can't work, this pr set a default empty list to users

Which issue(s) this PR fixes:

Try to fixes
#183
#181

@k8s-ci-robot
Copy link
Contributor

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

📝 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.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please log a ticket with the Linux Foundation Helpdesk: https://support.linuxfoundation.org/
  • Should you encounter any issues with the Linux Foundation Helpdesk, send a message to the backup e-mail support address at: [email protected]

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jun 2, 2020
@k8s-ci-robot k8s-ci-robot requested review from roycaihw and yliaog June 2, 2020 02:49
@k8s-ci-robot
Copy link
Contributor

Welcome @ACXLM!

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. 😃

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 2, 2020
@codecov-commenter
Copy link

codecov-commenter commented Jun 2, 2020

Codecov Report

Merging #198 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #198   +/-   ##
=======================================
  Coverage   92.69%   92.69%           
=======================================
  Files          13       13           
  Lines        1519     1519           
=======================================
  Hits         1408     1408           
  Misses        111      111           
Impacted Files Coverage Δ
config/kube_config_test.py 95.59% <ø> (ø)
config/kube_config.py 83.48% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49ec060...2108e57. Read the comment docs.

@ACXLM ACXLM force-pushed the fix/load-kube-config branch 3 times, most recently from f7a1363 to b76029c Compare June 2, 2020 05:42
@ACXLM ACXLM force-pushed the fix/load-kube-config branch from b76029c to 3ff79da Compare June 2, 2020 05:56
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jun 2, 2020
@ACXLM
Copy link
Contributor Author

ACXLM commented Jun 3, 2020

/assign @roycaihw

@roycaihw
Copy link
Member

roycaihw commented Jun 8, 2020

Could you add a unit test for this behavior? Thanks

@ACXLM
Copy link
Contributor Author

ACXLM commented Jun 9, 2020

Could you add a unit test for this behavior? Thanks

since users set to None, load_config() run like the following error:

.....................config/kube_config_test.py:1345: DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(actual._config_persister.__name__, "save_changes")
....................................EEE...
======================================================================
ERROR: test_list_kube_config_contexts (__main__.TestKubeConfigMerger)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "config/kube_config_test.py", line 1545, in test_list_kube_config_contexts
    contexts, active_context = list_kube_config_contexts(
  File "/home/ac/Project/PythonWorksPaces/python-base/config/kube_config.py", line 714, in list_kube_config_contexts
    loader = _get_kube_config_loader_for_yaml_file(config_file)
  File "/home/ac/Project/PythonWorksPaces/python-base/config/kube_config.py", line 694, in _get_kube_config_loader_for_yaml_file
    kcfg = KubeConfigMerger(filename)
  File "/home/ac/Project/PythonWorksPaces/python-base/config/kube_config.py", line 650, in __init__
    self.load_config(path)
  File "/home/ac/Project/PythonWorksPaces/python-base/config/kube_config.py", line 667, in load_config
    self._merge(item, config.get(item, []), path)
  File "/home/ac/Project/PythonWorksPaces/python-base/config/kube_config.py", line 671, in _merge
    for new_item in add_cfg:
TypeError: 'NoneType' object is not iterable

this PR can fix this error

@ACXLM ACXLM force-pushed the fix/load-kube-config branch from 2108e57 to b08556b Compare June 23, 2020 02:24
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 23, 2020
@roycaihw
Copy link
Member

/lgtm
/hold
LGTM once the pycodestyle failure is fixed: https://travis-ci.org/github/kubernetes-client/python-base/jobs/701111762

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Jun 24, 2020
@ACXLM ACXLM force-pushed the fix/load-kube-config branch from b08556b to 5565d32 Compare June 24, 2020 08:18
@k8s-ci-robot k8s-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jun 24, 2020
@k8s-ci-robot
Copy link
Contributor

@ACXLM: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ACXLM
Copy link
Contributor Author

ACXLM commented Jun 24, 2020

/lgtm
/hold
LGTM once the pycodestyle failure is fixed: https://travis-ci.org/github/kubernetes-client/python-base/jobs/701111762

fixed pycodestyle test failure

@ACXLM ACXLM force-pushed the fix/load-kube-config branch from 5565d32 to 30d9e2a Compare June 25, 2020 12:53
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 25, 2020
@ACXLM ACXLM requested a review from roycaihw June 25, 2020 17:03
@roycaihw
Copy link
Member

/lgtm
/approve
/hold cancel

@k8s-ci-robot k8s-ci-robot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 25, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ACXLM, roycaihw

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 Jun 25, 2020
@k8s-ci-robot k8s-ci-robot merged commit 3ea8003 into kubernetes-client:master Jun 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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 Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants