Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration to 1.4.0 may fail if default statuses have been modified. #2215

Closed
Rel-iez opened this issue Aug 16, 2022 · 1 comment · Fixed by #2217
Closed

Migration to 1.4.0 may fail if default statuses have been modified. #2215

Rel-iez opened this issue Aug 16, 2022 · 1 comment · Fixed by #2217
Assignees
Labels
impact: high High severity bugs causing system wide impact type: bug Something isn't working as expected
Milestone

Comments

@Rel-iez
Copy link

Rel-iez commented Aug 16, 2022

Environment

  • Python version: 3.9
  • Nautobot version: 1.4.0

Upgrading Nautobot from 1.3.6 to 1.4.0 using the instructions provided in the documentation introduced a conflict with the status
'Retired' if the existing environment already have this status implemented.

The error occurs during migration when running:

nautobot-server post_upgrade

Applying dcim.0014_location_status_data_migration...Unexpected error while running data migration to populate status for dcim.location: duplicate key value violates unique constraint "extras_status_name_key"
DETAIL: Key (name)=(Retired) already exists.

Temporarily solved by renaming the 'Retired' status.

Steps to Reproduce

  1. Have a status called 'Retired' in existing environment.
  2. Upgrade to 1.4.0 from 1.3.x with the same steps as documentation.
  3. Data migration during the post upgrade process will run into a duplicate key value.

Expected Behavior

Successful data migration

Observed Behavior

Unexpected error during post upgrade due to duplicate keys, status name 'Retired'.

@glennmatthews
Copy link
Contributor

glennmatthews commented Aug 16, 2022

Thanks for the report! I haven't encountered this in my own environment, but from code inspection it looks likely that this is going to be the case if any of the pre-populated status's slug, description, or color has been changed from the default values defined in nautobot/extras/management/__init__.py and nautobot/dcim/choices.py.

@glennmatthews glennmatthews added the type: bug Something isn't working as expected label Aug 16, 2022
@bryanculver bryanculver added the impact: high High severity bugs causing system wide impact label Aug 16, 2022
@bryanculver bryanculver added this to the v1.4.1 milestone Aug 16, 2022
@glennmatthews glennmatthews self-assigned this Aug 16, 2022
@glennmatthews glennmatthews changed the title Status 'Retired' implemented in 1.4.0 conflicts with existing status name Migration to 1.4.0 may fail if default statuses have been modified. Aug 16, 2022
glennmatthews added a commit that referenced this issue Aug 17, 2022
…2217)

* Fix #2215 - avoid error during migrations if default statuses have been modified

* Some suggestions from code review

Co-authored-by: Jathan McCollum <jathan@gmail.com>

* Address more review feedback

* Restore formatting. Sorry @glennmatthews

Co-authored-by: Jathan McCollum <jathan@gmail.com>
Co-authored-by: Bryan Culver <bryan.culver@networktocode.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: high High severity bugs causing system wide impact type: bug Something isn't working as expected
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants