hook failed: "install" when deployed to a non-k8s model

Bug #2032822 reported by George Kraft
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
CoreDNS Charm
Fix Released
Medium
George Kraft

Bug Description

When deploying the coredns charm to a model backed by a non-k8s cloud (e.g. Azure, vSphere, etc), the charm fails during the install hook due to missing service account credentials.

The real problem here is that the charm doesn't support being deployed in such models, and the charm's metadata is missing the required bits to inform Juju that that is the case.

====== Traceback ======

Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-coredns-0/charm/venv/lightkube/config/kubeconfig.py", line 175, in from_service_account
    token = account_dir.joinpath("token").read_text()
  File "/usr/lib/python3.10/pathlib.py", line 1134, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  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/juju/agents/unit-coredns-0/charm/venv/lightkube/config/kubeconfig.py", line 210, in from_env
    return KubeConfig.from_service_account(service_account=service_account)
  File "/var/lib/juju/agents/unit-coredns-0/charm/venv/lightkube/config/kubeconfig.py", line 178, in from_service_account
    raise exceptions.ConfigError(str(e))
lightkube.core.exceptions.ConfigError: [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/juju/agents/unit-coredns-0/charm/./src/charm.py", line 182, in <module>
    main(CoreDNSCharm)
  File "/var/lib/juju/agents/unit-coredns-0/charm/venv/ops/main.py", line 429, in main
    charm = charm_class(framework)
  File "/var/lib/juju/agents/unit-coredns-0/charm/./src/charm.py", line 35, in __init__
    self.client = Client(field_manager=self.app.name, namespace=self.model.name)
  File "/var/lib/juju/agents/unit-coredns-0/charm/venv/lightkube/core/client.py", line 43, in __init__
    self._client = GenericSyncClient(config, namespace=namespace, timeout=timeout, lazy=lazy,
  File "/var/lib/juju/agents/unit-coredns-0/charm/venv/lightkube/core/generic_client.py", line 82, in __init__
    config = KubeConfig.from_env().get()
  File "/var/lib/juju/agents/unit-coredns-0/charm/venv/lightkube/config/kubeconfig.py", line 212, in from_env
    return KubeConfig.from_file(os.environ.get('KUBECONFIG', default_config))
  File "/var/lib/juju/agents/unit-coredns-0/charm/venv/lightkube/config/kubeconfig.py", line 142, in from_file
    raise exceptions.ConfigError(f"Configuration file {fname} not found")
lightkube.core.exceptions.ConfigError: Configuration file ~/.kube/config not found

Revision history for this message
George Kraft (cynerva) wrote :
Changed in charm-coredns:
milestone: none → 1.28+ck1
importance: Undecided → Medium
assignee: nobody → George Kraft (cynerva)
status: New → In Progress
Revision history for this message
George Kraft (cynerva) wrote :
Changed in charm-coredns:
status: In Progress → Fix Committed
Adam Dyess (addyess)
tags: added: backport-needed
Revision history for this message
Adam Dyess (addyess) wrote :

Thanks @cynerva for the cherry-pick. No other backport needed

tags: removed: backport-needed
Adam Dyess (addyess)
Changed in charm-coredns:
status: Fix Committed → Fix Released
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.