RuntimeError: Model class pulp_file.app.models.FileContent doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS

Problem: I’m trying to deploy pulp-oci-images using the Compose method on an EC2 instance with an external DB running on RDS and an S3 bucket as the storage backend, but after running docker-compose up, the migration service fails to start, and checking its logs, I can see the error message below:

...
    class FileContent(Content):
  File "/usr/local/lib/python3.9/site-packages/pulpcore/app/models/base.py", line 94, in __new__
    new_class = super().__new__(cls, name, bases, attrs, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/db/models/base.py", line 134, in __new__
    raise RuntimeError(
RuntimeError: Model class pulp_file.app.models.FileContent doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

Expected outcome:

Migration service should complete and pulp should run

Pulpcore version:

3.81

Pulp plugins installed and their versions:

Not sure, as pulp has not started, but the ones installed in the pulp/pulp-minimal:3.81 image

Operating system - distribution and version:

Running pulp/pulp-minimal:3.81 image on Ubuntu 24.04.2 LTS

Other relevant data:

docker-compose.yml:

services:
  migration_service:
    image: pulp/pulp-minimal:3.81
    command: pulpcore-manager migrate --noinput
    volumes:
      - "./settings.py:/etc/pulp/settings.py"
      - "./certs:/etc/pulp/certs"

  signing_key_service:
    image: pulp/pulp-minimal:3.81
    command: sh -c "add_signing_service.sh"
    depends_on:
      migration_service:
        condition: service_completed_successfully
    volumes:
      - "./settings.py:/etc/pulp/settings.py"
      - "./certs:/etc/pulp/certs"

  pulp_web:
    image: "pulp/pulp-web:3.81"
    command: ["/usr/bin/nginx.sh"]
    depends_on:
      pulp_api:
        condition: service_healthy
      pulp_content:
        condition: service_healthy
    ports:
      - "8080:8080"
    hostname: pulp
    user: root
    volumes:
      - "./nginx.sh:/usr/bin/nginx.sh"
      - "./nginx.conf.template:/etc/nginx/nginx.conf.template"
    restart: always

  pulp_api:
    image: pulp/pulp-minimal:3.81
    deploy:
      replicas: 2
    command: ["pulp-api"]
    depends_on:
      migration_service:
        condition: service_completed_successfully
      signing_key_service:
        condition: service_completed_successfully
    hostname: pulp-api
    user: pulp
    volumes:
      - "./settings.py:/etc/pulp/settings.py"
      - "./certs:/etc/pulp/certs"
    restart: always
    healthcheck:
      test: readyz.py /pulp/api/v3/status/
      interval: 10s
      timeout: 5s
      retries: 5

  pulp_content:
    image: pulp/pulp-minimal:3.81
    deploy:
      replicas: 2
    command: ["pulp-content"]
    depends_on:
      migration_service:
        condition: service_completed_successfully
    hostname: pulp-content
    user: pulp
    volumes:
      - "./settings.py:/etc/pulp/settings.py"
      - "./certs:/etc/pulp/certs"
    restart: always
    healthcheck:
      test: readyz.py /pulp/content/
      interval: 10s
      timeout: 5s
      retries: 5

  pulp_worker:
    image: pulp/pulp-minimal:3.81
    deploy:
      replicas: 2
    command: ["pulp-worker"]
    depends_on:
      migration_service:
        condition: service_completed_successfully
    user: pulp
    volumes:
      - "./settings.py:/etc/pulp/settings.py"
      - "./certs:/etc/pulp/certs"
    restart: always

settings.py:

ENABLED_PLUGINS=["pulp_container", "pulp_deb"]
TOKEN_AUTH_DISABLED=True
MEDIA_ROOT=""
REDIRECT_TO_OBJECT_STORAGE=False
STORAGES = {
    "default": {
        "BACKEND": "storages.backends.s3.S3Storage",
        "OPTIONS": {
            "bucket_name": "${s3_bucket}",
            "region_name": "${s3_region}",
        },
    },
    "staticfiles": {
        "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
    },
}
DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "HOST": "${db_hostname}",
        "NAME": "${db_name}",
        "USER": "${db_username}",
        "PASSWORD": "${db_password}",
        "PORT": "5432",
        "CONN_MAX_AGE": 0,
        "OPTIONS": {
            "sslmode": "prefer"
        }
    }
}

I think, pulp_container depends on pulp_file. Can you add pulp_file to the enabled plugins?

1 Like

It works! Thanks for your assistance @x9c4!

However, I’m now facing a different issue with pulp_web service as it keeps exiting and restarting with apparently no logged messages that could help investigate the issue.

The EC2 instance is being provisioned with the script below:

#!/bin/bash

# Install dependencies
apt update -y
apt install docker.io docker-compose unzip -y

# Install AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

# Load pulp db encryption cert/key
# https://pulpproject.org/pulpcore/docs/admin/guides/configure-pulp/db-encryption/
mkdir /home/ubuntu/certs
aws ssm get-parameter --name "${db_key_ssm_name}" --with-decryption --query "Parameter.Value" --output text | tee /home/ubuntu/certs/database_fields.symmetric.key

# Load pulp settings file and secret key
# https://pulpproject.org/pulpcore/docs/admin/reference/settings/#secret_key
echo "${settings}" | tee /home/ubuntu/settings.py
SECRET_KEY=$(aws ssm get-parameter --name "${django_secret_key_ssm_name}" --with-decryption --query "Parameter.Value" --output text)
echo SECRET_KEY=\"$SECRET_KEY\" >> /home/ubuntu/settings.py

# Load nginx script and conf template
# https://github.com/pulp/pulp-oci-images/blob/latest/images/compose
echo "${nginx_script}" | tee /home/ubuntu/nginx.sh
echo "${nginx_conf}" | tee /home/ubuntu/nginx.conf.template
chmod 777 /home/ubuntu/nginx.sh /home/ubuntu/nginx.conf.template

echo "${docker_compose}" | tee /home/ubuntu/docker-compose.yml
docker-compose -f /home/ubuntu/docker-compose.yml up -d