Skip to content

patch: update mongos TF#242

Open
patriciareinoso wants to merge 7 commits into
8/edgefrom
DPE-10295
Open

patch: update mongos TF#242
patriciareinoso wants to merge 7 commits into
8/edgefrom
DPE-10295

Conversation

@patriciareinoso

@patriciareinoso patriciareinoso commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description

This PR update the terraform modules.
mongos is a charm module. Variables, outputs and file name were changed according to CC008 and DA219

  • Extract the terraform linting into a tox env
  • Update the juju provider to ~> 2.0
  • We no longer use the model name, we use the model UUID
  • Update outdated fields for the mongos module
  • New format for the outputs

Example

Modules are still under development so for now no version release

@patriciareinoso patriciareinoso added the enhancement New feature, UI change, or workload upgrade label Jun 25, 2026
Comment thread terraform/variables.tf

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is missing the constraints for the architecture ?
Something like:

variable "constraints" {
  description = "String listing constraints for this application"
  type        = string
  default     = "arch=amd64"
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cannot set constraints to a subordinate charm. I had to remove it from a previous commit

│ Error: Client Error
│ 
│   with module.mongos.juju_application.mongos,
│   on ../main.tf line 4, in resource "juju_application" "mongos":
│    4: resource "juju_application" "mongos" {
│ 
│ Unable to create application, got error: subordinate application must be
│ deployed without constraints
╵

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but we can define it in the variables for unifying the UX, and we just don't use it in the main.tf

@patriciareinoso patriciareinoso requested a review from Gu1nness June 25, 2026 12:45

@Mehdi-Bendriss Mehdi-Bendriss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Patricia, looks good, I have a few small comments

Comment thread terraform/main.tf
Comment on lines -30 to -38
lifecycle {
precondition {
condition = length(var.machines) == 0 || length(var.machines) == var.units
error_message = "Machine count does not match unit count"
}
precondition {
condition = length(var.storage) == 0 || lookup(var.storage, "count", 0) <= 1
error_message = "Only one storage is supported"
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 points here:

  1. why was this validation removed?
  2. seems like we're missing storage_directives and placement ?

@patriciareinoso patriciareinoso Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this section defines the mandatory input variables. Neither machines, storage_directives are mandatory

  • I meant to remove the machines variable since it is subordinate charm and to me it does not make sense to define the machine
  • Mongos does not define storage
  • I think placement is a legacy parameter. I do not see it in the app definition

Comment thread terraform/outputs.tf
description = "Object representing the deployed mongos application."
value = juju_application.mongos
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like we're missing offers and provides outputs, should they be omitted or declared but set to None or empty object?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those are optional parameters, I decided to omit them

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is on consistency, as the outputs are mostly gonna be used by other terraform modules or teams that may not have the mongodb knowledge about why we're omitting.
Also, consistency with the k8s charm (which will have a provides: mongos_proxy), and since it is a standalone charm, nothing stops users from deploying it in a separate model.

Comment thread terraform/variables.tf

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but we can define it in the variables for unifying the UX, and we just don't use it in the main.tf

Comment thread terraform/variables.tf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature, UI change, or workload upgrade

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants