diff --git a/qms-tests/.env b/qms-tests/.env index 20daf61d0f..bd246840e9 100644 --- a/qms-tests/.env +++ b/qms-tests/.env @@ -1,3 +1,4 @@ STORAGE_CONFIG="minio|minio?accessKey=minioadmin&secretKey=minioadmin" MONGO_URL=mongodb://mongodb:27018?compressors=snappy +DB_PG_URL=postgresql://root@cockroach:26257/defaultdb?sslmode=disable QUEUE_CONFIG=redpanda:9093 diff --git a/qms-tests/docker-compose.yaml b/qms-tests/docker-compose.yaml index 882fc6950d..d395842227 100644 --- a/qms-tests/docker-compose.yaml +++ b/qms-tests/docker-compose.yaml @@ -1,15 +1,13 @@ version: '3' services: - mongodb: - image: 'mongo:7-jammy' + cockroach: + image: cockroachdb/cockroach:v24.1.2 extra_hosts: - 'huly.local:host-gateway' - command: mongod --port 27018 - environment: - - PUID=1000 - - PGID=1000 ports: - - 27018:27018 + - '26258:26257' + - '18089:8080' + command: start-single-node --insecure restart: unless-stopped redpanda: image: docker.redpanda.com/redpandadata/redpanda:v24.3.6 @@ -93,7 +91,7 @@ services: - 'huly.local:host-gateway' pull_policy: never links: - - mongodb + - cockroach - minio ports: - 3003:3003 @@ -104,7 +102,7 @@ services: - ACCOUNT_PORT=3003 - SERVER_SECRET=secret - WORKSPACE_LIMIT_PER_USER=100 - - DB_URL=mongodb://mongodb:27018 + - DB_URL=${DB_PG_URL} - TRANSACTOR_URL=ws://transactor:3334;ws://huly.local:3334 - STORAGE_CONFIG=${STORAGE_CONFIG} - BRANDING_PATH=/var/cfg/branding-test.json @@ -113,15 +111,14 @@ services: extra_hosts: - 'huly.local:host-gateway' links: - - mongodb + - cockroach - minio volumes: - ./branding-test.json:/var/cfg/branding.json environment: - QUEUE_CONFIG=${QUEUE_CONFIG} - SERVER_SECRET=secret - - DB_URL=mongodb://mongodb:27018 - - MONGO_URL=mongodb://mongodb:27018 + - DB_URL=${DB_PG_URL} - TRANSACTOR_URL=ws://transactor:3334;ws://huly.local:3334 - STORAGE_CONFIG=${STORAGE_CONFIG} - ACCOUNTS_URL=http://account:3003 @@ -134,7 +131,7 @@ services: pull_policy: never links: - account - - mongodb + - cockroach - minio - elastic - collaborator @@ -147,7 +144,6 @@ services: - SERVER_PORT=8083 - SERVER_SECRET=secret - ACCOUNTS_URL=http://huly.local:3003 - - MONGO_URL=mongodb://mongodb:27018 - UPLOAD_URL=/files - GMAIL_URL=http://huly.local:8088 - CALENDAR_URL=http://huly.local:8095 @@ -164,7 +160,7 @@ services: - 'huly.local:host-gateway' pull_policy: never links: - - mongodb + - cockroach - minio - rekoni - account @@ -177,7 +173,7 @@ services: - SERVER_PROVIDER=${SERVER_PROVIDER} - SERVER_PORT=3334 - SERVER_SECRET=secret - - DB_URL=mongodb://mongodb:27018 + - DB_URL=${DB_PG_URL} - METRICS_CONSOLE=false - METRICS_FILE=metrics.txt - STORAGE_CONFIG=${STORAGE_CONFIG} @@ -194,7 +190,7 @@ services: extra_hosts: - 'huly.local:host-gateway' links: - - mongodb + - cockroach - minio - transactor ports: @@ -204,7 +200,6 @@ services: - SECRET=secret - ACCOUNTS_URL=http://account:3003 - UPLOAD_URL=/files - - MONGO_URL=mongodb://mongodb:27018 - STORAGE_CONFIG=${STORAGE_CONFIG} restart: unless-stopped rekoni: @@ -221,8 +216,6 @@ services: - 4003:4005 environment: - SECRET=secret - - MONGO_URL=${MONGO_URL} - - MONGO_OPTIONS={"appName":"print","maxPoolSize":1} - STORAGE_CONFIG=${STORAGE_CONFIG} - ACCOUNTS_URL=http://account:3003 deploy: @@ -241,8 +234,6 @@ services: - ../services/sign/pod-sign/debug/branding.json:/var/cfg/branding.json environment: - SECRET=secret - - MONGO_URL=${MONGO_URL} - - MONGO_OPTIONS={"appName":"sign","maxPoolSize":1} - MINIO_ENDPOINT=minio - MINIO_ACCESS_KEY=minioadmin - ACCOUNTS_URL=http://account:3003 @@ -257,17 +248,23 @@ services: fulltext: image: hardcoreeng/fulltext restart: unless-stopped + depends_on: + redpanda: + condition: service_started + cockroach: + condition: service_started links: - elastic - - mongodb + - cockroach - rekoni + - redpanda ports: - 4710:4710 environment: - QUEUE_CONFIG=${QUEUE_CONFIG} - PORT=4710 - SERVER_SECRET=secret - - DB_URL=mongodb://mongodb:27018 + - DB_URL=${DB_PG_URL} - FULLTEXT_DB_URL=http://elastic:9200 - ELASTIC_INDEX_NAME=local_storage_index - STORAGE_CONFIG=${STORAGE_CONFIG} diff --git a/qms-tests/tool-local.sh b/qms-tests/tool-local.sh index 06462d36cf..4ca76cfc98 100755 --- a/qms-tests/tool-local.sh +++ b/qms-tests/tool-local.sh @@ -3,8 +3,8 @@ export MINIO_ACCESS_KEY=minioadmin export MINIO_SECRET_KEY=minioadmin export MINIO_ENDPOINT=localhost:9000 export MONGO_URL=mongodb://localhost:27017 -export DB_URL=mongodb://localhost:27017 -export ACCOUNT_DB_URL=mongodb://localhost:27017 +export DB_URL=postgresql://root@localhost:26257/defaultdb?sslmode=disable +export ACCOUNT_DB_URL=postgresql://root@localhost:26257/defaultdb?sslmode=disable export ACCOUNTS_URL=http://localhost:3000 export TRANSACTOR_URL=ws://localhost:3333 export SERVER_SECRET=secret diff --git a/qms-tests/tool.sh b/qms-tests/tool.sh index 1a5a531691..471b9625ef 100755 --- a/qms-tests/tool.sh +++ b/qms-tests/tool.sh @@ -6,8 +6,8 @@ export MINIO_ENDPOINT=localhost:9002 export ACCOUNTS_URL=http://localhost:3003 export TRANSACTOR_URL=ws://localhost:3334 export MONGO_URL=mongodb://localhost:27018 -export ACCOUNT_DB_URL=mongodb://localhost:27018 -export DB_URL=mongodb://localhost:27018 +export ACCOUNT_DB_URL=postgresql://root@localhost:26258/defaultdb?sslmode=disable +export DB_URL=postgresql://root@localhost:26258/defaultdb?sslmode=disable export SERVER_SECRET=secret export STORAGE_CONFIG="minio|localhost:9002?accessKey=minioadmin&secretKey=minioadmin" export QUEUE_CONFIG=huly.local:19093 diff --git a/server/account-service/src/index.ts b/server/account-service/src/index.ts index 22cc45a961..da7861a634 100644 --- a/server/account-service/src/index.ts +++ b/server/account-service/src/index.ts @@ -49,6 +49,29 @@ export function serveAccount (measureCtx: MeasureContext, brandings: BrandingMap process.exit(1) } + if (dbUrl.startsWith('mongodb://')) { + if (process.env.PROCEED_V7_MONGO !== 'true') { + console.error(` + ⚠️ IMPORTANT: MongoDB Deprecation Notice + + MongoDB support is deprecated in v7 and will be removed in future versions. Important details: + + 1. New features may not be available with MongoDB + 2. Testing coverage for MongoDB will be limited + 3. Upgrading to v7 with MongoDB will PERMANENTLY LOCK your deployment to MongoDB-specific types + 4. Migration to CockroachDB will NOT be possible after upgrading + + ➡️ Recommended Action: + Migrate to CockroachDB before upgrading to v7. See migration instructions at: + https://github.com/hcengineering/huly-selfhost + + To proceed with MongoDB (despite these limitations): + Set environment variable PROCEED_V7_MONGO=true. + `) + process.exit(1) + } + } + const oldAccsUrl = process.env.OLD_ACCOUNTS_URL ?? (dbUrl.startsWith('mongodb://') ? dbUrl : undefined) const oldAccsNs = process.env.OLD_ACCOUNTS_NS diff --git a/server/account-service/src/migration/types.ts b/server/account-service/src/migration/types.ts index c1e99792de..1a989187ae 100644 --- a/server/account-service/src/migration/types.ts +++ b/server/account-service/src/migration/types.ts @@ -74,7 +74,6 @@ export interface Workspace { endpoint: string region?: string // Transactor group name - targetRegion?: string // Transactor region to move to backupInfo?: BackupStatus diff --git a/server/account/src/collections/postgres/migrations.ts b/server/account/src/collections/postgres/migrations.ts index 9364a4288d..8f55909028 100644 --- a/server/account/src/collections/postgres/migrations.ts +++ b/server/account/src/collections/postgres/migrations.ts @@ -32,7 +32,8 @@ export function getMigrations (ns: string): [string, string][] { getV11Migration(ns), getV12Migration(ns), getV13Migration(ns), - getV14Migration(ns) + getV14Migration(ns), + getV15Migration(ns) ] } @@ -425,3 +426,13 @@ function getV14Migration (ns: string): [string, string] { ` ] } + +function getV15Migration (ns: string): [string, string] { + return [ + 'account_db_v15_add_target_region_to_workspace_status', + ` + ALTER TABLE ${ns}.workspace_status + ADD COLUMN IF NOT EXISTS target_region STRING; + ` + ] +} diff --git a/tests/docker-compose.override.yaml b/tests/docker-compose.override.yaml index c16574744b..ea00a636cb 100644 --- a/tests/docker-compose.override.yaml +++ b/tests/docker-compose.override.yaml @@ -2,6 +2,7 @@ services: account: environment: - DB_URL=${DB_PG_URL} + - PROCEED_V7_MONGO=false transactor: environment: - DB_URL=${DB_PG_URL} diff --git a/tests/docker-compose.yaml b/tests/docker-compose.yaml index 71a7a1de76..4579425a84 100644 --- a/tests/docker-compose.yaml +++ b/tests/docker-compose.yaml @@ -125,6 +125,7 @@ services: - ADMIN_EMAILS=admin,${PLATFORM_ADMIN_EMAILS} - WORKSPACE_LIMIT_PER_USER=100 - DB_URL=${MONGO_URL} + - PROCEED_V7_MONGO=true - REGION_INFO=|America - TRANSACTOR_URL=ws://transactor:3334;ws://localhost:3334 - STORAGE_CONFIG=${STORAGE_CONFIG} diff --git a/ws-tests/docker-compose.yaml b/ws-tests/docker-compose.yaml index ac4098aeff..168258cfe0 100644 --- a/ws-tests/docker-compose.yaml +++ b/ws-tests/docker-compose.yaml @@ -137,7 +137,7 @@ services: - ADMIN_EMAILS=admin,${PLATFORM_ADMIN_EMAILS} - STATS_URL=http://huly.local:4901 - WORKSPACE_LIMIT_PER_USER=100 - - DB_URL=${MONGO_URL} + - DB_URL=${DB_EU_URL} # - REGION_INFO=|America;europe| # Europe without name will not be available for creation of new workspaces. - REGION_INFO=|America;europe|Europe - TRANSACTOR_URL=ws://huly.local:3334;ws://huly.local:3334,ws://huly.local:3335;ws://huly.local:3335;europe diff --git a/ws-tests/tool-europe.sh b/ws-tests/tool-europe.sh index 4fb6c4b3d8..d618fd87ef 100755 --- a/ws-tests/tool-europe.sh +++ b/ws-tests/tool-europe.sh @@ -6,8 +6,7 @@ export MINIO_SECRET_KEY=minioadmin export MINIO_ENDPOINT=huly.local:9002 export ACCOUNTS_URL=http://huly.local:3003 export TRANSACTOR_URL=ws://huly.local:3334 -# export ACCOUNT_DB_URL=postgresql://root@huly.local:26258/defaultdb?sslmode=disable -export ACCOUNT_DB_URL=mongodb://huly.local:27018 +export ACCOUNT_DB_URL=postgresql://root@huly.local:26258/defaultdb?sslmode=disable export MONGO_URL=mongodb://huly.local:27018 export ELASTIC_URL=http://huly.local:9201 export SERVER_SECRET=secret diff --git a/ws-tests/tool-local.sh b/ws-tests/tool-local.sh index a12abf336d..764535b352 100755 --- a/ws-tests/tool-local.sh +++ b/ws-tests/tool-local.sh @@ -4,7 +4,7 @@ export MINIO_SECRET_KEY=minioadmin export MINIO_ENDPOINT=huly.local:9000 export MONGO_URL=mongodb://huly.local:27017 export DB_URL=mongodb://huly.local:27017 -export ACCOUNT_DB_URL=mongodb://huly.local:27017 +export ACCOUNT_DB_URL=postgresql://root@huly.local:26257/defaultdb?sslmode=disable export ACCOUNTS_URL=http://huly.local:3000 export TRANSACTOR_URL=ws://huly.local:3333 export ELASTIC_URL=http://huly.local:9200 diff --git a/ws-tests/tool.sh b/ws-tests/tool.sh index e9f208df09..6ecafdc4b8 100755 --- a/ws-tests/tool.sh +++ b/ws-tests/tool.sh @@ -6,8 +6,7 @@ export MINIO_SECRET_KEY=minioadmin export MINIO_ENDPOINT=huly.local:9002 export ACCOUNTS_URL=http://huly.local:3003 export TRANSACTOR_URL=ws://huly.local:3334 -# export ACCOUNT_DB_URL=postgresql://root@huly.local:26258/defaultdb?sslmode=disable -export ACCOUNT_DB_URL=mongodb://huly.local:27018 +export ACCOUNT_DB_URL=postgresql://root@huly.local:26258/defaultdb?sslmode=disable export MONGO_URL=mongodb://huly.local:27018 export ELASTIC_URL=http://huly.local:9201 export SERVER_SECRET=secret