nautobot / nautobot-lab

All-in-one Docker container that allows a user to explore Nautobot in a lab environment.
Apache License 2.0
41 stars 13 forks source link

Nautobot-Lab Latest Programming Error When Get on DCIM/Device #38

Closed jvanderaa closed 3 years ago

jvanderaa commented 3 years ago

Setup

  1. Pull latest images
  2. Run docker command
  3. Load demo data (to get the API key)

Error Execution

  1. Navigate to the API
  2. Navigate to dcim/devices/ GET method
  3. On name key search for ams-leaf-01
  4. Receive a programming error
{
  "error": "relation \"extras_configcontext_device_types\" does not exist\nLINE 1: ...V0.\"id\" = V13.\"configcontext_id\") LEFT OUTER JOIN \"extras_co...\n                                                             ^\n",
  "exception": "ProgrammingError",
  "nautobot_version": "1.0.2",
  "python_version": "3.8.5"
}

This is not present on demo.nautobot.com nor on a pip installed version of Nautobot.

glennmatthews commented 3 years ago

Sounds like maybe the migration added in https://github.com/nautobot/nautobot/pull/441 is missing or unapplied?

jtdub commented 3 years ago

That may be a possibility, @glennmatthews. The mock data script blows away the schema and recreates it from the dump. I'll test tomorrow and verify.

jtdub commented 3 years ago

@jvanderaa - It looks like @glennmatthews was spot on. I was able to replicate your issue AND was able to do a nautobot-server migrate after load-mock-data to resolve it. Can you do the same to verify that it works for you?

If so, I'll work on a change that will resolve the underlying issue in the future.

% docker pull networktocode/nautobot-lab
Using default tag: latest
latest: Pulling from networktocode/nautobot-lab
5d3b2c2d21bb: Already exists
3fc2062ea667: Already exists
75adf526d75b: Already exists
335a4231eb20: Pull complete
74524f24a48e: Pull complete
f2e672119501: Pull complete
4fd21b38fd9b: Pull complete
Digest: sha256:888a9c7bf18bc36a9d1957895937821c6552bf97d4b0bae913150952a8c4c8e1
Status: Downloaded newer image for networktocode/nautobot-lab:latest
docker.io/networktocode/nautobot-lab:latest

% docker run -itd --name nautobot -p 80:8000 networktocode/nautobot-lab:latest
75179f0d9a958c456f0afa345fc538b2a59334535eadba0171125fbd9374abc0

% docker ps -a
CONTAINER ID   IMAGE                               COMMAND                  CREATED          STATUS                    PORTS                                   NAMES
75179f0d9a95   networktocode/nautobot-lab:latest   "/usr/local/bin/supe…"   37 seconds ago   Up 35 seconds (healthy)   0.0.0.0:80->8000/tcp, :::80->8000/tcp   nautobot

% docker exec -it nautobot load-mock-data
NOTICE:  drop cascades to 109 other objects
DETAIL:  drop cascades to table django_migrations
...
ALTER TABLE
ALTER TABLE
ALTER TABLE

curl -X GET "http://localhost/api/dcim/devices/?name__n=ams-leaf-01" -H  "accept: application/json" -H  "Authorization: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -H  "X-CSRFToken: jeowjfIBtm6N7KKObWMfYPuEIAd08tEjXPBXLUbt9icke8CYqnWOaTZEHicCsEhP"

{
  "error": "relation \"extras_configcontext_device_types\" does not exist\nLINE 1: ...V0.\"id\" = V13.\"configcontext_id\") LEFT OUTER JOIN \"extras_co...\n                                                             ^\n",
  "exception": "ProgrammingError",
  "nautobot_version": "1.0.2",
  "python_version": "3.8.5"
}

% docker exec -it nautobot bash

root@75179f0d9a95:/opt/nautobot# nautobot-server migrate
Operations to perform:
  Apply all migrations: admin, auth, circuits, contenttypes, dcim, extras, ipam, sessions, social_django, taggit, tenancy, users, virtualization
Running migrations:
  Applying extras.0005_configcontext_device_types... OK
  Applying ipam.0003_remove_max_length... OK

curl -X GET "http://localhost/api/dcim/devices/?name=ams-leaf-01" -H  "accept: application/json" -H  "X-CSRFToken: ndOAglvDP7cBEg9gyKn2I0Q8BRaiI4Jv1O11I0Yvv3i8LE1qNbxBU4l8Az9U2fm1"

{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": "e8b7b7f8-7509-439a-a4d7-fd9ca3df6763",
      "url": "http://localhost/api/dcim/devices/e8b7b7f8-7509-439a-a4d7-fd9ca3df6763/",
      "name": "ams-leaf-01",
      "device_type": {
        "id": "b77ff7f2-c9ac-49f1-a74e-9dc32545ce1e",
        "url": "http://localhost/api/dcim/device-types/b77ff7f2-c9ac-49f1-a74e-9dc32545ce1e/",
        "manufacturer": {
          "id": "7aa233a3-ba26-4a4f-be03-c404f475c247",
          "url": "http://localhost/api/dcim/manufacturers/7aa233a3-ba26-4a4f-be03-c404f475c247/",
          "name": "Arista",
          "slug": "arista",
          "display": "Arista"
        },
        "model": "DCS-7150S-24",
        "slug": "dcs-7150s-24",
        "display": "Arista DCS-7150S-24"
      },
      "device_role": {
        "id": "bf357808-a599-45a4-aaf0-eef07e05bd8e",
        "url": "http://localhost/api/dcim/device-roles/bf357808-a599-45a4-aaf0-eef07e05bd8e/",
        "name": "leaf",
        "slug": "leaf",
        "display": "leaf"
      },
      "tenant": null,
      "platform": null,
      "serial": "",
      "asset_tag": null,
      "site": {
        "id": "90065c0c-38a5-441d-9651-76ec6f8ad8fd",
        "url": "http://localhost/api/dcim/sites/90065c0c-38a5-441d-9651-76ec6f8ad8fd/",
        "name": "ams",
        "slug": "ams",
        "display": "ams"
      },
      "rack": {
        "id": "a881fb24-87d4-48c3-83f1-aeb9d6f4a52d",
        "url": "http://localhost/api/dcim/racks/a881fb24-87d4-48c3-83f1-aeb9d6f4a52d/",
        "name": "ams-101",
        "display": "ams-101"
      },
      "position": 44,
      "face": {
        "value": "front",
        "label": "Front"
      },
      "parent_device": null,
      "status": {
        "value": "active",
        "label": "Active"
      },
      "primary_ip": null,
      "primary_ip4": null,
      "primary_ip6": null,
      "cluster": null,
      "virtual_chassis": null,
      "vc_position": null,
      "vc_priority": null,
      "comments": "",
      "local_context_data": null,
      "tags": [],
      "custom_fields": {},
      "config_context": {
        "cdp": true,
        "ntp": [
          {
            "ip": "10.1.1.1",
            "prefer": false
          },
          {
            "ip": "10.2.2.2",
            "prefer": true
          }
        ],
        "lldp": true,
        "snmp": {
          "host": [
            {
              "ip": "10.1.1.1",
              "version": "2c",
              "community": "networktocode"
            }
          ],
          "contact": "John Smith",
          "location": "Network to Code - NYC | NY",
          "community": [
            {
              "name": "ntc-public",
              "role": "RO"
            },
            {
              "name": "ntc-private",
              "role": "RW"
            },
            {
              "name": "networktocode",
              "role": "RO"
            },
            {
              "name": "secure",
              "role": "RW"
            }
          ]
        },
        "aaa-new-model": false,
        "acl": {
          "definitions": {
            "named": {
              "PERMIT_ROUTES": [
                "10 permit ip any any"
              ]
            }
          }
        },
        "route-maps": {
          "PERMIT_CONN_ROUTES": {
            "seq": 10,
            "type": "permit",
            "statements": [
              "match ip address PERMIT_ROUTES"
            ]
          }
        }
      },
      "created": "2021-04-16",
      "last_updated": "2021-04-16T13:39:30.981193Z",
      "display": "ams-leaf-01"
    }
  ]
}
jvanderaa commented 3 years ago

Makes sense. I will try to test that fix out if possible.

jvanderaa commented 3 years ago

Let's go for it!