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

kube_config.py is unable to merge configs when one of configs has removed all contexts #183

Description

@matihost
  File \"/home/myuser/.local/lib/python3.6/site-packages/kubernetes/config/kube_config.py\", line 664, in load_kube_config
    persist_config=persist_config)
  File \"/home/myuser/.local/lib/python3.6/site-packages/kubernetes/config/kube_config.py\", line 620, in _get_kube_config_loader_for_yaml_file
    kcfg = KubeConfigMerger(filename)
  File \"/home/myuser/.local/lib/python3.6/site-packages/kubernetes/config/kube_config.py\", line 574, in __init__
    self.load_config(path)
  File \"/home/myuser/.local/lib/python3.6/site-packages/kubernetes/config/kube_config.py\", line 592, in load_config
    self._merge(item, config.get(item, {}), path)
  File \"/home/myuser/.local/lib/python3.6/site-packages/kubernetes/config/kube_config.py\", line 597, in _merge
    for new_item in add_cfg:
TypeError: 'NoneType' object is not iterable

when:

KUBECONFIG=/home/myuser/.kube/config:/home/myuser/.kube/microk8s.config

and for example one of them defines null contexts:

contexts: null

It happens when

kubectl config delete-context microk8s 

is invoked and there is no context left in kube config file.

Fix proposal add if:

    def _merge(self, item, add_cfg, path):
        if add_cfg is not None:
          for new_item in add_cfg:

around

for new_item in add_cfg:

Activity

  1. roycaihw commented on Mar 2, 2020

    @roycaihw
    Member

    /assign @palnabarun

  2. fejta-bot commented on May 31, 2020

    @fejta-bot

    Issues go stale after 90d of inactivity.
    Mark the issue as fresh with /remove-lifecycle stale.
    Stale issues rot after an additional 30d of inactivity and eventually close.

    If this issue is safe to close now please do so with /close.

    Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
    /lifecycle stale

  3. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on May 31, 2020
  4. fejta-bot commented on Jun 30, 2020

    @fejta-bot

    Stale issues rot after 30d of inactivity.
    Mark the issue as fresh with /remove-lifecycle rotten.
    Rotten issues close after an additional 30d of inactivity.

    If this issue is safe to close now please do so with /close.

    Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
    /lifecycle rotten

  5. added
    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.
    and removed
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Jun 30, 2020
  6. fejta-bot commented on Jul 30, 2020

    @fejta-bot

    Rotten issues close after 30d of inactivity.
    Reopen the issue with /reopen.
    Mark the issue as fresh with /remove-lifecycle rotten.

    Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
    /close

  7. k8s-ci-robot commented on Jul 30, 2020

    @k8s-ci-robot
    Contributor

    @fejta-bot: Closing this issue.

    Details

    In response to this:

    Rotten issues close after 30d of inactivity.
    Reopen the issue with /reopen.
    Mark the issue as fresh with /remove-lifecycle rotten.

    Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
    /close

    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.

  8. weininghu1012 commented on Feb 1, 2021

    @weininghu1012

    Hi, I also encounter this issue with error like:

      File "/Users/weininghu/.pyenv/virtualenvs/kafka-topic-manager/3.7.8/lib/python3.7/site-packages/kubernetes/config/kube_config.py", line 672, in _merge
        for new_item in add_cfg:
    TypeError: 'NoneType' object is not iterable
    

    Is this issue being working on?

  9. mohammedi-haroune commented on Feb 4, 2021

    @mohammedi-haroune

    I'm also getting this error

        def _merge(self, item, add_cfg, path):
    >       for new_item in add_cfg:
    E       TypeError: 'NoneType' object is not iterable
    
    ../../venv/lib/python3.7/site-packages/kubernetes/config/kube_config.py:672: TypeError
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions