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

nautobot fails on Running migration #88

Open
BitumarInc opened this issue Sep 13, 2024 · 1 comment
Open

nautobot fails on Running migration #88

BitumarInc opened this issue Sep 13, 2024 · 1 comment
Labels
question Further information is requested

Comments

@BitumarInc
Copy link

Issue: When I try to running my compose file (see below) it fails:

  Applying users.0002_token_ordering_by_created... OK
  Applying users.0003_alter_user_options... OK
  Applying users.0004_alter_user_managers... OK
  Applying users.0005_ensure_object_permission_names_are_unique... OK
  Applying users.0006_make_object_permission_name_globally_unique... OK
  Applying users.0007_alter_objectpermission_object_types... OK
  Applying users.0008_make_object_permission_a_changelogged_model... OK
  Applying users.0009_update_all_charfields_max_length_to_255... OK
  Applying users.0010_user_default_saved_views... OK
  Applying virtualization.0027_virtualmachine_software_image... OK
  Applying virtualization.0028_update_all_charfields_max_length_to_255... OK
  Applying virtualization.0029_add_role_field_to_interface_models... OK
  Applying virtualization.0030_alter_virtualmachine_local_config_context_data_owner_content_type_and_more... OK
20:39:25.030 INFO    nautobot.extras.utils utils.py        refresh_job_model_from_job_class() :
  Created Job "System Jobs: Export Object List" from <ExportObjectList>
20:39:25.056 INFO    nautobot.extras.utils utils.py        refresh_job_model_from_job_class() :
  Created Job "System Jobs: Git Repository: Sync" from <GitRepositorySync>
20:39:25.081 INFO    nautobot.extras.utils utils.py        refresh_job_model_from_job_class() :
  Created Job "System Jobs: Git Repository: Dry-Run" from <GitRepositoryDryRun>
20:39:25.101 INFO    nautobot.extras.utils utils.py        refresh_job_model_from_job_class() :
  Created Job "System Jobs: Import Objects" from <ImportObjects>
20:39:25.120 INFO    nautobot.extras.utils utils.py        refresh_job_model_from_job_class() :
  Created Job "System Jobs: Logs Cleanup" from <LogsCleanup>
20:39:25.139 INFO    nautobot.extras.utils utils.py        refresh_job_model_from_job_class() :
  Created Job "System Jobs: Refresh Dynamic Group Caches" from <RefreshDynamicGroupCaches>

Generating cable paths...
Found no missing circuit termination paths; skipping
Found no missing console port paths; skipping
Found no missing console server port paths; skipping
Found no missing interface paths; skipping
Found no missing power feed paths; skipping
Found no missing power outlet paths; skipping
Found no missing power port paths; skipping
Finished.

Collecting static files...

1156 static files copied to '/opt/nautobot/static'.

Removing stale content types...

Removing expired sessions...

Sending installation metrics...
Sending installation metrics to 'https://nautobot.cloud/api/nautobot/installation-metric/':
{
    "deployment_id": "1e7cdc41-af5e-4617-836a-983522c9e9f7",
    "nautobot_version": "2.3.2",
    "python_version": "3.12.5",
    "installed_apps": {},
    "debug": true
}
Failed to send installation metrics to 'https://nautobot.cloud/api/nautobot/installation-metric/: HTTPSConnectionPool(host='nautobot.cloud', port=443): Max retries exceeded with url: /api/nautobot/installation-metric/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)')))
To disable installation metrics, set INSTALLATION_METRICS_ENABLED = False in your Nautobot config.

Refreshing _content_type cache
CONTENT_TYPE_CACHE_TIMEOUT is set to 0; skipping cache refresh

Refreshing dynamic group member caches...
Refreshing DynamicGroup member caches...

❌ **Waited 0s or more for the DB to become ready**.

I did confirm that the DB is online:

nerdctl run --rm -it --network nautobot-sot_nautobot jbergknoff/postgresql-client "postgresql://$NAUTOBOT_DB_USER:$NAUTOBOT_DB_PASSWORD@$NAUTOBOT_DB_HOST:$NAUTOBOT_DB_PORT"

nautobot=> \l
                                 List of databases
   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges   
-----------+----------+----------+------------+------------+-----------------------
 nautobot  | nautobot | UTF8     | en_US.utf8 | en_US.utf8 | =Tc/nautobot         +
           |          |          |            |            | nautobot=CTc/nautobot
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
(4 rows)

nautobot=> \du
                                   List of roles
 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 nautobot  |                                                            | {}
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

 public | virtualization_vminterface_tagged_vlans            | table | nautobot
(187 rows)

nautobot=> \l
                                 List of databases
   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges   
-----------+----------+----------+------------+------------+-----------------------
 nautobot  | nautobot | UTF8     | en_US.utf8 | en_US.utf8 | =Tc/nautobot         +
           |          |          |            |            | nautobot=CTc/nautobot
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
(4 rows)

nautobot=> \du
                                   List of roles
 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 nautobot  |                                                            | {}
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

nautobot=> \dt
                               List of relations
 Schema |                        Name                        | Type  |  Owner   
--------+----------------------------------------------------+-------+----------
 public | auth_group                                         | table | nautobot
 public | auth_group_permissions                             | table | nautobot
 public | auth_permission                                    | table | nautobot
 public | auth_user                                          | table | nautobot
 public | auth_user_groups                                   | table | nautobot
 public | auth_user_user_permissions                         | table | nautobot
 public | circuits_circuit                                   | table | nautobot
 public | circuits_circuittermination                        | table | nautobot
 public | circuits_circuittype                               | table | nautobot
 public | circuits_provider                                  | table | nautobot
 public | circuits_providernetwork                           | table | nautobot
 public | cloud_cloudaccount                                 | table | nautobot
 public | cloud_cloudnetwork                                 | table | nautobot
 public | cloud_cloudnetworkprefixassignment                 | table | nautobot
 public | cloud_cloudresourcetype                            | table | nautobot
 public | cloud_cloudresourcetype_content_types              | table | nautobot
 public | cloud_cloudservice                                 | table | nautobot
 public | cloud_cloudservicenetworkassignment                | table | nautobot
 public | constance_constance                                | table | nautobot
 public | dcim_cable                                         | table | nautobot
 public | dcim_cablepath                                     | table | nautobot
 public | dcim_consoleport                                   | table | nautobot
 public | dcim_consoleporttemplate                           | table | nautobot
 public | dcim_consoleserverport                             | table | nautobot
 public | dcim_consoleserverporttemplate                     | table | nautobot
 public | dcim_controller                                    | table | nautobot
 public | dcim_controllermanageddevicegroup                  | table | nautobot
 public | dcim_device                                        | table | nautobot
 public | dcim_device_software_image_files                   | table | nautobot
 public | dcim_devicebay                                     | table | nautobot
 public | dcim_devicebaytemplate                             | table | nautobot
 public | dcim_devicefamily                                  | table | nautobot
nautobot=> 

Expected:
the DB migration to complete and nautobot to start/work

Environment:
OS: Fedora Atomic 41
Container : containerd+nerdctl
** containerd version: 1.7.21
** nerdctl version:

  • client: 1.7.6
  • server: 1.7.16

These are the files used:

local.env:


###################################################################
#   nautobot
###################################################################
#https://docs.nautobot.com/projects/helm-charts/en/stable/configuration/reference/#metrics-values (nautobot.db.timeout)

DB_WAIT_TIMEOUT=300
MAX_DB_WAIT_TIME=0
NAUTOBOT_DOCKER_SKIP_INIT=false

NAUTOBOT_SUPERUSER_NAME=admin
[email protected]

NAUTOBOT_DEBUG=true
###################################################################
#   uwsgi
###################################################################
NAUTOBOT_UWSGI_PROCESSES=$[$(nproc)+1]
NAUTOBOT_UWSGI_LISTEN="db:8001"
NAUTOBOT_UWSGI_BUFFER_SIZE=4096

#NAUTOBOT_SECRET_KEY

NAUTOBOT_ALLOWED_HOSTS=[*]

###################################################################
#   db
###################################################################

#NAUTOBOT_DB_TIMEOUT

NAUTOBOT_DB_ENGINE=django.db.backends.postgresql

NAUTOBOT_DB_HOST=nautobot_db
NAUTOBOT_DB_PORT=5432
NAUTOBOT_DB_NAME=nautobot
NAUTOBOT_DB_USER=nautobot

###################################################################
#   redis
###################################################################
NAUTOBOT_REDIS_HOST=nautobot_redis
NAUTOBOT_REDIS_PORT=6379

REDIS_VERSION=7.2.5

secrets.env

###################################################################
#   nautobot
###################################################################
NAUTOBOT_CREATE_SUPERUSER=true
NAUTOBOT_SUPERUSER_PASSWORD=xxxx
NAUTOBOT_SUPERUSER_API_TOKEN=xxx
###################################################################
#   db
###################################################################

NAUTOBOT_DB_PASSWORD=xxxx

#password of the superuser \$POSTGRES_USER
POSTGRES_PASSWORD=xxxx

###################################################################
#   NAPALM
###################################################################
NAUTOBOT_NAPALM_USERNAME=napalm
NAUTOBOT_NAPALM_PASSWORD=xxxx
#NAUTOBOT_NAPALM_TIMEOUT

###################################################################
#   redis
###################################################################

NAUTOBOT_REDIS_USERNAME=default
NAUTOBOT_REDIS_PASSWORD=xxxxx

Init script:

NAUTOBOT_DB_PASSWORD=$(cat secrets.env |grep "NAUTOBOT_DB_PASSWORD"|cut -d'=' -f2)
NAUTOBOT_DB_USER=$(cat local.env |grep "NAUTOBOT_DB_USER"|cut -d'=' -f2)
REDIS_VERSION=$(cat local.env |grep "REDIS_VERSION"|cut -d'=' -f2)

PG_INIT_SCRIPT_DIR=$HOME/postgreSQL/scripts

mkdir -p $PG_INIT_SCRIPT_DIR

cat<<EOSQL > $PG_INIT_SCRIPT_DIR/1_nautobot-init.sql
CREATE DATABASE $NAUTOBOT_DB_USER;
CREATE USER nautobot WITH PASSWORD '$NAUTOBOT_DB_PASSWORD';
GRANT ALL PRIVILEGES ON DATABASE nautobot TO nautobot;
\connect nautobot
GRANT CREATE ON SCHEMA public TO nautobot;
GRANT USAGE ON SCHEMA public TO nautobot;
ALTER DATABASE nautobot OWNER TO nautobot;
EOSQL

NAUTOBOT_DB_PASSWORD=$(cat secrets.env |grep "NAUTOBOT_DB_PASSWORD"|cut -d'=' -f2)
NAUTOBOT_DB_USER=$(cat local.env |grep "NAUTOBOT_DB_USER"|cut -d'=' -f2)
NAUTOBOT_DB_HOST=$(cat local.env |grep "NAUTOBOT_DB_HOST"|cut -d'=' -f2)
NAUTOBOT_DB_PORT=$(cat local.env |grep "NAUTOBOT_DB_PORT"|cut -d'=' -f2)
NAUTOBOT_REDIS_PASSWORD=$(cat secrets.env |grep "NAUTOBOT_REDIS_PASSWORD"|cut -d'=' -f2)

nautobot.yaml

name: nautobot-sot

services:
  db:
    image: postgres:14.13-alpine3.20
    container_name: nautobot_db
    env_file:
      - "local.env"
      - "secrets.env"
    healthcheck:
      #CHANGE 1: this command checks if the database is ready, right on the source db server
      test: [ "CMD-SHELL", "pg_isready" ]
      interval: 5s
      timeout: 5s
      retries: 5
    ports:          
      - "5432:5432"
    volumes:
      - $PG_INIT_SCRIPT_DIR:/docker-entrypoint-initdb.d:Z
      - VOL_DB_DATA:/var/lib/postgresql/data:Z    
    networks:
      - nautobot    

  redis:    
    image: "redis:$REDIS_VERSION-alpine"
    container_name: nautobot_redis
    healthcheck:
      test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]    
    command:
      - "sh"
      - "-c"  
      - "redis-server --appendonly yes --requirepass $NAUTOBOT_REDIS_PASSWORD"
    env_file:
      - "local.env"
      - "secrets.env"
    networks:
      - nautobot  

  nautobot:
    image: networktocode/nautobot:2.3
    container_name: nautobot_app    
    volumes:
      - VOL_NAUTOBOT_CFG:/opt/nautobot
    depends_on:
      "db":
        condition: service_healthy
      "redis":
        condition: service_healthy      
    env_file:
      - "local.env"
      - "secrets.env" 
    networks:
      - nautobot 

  pgclient:
    image: jbergknoff/postgresql-client
    depends_on:
      "db":  
        condition: service_healthy 
    command: "postgresql://$NAUTOBOT_DB_USER:$NAUTOBOT_DB_PASSWORD@$NAUTOBOT_DB_HOST:$NAUTOBOT_DB_PORT/db"
    networks:
      - nautobot        
volumes:
  VOL_DB_DATA:  
  VOL_NAUTOBOT_CFG:
networks:
  nautobot:

Command to execute the compose file:

nerdctl compose -f nautobot.yaml up
@jdrew82
Copy link
Contributor

jdrew82 commented Sep 17, 2024

@BitumarInc is there a particular reason you're creating your own compose file instead of using the ones we have included along with using invoke? The specific reason why you're having this issue though is your NAUTOBOT_DB_HOST configuration. It appears you're pointing to nautobot_db when the service is called db.

@jdrew82 jdrew82 added the question Further information is requested label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants