Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

CustomField issues after upgrading to 1.5.0 #143

Closed
danieltudares opened this issue Feb 10, 2023 · 0 comments · Fixed by #144
Closed

CustomField issues after upgrading to 1.5.0 #143

danieltudares opened this issue Feb 10, 2023 · 0 comments · Fixed by #144

Comments

@danieltudares
Copy link

Environment

  • Python version: 3.10
  • Nautobot version: 1.5.4
  • aristacv-sync version: 1.5.0

Expected Behavior

Upgrade from 1.4.0 to 1.5.0 without issues.

Observed Behavior

Getting an error after upgrading to latest and running nautobot-server post_upgrade

Traceback (most recent call last):
  File "/opt/nautobot/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "extras_customfield_name_key"
DETAIL:  Key (name)=(arista_eostrain) already exists.

Steps to Reproduce

  1. pip install nautobot-ssot-aristacv --upgrade
  2. nautobot-server post_upgrade

More details

I was able to workaround the error by deleting all CustomFields from the Nautobot instance and try again. After that the error is gone and the upgrades succeeds.

Another issue that came with the upgrade to 1.5.0 is that enabling the create controller feature causes some error on the imported CloudVision device. After the initial sync, the CloudVision controller is created with empty CustomFields values. After trying subsequent syncs, there is an error:

Traceback (most recent call last):
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_ssot/jobs/base.py", line 332, in run
    self.sync_data()
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_ssot/jobs/base.py", line 146, in sync_data
    self.load_target_adapter()
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_ssot_aristacv/jobs.py", line 115, in load_target_adapter
    self.target_adapter.load()
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_ssot_aristacv/diffsync/adapters/nautobot.py", line 140, in load
    self.load_devices()
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_ssot_aristacv/diffsync/adapters/nautobot.py", line 45, in load_devices
    version=nautobot.get_device_version(dev),
  File "/opt/nautobot/lib/python3.10/site-packages/nautobot_ssot_aristacv/utils/nautobot.py", line 94, in get_device_version
    version = device.custom_field_data["arista_eos"]
KeyError: 'arista_eos'

After checking further, there is no arista_eos value for the CloudVision device:

>>> for dev in Device.objects.all():
...   print(f"Arista EOS CF for {dev.name} is {dev.custom_field_data['arista_eos'] if dev.custom_field_data.get('arista_eos') else 'MISSING' }")
...
Arista EOS CF for CloudVision is MISSING
Arista EOS CF for nsx01-borderleaf-01 is 4.28.3M
Arista EOS CF for nsx01-leaf-01 is 4.28.5M
Arista EOS CF for nsx01-leaf-02 is 4.28.5M

After manually adding a value to the CloudVision arista_eos field, the problem is solved and subsequent syncs succeeds.

Reference Slack conversation (troubleshoot and debug)

https://networktocode.slack.com/archives/C01NWPK6WHL/p1676042235148109

@qduk qduk closed this as completed in #144 Feb 17, 2023
qduk pushed a commit that referenced this issue Feb 17, 2023
* fix: 🐛 Use update_or_create instead of get_or_create. Fixes #143 and #133

* fix: 🐛 Add handling in case arista_eos field is None

In case the version isn't set this should return empty string

* fix: 🐛 Ensure that EOS Version CF is created for CloudVision

* style: 🚨 Fix linter warnings

---------

Co-authored-by: Justin Drew <jdrew82@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant