Skip to content

fix: stop emitting the Grafana module twice in the cloud_run template#62

Open
lokeshmuvva wants to merge 1 commit into
devfrom
fix/grafana-duplicate-module-cloud-run
Open

fix: stop emitting the Grafana module twice in the cloud_run template#62
lokeshmuvva wants to merge 1 commit into
devfrom
fix/grafana-duplicate-module-cloud-run

Conversation

@lokeshmuvva
Copy link
Copy Markdown

What

main.tf.j2 (the Cloud Run template used when a stack has neither MLflow nor W&B) emitted the Grafana module twice — once from the generic per-tool loop and once from the dedicated Grafana block. The generic loop also passed arguments the Grafana Cloud Run module doesn't declare.

This excludes grafana from the generic loop so only the dedicated block emits it.

Why

Two Terraform errors made Grafana undeployable via this template:

  1. Duplicate module "model_monitoring_grafana" (duplicate module name).
  2. Unsupported arguments (cpu_request, max_scale, use_postgres, …) passed to a module that doesn't declare them.

mlflow_main.tf.j2 already avoids this by using dedicated per-tool blocks; this aligns main.tf.j2 with that approach (exclude grafana from the catch-all, let the specialized block own it).

Verification

Rendered main.tf.j2 for grafana-containing stacks:

  • grafana-only → 1 Grafana module (was 2), no stray args
  • grafana + params → 1 module, no x = var.x junk (previously emitted, e.g. grafana_port = var.grafana_port)
  • fastapi + grafana → fastapi still emits via the generic loop, grafana once (regression check: only grafana is excluded)

Notes

Found while working on #61 (Grafana credentials) and deliberately scoped out of that PR to keep it focused. Independent change; touches different lines of the same file, so the two PRs do not conflict.

Test plan

  • Render main.tf.j2 across grafana / non-grafana stacks (counts above)
  • (maintainer) deploy a grafana cloud_run stack and confirm terraform apply succeeds

main.tf.j2's generic per-tool loop emitted a module for every tool
including grafana, while a dedicated block emitted grafana again. That
produced a duplicate module "model_monitoring_grafana", and the generic
loop also passed arguments the Grafana Cloud Run module does not declare
(cpu_request, max_scale, use_postgres, ...). A grafana stack with no
MLflow/W&B (which renders this template) therefore could not deploy.

Exclude grafana from the generic loop so only the dedicated block emits
it, matching how mlflow_main.tf.j2 uses dedicated per-tool blocks.
Verified by rendering: grafana-containing stacks now emit a single
Grafana module with no stray arguments, and non-grafana tools are
unaffected.
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.

1 participant