juju / juju-crashdump

Script to assist in gathering logs and other debugging info from a Juju model
MIT License
10 stars 23 forks source link

Exception when running juju-crashdump on a kubernetes-model #98

Open addyess opened 2 years ago

addyess commented 2 years ago

i'm GUESSING that list(services.values()) is empty?

❯ snap list juju-crashdump
Name            Version               Rev  Tracking       Publisher    Notes
juju-crashdump  1.0.2+git114.6c1c71e  259  latest/stable  jason-hobbs  classic

❯ juju-crashdump -m test-kubernetes-metrics-server-krgf
2022-04-28 14:44:36,738 - juju-crashdump started.
Traceback (most recent call last):
  File "/snap/juju-crashdump/259/bin/juju-crashdump", line 33, in <module>
    sys.exit(load_entry_point('jujucrashdump==0.0.0', 'console_scripts', 'juju-crashdump')())
  File "/snap/juju-crashdump/259/lib/python3.6/site-packages/jujucrashdump/crashdump.py", line 597, in main
    filename = collector.collect()
  File "/snap/juju-crashdump/259/lib/python3.6/site-packages/jujucrashdump/crashdump.py", line 387, in collect
    self.run_addons()
  File "/snap/juju-crashdump/259/lib/python3.6/site-packages/jujucrashdump/crashdump.py", line 277, in run_addons
    units = [v for v in list(set.union(*list(services.values()))) if "/" in v]
TypeError: descriptor 'union' of 'set' object needs an argument
addyess commented 2 years ago

here's the juju status for the model:

❯ juju status --format yaml
model:
  name: test-kubernetes-metrics-server-krgf
  type: caas
  controller: addyess-vsphere
  cloud: k8s-cloud
  region: default
  version: 2.9.28
  model-status:
    current: destroying
    message: 'attempt 5 to destroy model failed (will retry):  model not empty, found
      1 application (model not empty)'
    since: 28 Apr 2022 14:28:28-05:00
  sla: unsupported
machines: {}
applications:
  prometheus:
    charm: prometheus-k8s
    series: kubernetes
    os: kubernetes
    charm-origin: charmhub
    charm-name: prometheus-k8s
    charm-rev: 20
    charm-channel: beta
    scale: 1
    exposed: false
    life: dying
    application-status:
      current: error
      message: 'StorageClass.storage.k8s.io "test-kubernetes-metrics-server-krgf-"
        is invalid: [metadata.name: Invalid value: "test-kubernetes-metrics-server-krgf-":
        a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters,
        ''-'' or ''.'', and must start and end with an alphanumeric character (e.g.
        ''example.com'', regex used for validation is ''[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*''),
        provisioner: Required value]'
      since: 28 Apr 2022 11:46:47-05:00
    units:
      prometheus/0:
        workload-status:
          current: waiting
          message: installing agent
        juju-status:
          current: allocating
          since: 28 Apr 2022 11:46:42-05:00
    endpoint-bindings:
      "": alpha
      alertmanager: alpha
      grafana-source: alpha
      ingress: alpha
      metrics-endpoint: alpha
      prometheus-peers: alpha
      receive-remote-write: alpha
storage: {}
controller:
  timestamp: 14:47:53-05:00
addyess commented 2 years ago

trouble seems to be here

    def run_addons(self):
        services = service_unit_addresses(self.status)
        machines = services.keys()
        units = [v for v in list(set.union(*list(services.values()))) if "/" in v]
        if not machines:
            return

might should be:

    def run_addons(self):
        services = service_unit_addresses(self.status)
        machines = services.keys()
        if not machines:
            return
        units = [v for v in list(set.union(*list(services.values()))) if "/" in v]
addyess commented 2 years ago

seems like it was introduced in this commit https://github.com/juju/juju-crashdump/commit/db5f663ecbfd17b3b4f8f414fa54fd9c41d6437b

Sponge-Bas commented 2 years ago

Thanks @addyess!

The problem goes a little deeper unfortunately. It looks like service_unit_addresses assumes that the units have a public address, which is not the case if the machine is still allocating. For specific addons it is still nice if we get a list of units.

I will push the previous version back to stable to unblock you and fix this problem tomorrow.

addyess commented 2 years ago

oh... don't goto to too much trouble on my account. Fix at your leisure