Thanks to visit codestin.com
Credit goes to github.com

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

Closed
@matihost

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:

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