azukaar / Cosmos-Server

☁️ The Most Secure and Easy Selfhosted Home Server. Take control of your data and privacy without sacrificing security and stability (Authentication, anti-DDOS, anti-bot)
https://cosmos-cloud.io
Other
3.65k stars 130 forks source link

[BUG]: Creating a stack depends_on with extra parameters i.e. 'condition' fails #295

Closed tcorzo closed 3 months ago

tcorzo commented 3 months ago

What happened?

When trying to import a docker compose file with services.{container}.depends_on.{other_container}.condition the stack creation fails. It's trying to unmarshal it as a string array :(

What should have happened?

It should have correctly parsed the depends_on

How to reproduce the bug?

This docker compose fails, removing the conditions results in circular dependecies and removing the dependencies altogether fails to deploy for infisical-related reasons:

version: "3"

services:
  db-migration:
    container_name: infisical-db-migration
    depends_on:
      db:
        condition: service_healthy
    image: infisical/infisical:latest-postgres
    env_file: .env
    command: npm run migration:latest
    pull_policy: always
    networks:
      - infisical

  backend:
    container_name: infisical-backend
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started
      db-migration:
        condition: service_completed_successfully
    image: infisical/infisical:latest-postgres
    pull_policy: always
    env_file: .env
    ports:
      - 80:8080
    environment:
      - NODE_ENV=production
    networks:
      - infisical

  redis:
    image: redis
    container_name: infisical-dev-redis
    env_file: .env
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
    ports:
      - 6379:6379
    networks:
      - infisical
    volumes:
      - redis_data:/data

  db:
    container_name: infisical-db
    image: postgres:14-alpine
    restart: always
    env_file: .env
    volumes:
      - pg_data:/var/lib/postgresql/data
    networks:
      - infisical
    healthcheck:
      test: "pg_isready --username=${POSTGRES_USER} && psql --username=${POSTGRES_USER} --list"
      interval: 5s
      timeout: 10s
      retries: 10

volumes:
  pg_data:
    driver: local
  redis_data:
    driver: local

networks:
  infisical:

Relevant log output

Creating Service...                              
[OPERATION FAILED] Bad request: json: cannot unmarshal object into Go struct field ContainerCreateRequestContainer.services.depends_on of type []string%!(EXTRA int=400, string=DS003){"status":"error","message":"Bad request: json: cannot unmarshal object into Go struct field ContainerCreateRequestContainer.services.depends_on of type []string","code":"DS003"}

Other details

No response

System details

BearTS commented 3 months ago

Can check this issue next week.

azukaar commented 3 months ago

Thanks Bear, althgouht Issue has been fixed already on the 0.16 branch, I added support for conditions