Skip to content

Fix inventory service DATABASE_HOST env var in docker-compose.prod.yml#3

Closed
Copilot wants to merge 2 commits into
developfrom
copilot/fix-saga-transaction-issue
Closed

Fix inventory service DATABASE_HOST env var in docker-compose.prod.yml#3
Copilot wants to merge 2 commits into
developfrom
copilot/fix-saga-transaction-issue

Conversation

Copilot AI commented Nov 26, 2025

Copy link
Copy Markdown

Saga transaction endpoint /saga/transaction fails in production but works in development. The inventory service cannot connect to PostgreSQL in production due to misconfigured environment variables.

Root Cause

docker-compose.prod.yml passes POSTGRES_HOST to the inventory service, but inventory/config/settings.py reads from DATABASE_HOST:

# inventory/config/settings.py:65
"HOST": os.getenv("DATABASE_HOST", "postgres"),

Changes

  • Updated docker-compose.prod.yml inventory service environment:
    • POSTGRES_HOSTDATABASE_HOST
    • POSTGRES_PORTDATABASE_PORT

This aligns production with development (docker-compose.yml) which correctly uses DATABASE_HOST.

Original prompt

Cuando ejecuto el endpoint saga/transaction con el docker compose de desarrollo funciona perfectamente sin modificar nada del codigo pero con el docker compose de prod no funciona

[Chronological Review: The conversation began with the user asking about the data sent by each endpoint of the microservices. The user then inquired about where to change the success or failure probability in transactions. Following that, the user requested to test the saga transaction to see if it succeeds. The user also asked to try using the production Docker Compose. The conversation continued with the user expressing issues with the production Docker Compose not executing the saga transaction successfully, while it worked fine with the development Docker Compose without code modifications. The user reiterated the problem with the production setup not functioning as expected.]

[Intent Mapping:

  1. "que datos envia cada endpoint de cada microserviicio??" - User wants to understand the data flow in microservices.
  2. "en que partes del codigo puedo cambiar la probabilidad de exito o fallo en las transacciones" - User seeks to modify transaction success/failure probabilities.
  3. "prueba la transaccion saga para ver si tiene exito" - User requests testing of the saga transaction.
  4. "podrias probar usando el docker compose de prod" - User asks to test with the production Docker Compose.
  5. "con el docker compose normal yo podia ejecutar /saga/transaction sin problema y sin modificar el codigo la transaccion era exitosa. porque con el de produccion no pasa lo mismo?" - User is confused about the different behaviors of the Docker Compose setups.
  6. "Cuando ejecuto el endpoint saga/transaction con el docker compose de desarrollo funciona perfectamente sin modificar nada del codigo pero con el docker compose de prod no funciona" - User reiterates the issue with the production setup.]

[Technical Inventory:

  • Microservices architecture is being used.
  • Docker and Docker Compose are employed for containerization and orchestration.
  • The user is working with a saga pattern for transaction management.]

[Code Archaeology:

  • The user has been working with various Dockerfiles in the ecommerce-microservices repository, particularly in the catalog and purchases directories.
  • The user has also mentioned changes to the entrypoint.sh file and settings.py in the orchestrator app.]

[Progress Assessment:

  • The user has successfully executed the saga transaction in the development environment.
  • The user is currently facing issues with the production environment setup.]

[Context Validation: All critical information regarding the user's inquiries about microservices, transaction management, and Docker Compose setups is captured.]

[Recent Commands Analysis:

  • Last Agent Commands: The user requested to test the saga transaction and to use the production Docker Compose.
  • Tool Results Summary: The user reported that the saga transaction works in the development environment but fails in the production environment without code modifications.
  • Pre-Summary State: The agent was actively discussing the differences in behavior between the development and production Docker Compose setups when the token budget was exceeded.
  • Operation Context: The user is trying to understand why the production setup is not functioning as expected compared to the development setup.]
1. Conversation Overview: - Primary Objectives: - "que datos envia cada endpoint de cada microserviicio??" - Understanding endpoint data. - "en que partes del codigo puedo cambiar la probabilidad de exito o fallo en las transacciones" - Modifying transaction probabilities. - "prueba la transaccion saga para ver si tiene exito" - Testing saga transaction. - "podrias probar usando el docker compose de prod" - Testing with production Docker Compose. - "con el docker compose normal yo podia ejecutar /saga/transaction sin problema y sin modificar el codigo la transaccion era exitosa. porque con el de produccion no pasa lo mismo?" - Investigating production issues. - "Cuando ejecuto el endpoint saga/transaction con el docker compose de desarrollo funciona perfectamente sin modificar nada del codigo pero con el docker compose de prod no funciona" - Reiterating production issues.
  • Session Context: The conversation has revolved around understanding microservices, transaction management, and the differences between development and production environments.

  • User Intent Evolution: The user initially sought information about endpoints and transaction management but shifted focus to troubleshooting issues with the production environment.

  1. Technical Foundation:
  • Microservices Architecture: Used for the ecommerce application.
  • Docker: Employed for containerization.
  • Docker Compose: Used for orchestrating multi-container applications.
  1. Codebase Status:
  • File Name 1: Dockerfile (various locations)
    • Purpose: Container configuration for micro...

Created from VS Code via the GitHub Pull Request extension.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…od.yml

Co-authored-by: valerubio7 <129685751+valerubio7@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix saga transaction issues with production docker compose Fix inventory service DATABASE_HOST env var in docker-compose.prod.yml Nov 26, 2025
Copilot AI requested a review from valerubio7 November 26, 2025 20:42
@valerubio7

Copy link
Copy Markdown
Collaborator

@copilot podes probar ahora el endpoint de transaction

Copilot AI commented Nov 26, 2025

Copy link
Copy Markdown
Author

@copilot podes probar ahora el endpoint de transaction

No puedo ejecutar Docker en este entorno sandbox debido a restricciones de red (no se pueden descargar paquetes de Alpine). Sin embargo, el fix está correcto: cambié POSTGRES_HOSTDATABASE_HOST y POSTGRES_PORTDATABASE_PORT en el servicio inventory de docker-compose.prod.yml, alineándolo con lo que espera inventory/config/settings.py. Podés probarlo en tu entorno local ejecutando docker compose -f docker-compose.prod.yml up y luego curl -X POST http://localhost:8000/saga/transaction -H "Content-Type: application/json" -d '{"user_id": "test-user", "amount": 100}'.

@valerubio7 valerubio7 removed their request for review November 26, 2025 20:50
@valerubio7 valerubio7 closed this Nov 26, 2025
@valerubio7 valerubio7 deleted the copilot/fix-saga-transaction-issue branch November 26, 2025 20:51
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

Successfully merging this pull request may close these issues.

2 participants