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

Are the environment variables set correctly? #61

Open
Leiyiliro opened this issue Apr 17, 2023 · 0 comments
Open

Are the environment variables set correctly? #61

Leiyiliro opened this issue Apr 17, 2023 · 0 comments

Comments

@Leiyiliro
Copy link

I don't really understand python but it seems to me that the application tries to read the environment variable MBSLAVE_DB_DB for the db name and not MBSLAVE_DB_NAME as it is stated in the documentation.

read_env_item(self, 'name', prefix + 'DB_DB')

self.musicbrainz.read_env('MBSLAVE_')

I tried to add MBSLAVE_DB_DB as an environment variable but still for some reason I am getting an error.

The issue I am facing is that although I am setting up the environment variables like this (in a k8s yml file):

containers:
      - name: musicbrainz-db-mirror
        image: leiyiliro/mbslave:1.0  # Specific version of the Docker image
        env:
        - name: MBSLAVE_DB_HOST
          value: musicbrainz-db
        - name: MBSLAVE_DB_PORT
          value: "5432"
        - name: MBSLAVE_DB_NAME
          value: musicbrainz
        - name: MBSLAVE_DB_DB
          value: musicbrainz
          # Used for read and write operations on the MusicBrainz database          
        - name: MBSLAVE_DB_USER
          value: $(POSTGRES_USER)
          # PostgreSQL database password for the general user
        - name: MBSLAVE_DB_PASSWORD
          value: $(POSTGRES_PASSWORD)
          # Used for creating and managing the mbslave database, schema updates, and replication
        - name: MBSLAVE_DB_ADMIN_USER
          value: $(POSTGRES_USER)
          # MusicBrainz Slave admin password for the admin user
        - name: MBSLAVE_DB_ADMIN_PASSWORD
          value: $(POSTGRES_PASSWORD)
        - name: MBSLAVE_MUSICBRAINZ_TOKEN
          value: $(MBSLAVE_MUSICBRAINZ_TOKEN)
        ports:
        - containerPort: 80

The code seems to look for a database with the name of my env variable $(POSTGRES_USER) ,which is "xxxxxx".

Traceback (most recent call last):
2023-04-18 00:30:10   File "/usr/local/bin/mbslave", line 8, in <module>
2023-04-18 00:30:10     sys.exit(main())
2023-04-18 00:30:10              ^^^^^^
2023-04-18 00:30:10   File "/usr/local/lib/python3.11/site-packages/mbdata/replication.py", line 803, in main
2023-04-18 00:30:10     args.func(config, args)
2023-04-18 00:30:10   File "/usr/local/lib/python3.11/site-packages/mbdata/replication.py", line 622, in mbslave_init_main
2023-04-18 00:30:10     create_user(config)
2023-04-18 00:30:10   File "/usr/local/lib/python3.11/site-packages/mbdata/replication.py", line 576, in create_user
2023-04-18 00:30:10     db = connect_db(config, superuser=True, no_db=True)
2023-04-18 00:30:10          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-04-18 00:30:10   File "/usr/local/lib/python3.11/site-packages/mbdata/replication.py", line 209, in connect_db
2023-04-18 00:30:10     return cfg.connect_db(set_search_path=set_search_path, superuser=superuser, no_db=no_db)
2023-04-18 00:30:10            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-04-18 00:30:10   File "/usr/local/lib/python3.11/site-packages/mbdata/replication.py", line 202, in connect_db
2023-04-18 00:30:10     db = psycopg2.connect(**self.database.create_psycopg2_kwargs(superuser=superuser, no_db=no_db))
2023-04-18 00:30:10          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-04-18 00:30:10   File "/usr/local/lib/python3.11/site-packages/psycopg2/__init__.py", line 122, in connect
2023-04-18 00:30:10     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
2023-04-18 00:30:10            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-04-18 00:30:10 psycopg2.OperationalError: FATAL:  database "xxxxxx" does not exist
2023-04-18 00:30:10 
2023-04-18 00:30:10 Traceback (most recent call last):
2023-04-18 00:30:10   File "/usr/local/bin/mbslave", line 8, in <module>
2023-04-18 00:30:10     sys.exit(main())
2023-04-18 00:30:10              ^^^^^^
2023-04-18 00:30:10   File "/usr/local/lib/python3.11/site-packages/mbdata/replication.py", line 803, in main
2023-04-18 00:30:10     args.func(config, args)
2023-04-18 00:30:10   File "/usr/local/lib/python3.11/site-packages/mbdata/replication.py", line 513, in mbslave_sync_main
2023-04-18 00:30:10     cursor.execute("SELECT current_schema_sequence, current_replication_sequence FROM %s.replication_control" % config.schemas.name('musicbrainz'))
2023-04-18 00:30:10 psycopg2.errors.UndefinedTable: relation "musicbrainz.replication_control" does not exist
2023-04-18 00:30:10 LINE 1: ...chema_sequence, current_replication_sequence FROM musicbrain...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant