Page MenuHomePhabricator

netbox update (triggered from reimage script) failed: 'ImportPuppetDB' object has no attribute 'log_error'
Closed, ResolvedPublic

Description

When reimaging bast3004 I got the following traceback:

15:46:51 | Updated Netbox:
15:46:52 | bast3004.wikimedia.org | [info] Processing device bast3004
15:46:52 | bast3004.wikimedia.org | [info] bast3004: removing interface no longer in puppet enp175s0f1d1
15:46:52 | bast3004.wikimedia.org | [failure] An exception occurred: `AttributeError: 'ImportPuppetDB' object has no attribute 'log_error'`

Traceback (most recent call last):

File "/srv/deployment/netbox/deploy-cache/revs/b17db9919cea6f35b569e5b9f3f18a3c2fb24b3f/src/netbox/extras/scripts.py", line 451, in _run_script
  script.output = script.run(**kwargs)
File "/srv/deployment/netbox-extras//customscripts/interface_automation.py", line 803, in run
  messages.extend(self._import_interfaces_for_device(device, net_driver, networking, lldp, False))
File "/srv/deployment/netbox-extras//customscripts/interface_automation.py", line 541, in _import_interfaces_for_device
  self.log_error(f"{device.name}: We want to remove interface {device_interface.name}, however "

AttributeError: 'ImportPuppetDB' object has no attribute 'log_error'

15:46:52 | bast3004.wikimedia.org | [info] Database changes have been reverted due to error.
15:46:52 | bast3004.wikimedia.org | Reimage completed
15:46:52 | bast3004.wikimedia.org | REIMAGE END | retcode=0
15:46:57 | END

Event Timeline

Volans triaged this task as High priority.

Change 664308 had a related patch set uploaded (by Volans; owner: Volans):
[operations/software/netbox-extras@master] interface automation: fix typo in method name

https://gerrit.wikimedia.org/r/664308

Change 664308 merged by Volans:
[operations/software/netbox-extras@master] interface automation: fix typo in method name

https://gerrit.wikimedia.org/r/664308

Change 664309 had a related patch set uploaded (by Volans; owner: Volans):
[operations/software/netbox-extras@master] interface automation: fix typo in method name (2)

https://gerrit.wikimedia.org/r/664309

Change 664309 merged by Volans:
[operations/software/netbox-extras@master] interface automation: fix typo in method name (2)

https://gerrit.wikimedia.org/r/664309

@crusnov passing it over to you. I've fixed the basic typos, but the problem now is that the script tries to remove first before creating and so it stops because the cable is still attached to the old interface.
Old interface is enp175s0f0, new is ens3f0np0.
We should first handle those from puppetdb and then loop over the netbox ones if this doesn't have any other side effect probably.

That seems reasonable, I'll look at it and get a patch out soonish.

Change 664332 had a related patch set uploaded (by CRusnov; owner: CRusnov):
[operations/software/netbox-extras@master] interface_automation: Move interface removal to end

https://gerrit.wikimedia.org/r/664332

Is there anything which needs to be rectified in Netbox for bast3004?

Change 664332 merged by Volans:
[operations/software/netbox-extras@master] interface_automation: Move interface removal to end

https://gerrit.wikimedia.org/r/664332

@MoritzMuehlenhoff I've tested and merged the above change and then I manually run the Netbox script https://netbox.wikimedia.org/extras/scripts/interface_automation.ImportPuppetDB/ against bast3004, that updated the records generating this changelog:
https://netbox.wikimedia.org/extras/changelog/?request_id=1f8e9308-8619-4d1e-be65-0e31fc78b05a

Then I run homer (homer asw2-esams.mgmt.esams.wmnet commit 'Updated bast3004 interface name') that generated this diff:

Configuration diff for asw2-esams.mgmt.esams.wmnet:

[edit interfaces xe-6/0/14]
-   description "bast3004:enp175s0f0 {#20052}";
+   description "bast3004:ens3f0np0 {#20052}";
Volans removed crusnov as the assignee of this task.