remove_dnsha does not use `name` parameter

Bug #2037515 reported by Samuel Allan
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Kubernetes API Load Balancer
New
Undecided
Unassigned
charm-interface-hacluster
Fix Released
Undecided
Unassigned

Bug Description

The remove_dnsha method takes a `name` parameter, but does not use it. Instead, it uses `self.service_name`, which is not always defined. This was discovered by a crash in kubeapi-load-balancer charm:

```
2023-09-27 07:44:58 ERROR unit.kubeapi-load-balancer/0.juju-log server.go:325 'HAServiceRequires' object has no attribute 'service_name'
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-kubeapi-load-balancer-0/charm/venv/charms/reconciler.py", line 34, in reconcile
    result = self.reconcile_function(event)
  File "/var/lib/juju/agents/unit-kubeapi-load-balancer-0/charm/./src/charm.py", line 333, in _reconcile
    self._configure_hacluster()
  File "/var/lib/juju/agents/unit-kubeapi-load-balancer-0/charm/./src/charm.py", line 115, in _configure_hacluster
    self.hacluster.update_dns()
  File "/var/lib/juju/agents/unit-kubeapi-load-balancer-0/charm/src/hacluster.py", line 136, in update_dns
    self.interface.remove_dnsha(self._unit_name, "public")
  File "/var/lib/juju/agents/unit-kubeapi-load-balancer-0/charm/venv/interface_hacluster/common.py", line 258, in remove_dnsha
    self.service_name.replace('-', '_'),
AttributeError: 'HAServiceRequires' object has no attribute 'service_name'
```

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-interface-hacluster (master)
Changed in charm-interface-hacluster:
status: New → In Progress
tags: added: cdo-qa foundations-engine
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to charm-interface-hacluster (master)

Reviewed: https://review.opendev.org/c/openstack/charm-interface-hacluster/+/896620
Committed: https://opendev.org/openstack/charm-interface-hacluster/commit/d91e83a1fa59a13f4160febfe536c68dc762e436
Submitter: "Zuul (22348)"
Branch: master

commit d91e83a1fa59a13f4160febfe536c68dc762e436
Author: Samuel Walladge <email address hidden>
Date: Wed Sep 27 18:15:42 2023 +0930

    Use the passed arguments in remove_dnsha

    This appears to be a typo, where self.service_name and self.endpoint_type
    was used in the same way as seen in other methods,
    but self.service_name or self.endpoint_type is not defined in this class,
    or any subclasses of it.
    So we can use the passed name and endpoint_type arguments here.

    Closes-Bug: #2037515
    Change-Id: I12c561057372c11632b2d97fa1763fc92d89f479

Changed in charm-interface-hacluster:
status: In Progress → 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.