magnum-api error ~/.kube/config missing

Bug #2047360 reported by Daniel Niasoff
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
kolla
Triaged
Undecided
Unassigned
Bobcat
Fix Released
Undecided
Unassigned

Bug Description

**Bug Report**

magnum-api fails to create cluster template or clusters - getting Internal server error 500

Getting stacktrace

```2023-12-25 16:30:18.814 754 INFO werkzeug [None req-02595850-de14-4192-9025-908d63d91927 9b3dc4c0ffff46f5a71a9af7c5fc7b1a 10f91ab774a14ab38cc791ea60bc37f4 - - default -] 92.12.220.113, 192.168.100.20,192.168.100.28 - - [25/Dec/2023 16:30:18] "POST /v1/clustertemplates HTTP/1.0" 500 -
2023-12-25 16:30:23.491 755 ERROR wsme.api [None req-a83ff7d7-b859-47a3-8e29-a45119986867 9b3dc4c0ffff46f5a71a9af7c5fc7b1a 10f91ab774a14ab38cc791ea60bc37f4 - - default -] Server-side error: "Configuration file ~/.kube/config not found". Detail:
Traceback (most recent call last):

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/pykube/config.py", line 111, in from_env
    config = cls.from_service_account()

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/pykube/config.py", line 42, in from_service_account
    with service_account_dir.joinpath("token").open() as fp:

  File "/usr/lib/python3.10/pathlib.py", line 1119, in open
    return self._accessor.open(self, mode, buffering, encoding, errors,

FileNotFoundError: [Errno 2] No such file or directory: '/var/run/secrets/kubernetes.io/serviceaccount/token'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/wsmeext/pecan.py", line 82, in callfunction
    result = f(self, *args, **kwargs)

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/magnum/api/validation.py", line 165, in wrapper
    return func(*args, **kwargs)

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/magnum/api/validation.py", line 128, in wrapper
    return func(*args, **kwargs)

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/magnum/api/validation.py", line 180, in wrapper
    return func(*args, **kwargs)

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/magnum/api/validation.py", line 190, in wrapper
    return func(*args, **kwargs)

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/magnum/api/validation.py", line 84, in wrapper
    driver.Driver.get_driver(*cluster_type)

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/magnum/drivers/common/driver.py", line 123, in get_driver
    definition_map = cls.get_drivers()

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/magnum/drivers/common/driver.py", line 77, in get_drivers
    for cluster_type in def_class().provides:

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/magnum_cluster_api/driver.py", line 24, in __init__
    self.k8s_api = clients.get_pykube_api()

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/magnum_cluster_api/clients.py", line 20, in get_pykube_api
    return pykube.HTTPClient(pykube.KubeConfig.from_env())

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/pykube/config.py", line 114, in from_env
    config = cls.from_file()

  File "/var/lib/kolla/venv/lib/python3.10/site-packages/pykube/config.py", line 93, in from_file
    raise exceptions.PyKubeError(

pykube.exceptions.PyKubeError: Configuration file ~/.kube/config not found
: pykube.exceptions.PyKubeError: Configuration file ~/.kube/config not found```

Related to change I6b8780c2b869929a02b624bfb8c6087d5a82c74a "Add magnum-cluster-api driver to Kolla images"

If I remove `magnum-cluster-api` from the python packages and revert the commit then everything works OK.

**Environment**:

Ubuntu 22.04
Kolla/Kolla-Ansible/Openstack version 2023.2

Changed in kolla:
status: New → Triaged
Revision history for this message
Paul Heinlein (paulheinlein) wrote :

I'm seeing the same thing. I'm running master-rocky-9 containers that I updated about an hour ago. The issue is marked as "Triaged," but I'm not sure if that means a fix is available to me or not. If so, is there a procedure for implementing the fix?

Revision history for this message
Daniel Niasoff (5-daniel-o) wrote :

Hi Paul,

As a workaround for now if you create a file called /etc/kolla/template-overrides.j2

and add the content of the attached file to it, it should, in theory, reverse the commit.

No need to build all containers - you can just run `kolla-build magnum`

I have not tested this process myself.

Danny

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/kolla-ansible 17.1.0

This issue was fixed in the openstack/kolla-ansible 17.1.0 release.

Revision history for this message
RJ (rjbugreporting) wrote :

This bug still seems to affect me on Bobcat, using openstack/kolla-ansible 17.3.1 release, and pulling/deploying the latest 2023.2-rocky-9 containers (as of last week).

The override posted by Daniel does solve the problem, after adding the `-y` flag to the pip command.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.