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

when deploy by docker-compose, after set oncall env default value, the env value is wrong #3620

Closed
lianghuiyuan opened this issue Jan 5, 2024 · 1 comment

Comments

@lianghuiyuan
Copy link

What went wrong?

What happened:

  • when deploy by docker-compose, after set oncall env default value, the env value is wrong
    eg: set oncall env DATABASE_TYPE DATABASE_TYPE=${ONCALL_DATABASE_TYPE:-sqlite3} and ONCALL_DATABASE_TYPE=SQLITE3
    expect DATABASE_TYPE= SQLITE3 or DATABASE_TYPE=sqlite3
    but get an error "DATABASE_TYPE=SQLITE3:-sqlite3}",

What did you expect to happen:

  • after set oncall env default value, if env is set, use env value; if env not set, use the default value

How do we reproduce it?

  1. config env file
  • docker-compose.yaml
---
version: "3.9"

networks:
  xxx-network:
    external: true

services:
  engine:
    image: ${ONCALL_IMAGE:-grafana/oncall:latest}
    container_name: oncall-engine
    restart: always
    ports:
      - ${ONCALL_ENGINE_PORT:-8080}:8080
    command: sh -c "uwsgi --ini uwsgi.ini"
    env_file:
      - ./config/oncall.env
    volumes:
      - ${ONCALL_ROOT_DATA:-/oncall}:/var/lib/oncall
    depends_on:
      oncall_db_migration:
        condition: service_completed_successfully
      redis:
        condition: service_healthy        
    networks:
      - xxx-network

  celery:
    image: ${ONCALL_IMAGE:-grafana/oncall:latest}
    container_name: oncall-celery
    restart: always
    command: sh -c "./celery_with_exporter.sh"
    env_file:
      - ./config/oncall.env    
    volumes:
      - /jetmon/oncall:/var/lib/oncall
    depends_on:
      oncall_db_migration:
        condition: service_completed_successfully
      redis:
        condition: service_healthy
    networks:
      - xxx-network        

  oncall_db_migration:
    image: ${ONCALL_IMAGE:-grafana/oncall:latest}
    container_name: oncall_db_migration
    command: python manage.py migrate --noinput
    env_file:
      - ./config/oncall.env    
    volumes:
      - /jetmon/oncall:/var/lib/oncall
    depends_on:
      redis:
        condition: service_healthy
    networks:
      - xxx-network         

  redis:
    image: ${REDIS_IMAGE:-redis:latest}
    container_name: redis
    restart: always
    expose:
      - ${REDIS_PORT:-6379}:6379
    volumes:
      - ${ROOT_DATA_REDIS:-/redis}:/data
    deploy:
      resources:
        limits:
          memory: 500m
          cpus: "0.5"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      timeout: 5s
      interval: 5s
      retries: 10
    networks:
      - jetmon-network
  • ./config/oncall.env
# Grafana on-call Config
TZ=${TZ:-Asia/Shanghai}
BASE_URL=${ONCALL_BASE_URL:-'http://localhost:8080}
DATABASE_TYPE=${ONCALL_DATABASE_TYPE:-sqlite3}
BROKER_TYPE=${ONCALL_BROKER_TYPE:-redis}
REDIS_URI=${ONCALL_REDIS_URI:-redis://redis:6379/0}
FEATURE_PROMETHEUS_EXPORTER_ENABLED=${ONCALL_FEATURE_PROMETHEUS_EXPORTER_ENABLED:-false}
PROMETHEUS_EXPORTER_SECRET=${ONCALL_PROMETHEUS_EXPORTER_SECRET:-}
DJANGO_SETTINGS_MODULE=${ONCALL_DJANGO_SETTINGS_MODULE}
SECRET_KEY=${ONCALL_SECRET_KEY:-my_random_secret_must_be_more_than_32_characters_long}
CELERY_WORKER_QUEUE=${ONCALL_CELERY_WORKER_QUEUE:-"default,critical,long,slack,telegram,webhook,retry,celery"}
CELERY_WORKER_CONCURRENCY=${ONCALL_CELERY_WORKER_CONCURRENCY:-3}
CELERY_WORKER_MAX_TASKS_PER_CHILD=${ONCALL_CELERY_WORKER_MAX_TASKS_PER_CHILD:-100}
CELERY_WORKER_SHUTDOWN_INTERVAL=${ONCALL_CELERY_WORKER_SHUTDOWN_INTERVAL:-65m}
CELERY_WORKER_BEAT_ENABLED=${ONCALL_CELERY_WORKER_BEAT_ENABLED:-True}
CELERY_WORKER_DEBUG_LOGS=${ONCALL_CELERY_WORKER_DEBUG_LOGS:-false}
GRAFANA_API_URL=${ONCALL_GRAFANA_API_URL:-http://grafana:3000}


# email SMTP config
ENABLE_SMTP_EMAIL_BACKEND=${ONCALL_ENABLE_SMTP_EMAIL_BACKEND:-True}
FEATURE_EMAIL_INTEGRATION_ENABLED=${ONCALL_FEATURE_EMAIL_INTEGRATION_ENABLED:-True}
FEATURE_LIVE_SETTINGS_ENABLED=${ONCALL_FEATURE_LIVE_SETTINGS_ENABLED:-false}
EMAIL_HOST=${ONCALL_SMTP_HOST:-localhost}
EMAIL_HOST_USER=${ONCALL_SMTP_USER:-}
EMAIL_HOST_PASSWORD=${ONCALL_SMTP_PASSWORD:-}
EMAIL_PORT=${ONCALL_SMTP_PORT:-587}
EMAIL_USE_TLS=${ONCALL_EMAIL_USE_TLS:-false}
EMAIL_FROM_ADDRESS=${ONCALL_SMTP_FROM_ADDRESS:-}
  • .env
# on-call 配置
ONCALL_IMAGE=grafana/oncall:latest
ONCALL_ENGINE_PORT=8080
ONCALL_ROOT_DATA=/xxx/oncall
ONCALL_BASE_URL=http://engine:8080
ONCALL_DATABASE_TYPE=SQLITE3 
ONCALL_BROKER_TYPE=redis          
ONCALL_REDIS_URI=redis://redis:6379/0
ONCALL_FEATURE_PROMETHEUS_EXPORTER_ENABLED=true
# ONCALL_PROMETHEUS_EXPORTER_SECRET=xxx   
ONCALL_DJANGO_SETTINGS_MODULE="settings.hobby"
ONCALL_SECRET_KEY=V7fTScDq8lxyghjfjdjhdhfcvb6546477674567467467467536325245xtXRfCpoQhh   
ONCALL_CELERY_WORKER_QUEUE="default,critical,long,slack,telegram,webhook,retry,celery"  
ONCALL_CELERY_WORKER_CONCURRENCY="3"  
ONCALL_CELERY_WORKER_MAX_TASKS_PER_CHILD="100"   
ONCALL_CELERY_WORKER_SHUTDOWN_INTERVAL="65m"       
ONCALL_CELERY_WORKER_BEAT_ENABLED="True"          
ONCALL_CELERY_WORKER_DEBUG_LOGS=false
ONCALL_GRAFANA_API_URL=http://grafana:3000

ONCALL_FEATURE_EMAIL_INTEGRATION_ENABLED=True
ONCALL_FEATURE_LIVE_SETTINGS_ENABLED=False
ONCALL_ENABLE_SMTP_EMAIL_BACKEND=True
ONCALL_SMTP_HOST=xxx 
ONCALL_EMAIL_USE_TLS=False
ONCALL_SMTP_PORT=25
ONCALL_SMTP_USER=xxx
ONCALL_SMTP_PASSWORD=xxx
ONCALL_SMTP_FROM_ADDRESS= xxx

# redis 配置
REDIS_IMAGE=redis:7.0.5
REDIS_PORT=6379
ROOT_DATA_REDIS=/jetmon/redis
  1. deploy by docker-compose
docker-compose --env-file .env -f docker-compose-grafana.yaml pull && docker-compose -f docker-compose-grafana.yaml up -d
  1. find the errors by docker inspect oncall_db_migration
……
……
"Config": {
            "Hostname": "2a920e1818c1",
            "Domainname": "",
            "User": "1000",
            "AttachStdin": false,
            "AttachStdout": true,
            "AttachStderr": true,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "SECRET_KEY= V7fTScDq8lxyghjfjdjhdhfcvb6546477674567467467467536325245xtXRfCpoQhh:-my_random_secret_must_be_more_than_32_characters_long}",
                "FEATURE_PROMETHEUS_EXPORTER_ENABLED=true:-false}",
                "TZ=Asia/Shanghai",
                "EMAIL_HOST=smtp.xxx.com:-localhost}",
                "CELERY_WORKER_SHUTDOWN_INTERVAL=65m:-65m}",
                "EMAIL_HOST_USER=xxx:-}",
                "PROMETHEUS_EXPORTER_SECRET=:-}",
                "DJANGO_SETTINGS_MODULE=settings.hobby",
                "CELERY_WORKER_MAX_TASKS_PER_CHILD=100:-100}",
                "BASE_URL=http://engine:8080:-'http://localhost:8080}",
                "CELERY_WORKER_DEBUG_LOGS=false:-false}",
                "EMAIL_HOST_PASSWORD=:-}",
                "EMAIL_FROM_ADDRESS=xxx:-}",
                "DATABASE_TYPE=SQLITE3:-sqlite3}",
                "CELERY_WORKER_CONCURRENCY=3:-3}",
                "ENABLE_SMTP_EMAIL_BACKEND=True:-True}",
                "BROKER_TYPE=redis:-redis}",
                "REDIS_URI=redis://redis:6379/0:-redis://redis:6379/0}",
                "FEATURE_LIVE_SETTINGS_ENABLED=False:-false}",
                "CELERY_WORKER_QUEUE=default,critical,long,slack,telegram,webhook,retry,celery:-\"default,critical,long,slack,telegram,webhook,retry,celery\"}",
                "GRAFANA_API_URL=http://grafana:3000:-http://grafana:3000}",
                "CELERY_WORKER_BEAT_ENABLED=True:-True}",
                "FEATURE_EMAIL_INTEGRATION_ENABLED=True:-True}",
                "EMAIL_PORT=25:-587}",
                "EMAIL_USE_TLS=False:-false}",
                "PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "LANG=C.UTF-8",
                "GPG_KEY=A035C8C19219BA821ECEA86B64E628F8D684696D",
                "PYTHON_VERSION=3.11.4",
                "PYTHON_PIP_VERSION=23.1.2",
                "PYTHON_SETUPTOOLS_VERSION=65.5.1",
                "PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/9af82b715db434abb94a0a6f3569f43e72157346/public/get-pip.py",
                "PYTHON_GET_PIP_SHA256=45a2bb8bf2bb5eff16fdd00faef6f29731831c7c59bd9fc2bf1f3bed511ff1fe",
                "APP_USER=appuser",
                "prometheus_multiproc_dir=/tmp/prometheus_django_metrics"
            ],
……
……

Grafana OnCall Version

OnCall (1.3.81, OpenSource)

Product Area

Alert Flow & Configuration, Helm, Other

Grafana OnCall Platform?

Docker

User's Browser?

No response

Anything else to add?

Server: Linux node123 5.4.0-165-generic #182-Ubuntu SMP Mon Oct 2 19:43:28 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

@joeyorlando
Copy link
Contributor

this appears to be a docker-compose syntax issue? Have you checked the docker compose documentation on this?

@joeyorlando joeyorlando closed this as not planned Won't fix, can't repro, duplicate, stale Feb 20, 2024
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

2 participants