Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

juju_machine should allow both placement and constraints #476

Closed
arif-ali opened this issue May 2, 2024 · 7 comments · Fixed by #499
Closed

juju_machine should allow both placement and constraints #476

arif-ali opened this issue May 2, 2024 · 7 comments · Fixed by #499
Assignees
Labels
hint/main going on main branch kind/bug indicates a bug in the project
Milestone

Comments

@arif-ali
Copy link

arif-ali commented May 2, 2024

Description

Following the PR #378 of the placement addition in 0.11.0, and came to test this today, but have come to another issue. We should be able to appliy a constraint and a placement, but the provider does not allow us to do this

Urgency

Blocker for our release

Terraform Juju Provider version

0.12.0

Terraform version

1.8.2

Terraform Configuration(s)

resource "juju_machine" "ceph-mon-1" {
  model = juju_model.cpe-focal.name
  placement = join(":",["lxd",juju_machine.all_machines["101"].machine_id])
  constraints = "spaces=oam,ceph-access,ceph-replica"
}

Reproduce / Test

❱❱❱ juju add-machine lxd:34 --constraints="spaces=oam,ceph-access,ceph-replica"
created container 34/lxd/8

The above extract from terraform gives me the following error


╷
│ Error: Invalid Attribute Combination
│ 
│   with juju_machine.ceph-mon-1,
│   on 05-ceph.tf line 35, in resource "juju_machine" "ceph-mon-1":
│   35:   placement = join(":",["lxd",juju_machine.all_machines["101"].machine_id])
│ 
│ Attribute "constraints" cannot be specified when "placement" is specified


### Debug/Panic Output

```shell
n/a

Notes & References

n/a

@arif-ali arif-ali added the kind/bug indicates a bug in the project label May 2, 2024
@hmlanigan
Copy link
Member

@arif-ali

In your example juju will attempt to use those spaces for the container if they are available on the host machine, however will continue if not and use the spaces available to the host machine as a fallback. For spaces, juju does not treat space constraints exactly the same as when creating a machine.

The example below is a bit more straight forward:

resource "juju_machine" "ceph-mon-1" {
  model = juju_model.cpe-focal.name
  placement = join(":",["lxd",juju_machine.all_machines["101"].machine_id])
  constraints = "mem=10G"
}

@hmlanigan hmlanigan added this to the 0.12.1 milestone May 2, 2024
@hmlanigan hmlanigan added the hint/main going on main branch label May 2, 2024
@arif-ali
Copy link
Author

arif-ali commented May 2, 2024

If I don't add any constraints, then the lxd fails to deploy, and get the following from juju status --format json

      "7/lxd/0": {
        "juju-status": {
          "current": "down",
          "message": "agent is not communicating with the server",
          "since": "02 May 2024 20:19:34+01:00"
        },
        "instance-id": "pending",
        "machine-status": {
          "current": "provisioning error",
          "message": "no obvious space for container \"7/lxd/0\", host machine has spaces: \"admin\", \"ceph-access\", \"ceph-replica\", \"external\", \"internal\", \"oam\", \"overlay\"",
          "since": "02 May 2024 20:19:34+01:00"
        },
        "modification-status": {
          "current": "idle",
          "since": "02 May 2024 19:59:35+01:00"
        },
        "series": "focal"
      },

adding the constraint causes the original issue

@arif-ali
Copy link
Author

arif-ali commented May 3, 2024

@arif-ali

In your example juju will attempt to use those spaces for the container if they are available on the host machine, however will continue if not and use the spaces available to the host machine as a fallback. For spaces, juju does not treat space constraints exactly the same as when creating a machine.

The example below is a bit more straight forward:

resource "juju_machine" "ceph-mon-1" {
  model = juju_model.cpe-focal.name
  placement = join(":",["lxd",juju_machine.all_machines["101"].machine_id])
  constraints = "mem=10G"
}

Even with constraints="mem=10G" doesn't work unfortunately

 resource "juju_machine" "ceph-mon-1" {
  model = juju_model.cpe-focal.name
  placement = join(":",["lxd",juju_machine.all_machines["101"].machine_id])
#  constraints = "spaces=oam,ceph-access,ceph-replica"
  constraints = "mem=10G"
}
╷
│ Error: Invalid Attribute Combination
│ 
│   with juju_machine.ceph-mon-1,
│   on 05-ceph.tf line 35, in resource "juju_machine" "ceph-mon-1":
│   35:   placement = join(":",["lxd",juju_machine.all_machines["101"].machine_id])
│ 
│ Attribute "constraints" cannot be specified when "placement" is specified
╵

@hmlanigan hmlanigan self-assigned this May 3, 2024
@arif-ali
Copy link
Author

arif-ali commented May 7, 2024

I removed the line, compiled the provider, and used it locally, and now for me it works as expected. I have managed to deploy lxd/kvm machines successfully and attach them to applications similar to what I was originally expecting

@cderici
Copy link

cderici commented Jun 6, 2024

@arif-ali sounds like the placement conflicts can be relaxed, can you open a PR with your change and qa steps so we can take a closer look at it? Thanks!

@hmlanigan
Copy link
Member

@cderici, @arif-ali - I'm working on this bug already. It's in the milestone for 0.13.0. It also has a jira card.

@cderici
Copy link

cderici commented Jun 6, 2024

@cderici, @arif-ali - I'm working on this bug already. It's in the milestone for 0.13.0. It also has a jira card.

Sorry that's my mistake, I didn't realize @hmlanigan was on this, you may safely ignore my message 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hint/main going on main branch kind/bug indicates a bug in the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants