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

Error: The connection 'schema_branch_BRANCH' doesn't exist #167

Open
mhdask opened this issue Nov 6, 2024 · 6 comments
Open

Error: The connection 'schema_branch_BRANCH' doesn't exist #167

mhdask opened this issue Nov 6, 2024 · 6 comments
Assignees

Comments

@mhdask
Copy link

mhdask commented Nov 6, 2024

Plugin Version

0.5.1

NetBox Version

4.1.6

Python Version

3.10.12

Steps to Reproduce

My setup looks like this:
I am running postgresql and redis in docker, using docker-compose:

version: '3.4'
services:
  postgres:
    image: postgres:15-alpine
    volumes:
      - netbox-postgres-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=netbox
      - POSTGRES_PASSWORD=
      - POSTGRES_USER=netbox
      - POSTGRES_HOST_AUTH_METHOD=trust
    ports:
      - 5432:5432
  redis:
    ports:
      - 6379:6379
    image: redis:7-alpine
volumes:
  netbox-postgres-data:
    driver: local
  netbox-redis-data:
    driver: local
  1. Run command GRANT CREATE ON DATABASE $database TO $user;
  2. Install plugin (I installed using local_requirements.py)
  3. Put netbox_branching as the last plugin in the file
  4. Create local_settings:
from netbox_branching.utilities import DynamicSchemaDict
from .configuration import DATABASE

# Wrap DATABASES with DynamicSchemaDict for dynamic schema support
DATABASES = DynamicSchemaDict({
    'default': DATABASE,
})

# Employ our custom database router
DATABASE_ROUTERS = [
    'netbox_branching.database.BranchAwareRouter',
]
  1. Start netbox (i activate virtual environment, and use command python3 netbox/manage.py runserver
  2. Create branch
  3. Try to switch to branch - Error occurs

Expected Behavior

I expected that I would be able to switch to the branch

Observed Behavior

Error The connection 'schema_branch_BRANCH' doesn't exist

@mhdask mhdask added the type: bug A confirmed report of unexpected behavior in the application label Nov 6, 2024
@cvitan cvitan added the app: branching label Nov 6, 2024 — with Linear
@jeremystretch
Copy link
Contributor

The connection 'schema_branch_BRANCH' doesn't exist

This error message suggests that the DATABASES setting was not loaded from local_settings.py. This may be a complication of your Docker implementation. Check that local_settings.py exists in the same path as settings.py.

@mhdask
Copy link
Author

mhdask commented Nov 8, 2024

@jeremystretch

The connection 'schema_branch_BRANCH' doesn't exist

This error message suggests that the DATABASES setting was not loaded from local_settings.py. This may be a complication of your Docker implementation. Check that local_settings.py exists in the same path as settings.py.

local_settings.py is located in the same path as settings.py:

/home/user/development/netbox/netbox/netbox/local_settings.py
/home/user/development/netbox/netbox/netbox/settings.py

@arthanson
Copy link
Contributor

arthanson commented Dec 2, 2024

@mhdask this does seem like a mis-configuration issue, did you make any progress on this or are you still experiencing this error? Also what did you name your branch?

@mhdask
Copy link
Author

mhdask commented Dec 10, 2024

@arthanson When I move the contents to the settings.py file instead it works, so I did that - If I try to create the local_settings.py and have the configuration there, it still does not work

@cruse1977
Copy link
Member

Hi, I agree with arthur here - this is a config issue - the following works in netbox-docker (based upon the netbox-docker using plugins wiki entry):

local-settings.py in root of netbox-docker (rather than configuration)

Dockerfile-Plugins

FROM netboxcommunity/netbox:v4.1.6
COPY local_settings.py /opt/netbox/netbox/netbox/local_settings.py
RUN /opt/netbox/venv/bin/pip install netboxlabs-netbox-branching

docker-compose.override.yml

version: '3.4' # This is NOT the version of NetBox! No need to adjust :)
services:
  netbox:
    image: netbox:latest-plugins
    pull_policy: never
    ports:
      - 8000:8080
    build:
      context: .
      dockerfile: Dockerfile-Plugins
    volumes:
  netbox-worker:
    image: netbox:latest-plugins
    pull_policy: never
  netbox-housekeeping:
    image: netbox:latest-plugins
    pull_policy: never

@cruse1977 cruse1977 removed the type: bug A confirmed report of unexpected behavior in the application label Jan 16, 2025
@mhdask
Copy link
Author

mhdask commented Jan 31, 2025

I am NOT running netbox in docker, so I placed local_settings.py in the same folder as configuration.py (/netbox/netbox/netbox/local_settings.py)
Is this not correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants