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

nodepool.tf|precondition bug|single availability domain must be specified when using a capacity reservation #882

Open
shb-mll opened this issue Dec 17, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@shb-mll
Copy link

shb-mll commented Dec 17, 2023

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version and Provider Version

$ terraform --version
Terraform v1.3.9
on darwin_arm64

  • provider registry.terraform.io/hashicorp/cloudinit v2.3.3
  • provider registry.terraform.io/oracle/oci v5.23.0

Affected Resource(s)

oci_containerengine_node_pool

Terraform Configuration Files

https://github.com/oracle-terraform-modules/terraform-oci-oke/blob/v5.1.0/modules/workers/nodepools.tf#L146

    precondition {
      condition     = coalesce(each.value.capacity_reservation_id, "none") == "none" || length(each.value.availability_domains) == 1
      error_message = "A single availability domain must be specified when using a capacity reservation with mode=${each.value.mode}"
    }

Debug Output

╷
│ Error: Resource precondition failed
│
│   on nodepools.tf line 146, in resource "oci_containerengine_node_pool" "workers":
│  146:       condition     = coalesce(each.value.capacity_reservation_id, "none") == null || length(each.value.availability_domains) == 1
│     ├────────────────
│     │ each.value.availability_domains is list of string with 3 elements
│     │ each.value.capacity_reservation_id is "null"
│
│ A single availability domain must be specified when using a capacity
│ reservation with mode=node-pool
╵
╷
│ Error: Resource precondition failed
│
│   on nodepools.tf line 146, in resource "oci_containerengine_node_pool" "workers":
│  146:       condition     = coalesce(each.value.capacity_reservation_id, "none") == null || length(each.value.availability_domains) == 1
│     ├────────────────
│     │ each.value.availability_domains is list of string with 3 elements
│     │ each.value.capacity_reservation_id is "null"
│
│ A single availability domain must be specified when using a capacity
│ reservation with mode=node-pool
╵

Panic Output

Expected Behavior

the precondition should only check when a capacity reservation is specified. However its check for all cases.
The condition should be changed to below

      condition     = each.value.capacity_reservation_id != "null" ? length(each.value.availability_domains) == 1 : true

Actual Behavior

Its checking irrespective of capacity reservation id specification. In my case the capacity reservation id is default value null.

Steps to Reproduce

  1. my region is us-ashburn-1 which has 3 availability domains.
  2. don't specify a capacity reservation id and run terraform apply

Important Factoids

References

@shb-mll shb-mll added the bug Something isn't working label Dec 17, 2023
@shb-mll shb-mll changed the title nodepool.tf nodepool.tf : precondition bug single availability domain must be specified when using a capacity reservation Dec 17, 2023
@shb-mll shb-mll changed the title nodepool.tf : precondition bug single availability domain must be specified when using a capacity reservation nodepool.tf|precondition bug|single availability domain must be specified when using a capacity reservation Dec 17, 2023
@syedthameem85
Copy link
Member

syedthameem85 commented Jan 23, 2024

@shb-mll / @hyder / @devoncrouse - The current code for oci_containerengine_node_pool works fine for single availability domain regions. Capacity reservation is an availability domain specific resource which means for node placement in capacity reservation across three availability domains (in regions like us-ashburn-1), the worker_capacity_reservation_id input should have provision to accept 3 such capacity reservation ids with mapping to right availability domain.
In current version of module, worker_capacity_reservation_id has been declared as string.
https://github.com/oracle-terraform-modules/terraform-oci-oke/blob/v5.1.0/variables-workers.tf

variable "worker_capacity_reservation_id" {
default = null
description = "The ID of the Compute capacity reservation the worker node will be launched under. See Capacity Reservations for more information."
type = string
}

So it doesn’t support capacity reservation ids for multiple availability domain regions. Till we have this feature rolled out, it’s better to change the precondition error message stating that the capacity reservation cannot be used for regions with multiple availability domains.

https://github.com/oracle-terraform-modules/terraform-oci-oke/blob/v5.1.0/modules/workers/nodepools.tf#L146

precondition {
  condition     = coalesce(each.value.capacity_reservation_id, "none") == "none" || length(each.value.availability_domains) == 1
  error_message = "A single availability domain must be specified when using a capacity reservation with mode=${each.value.mode}"
}

The implementation requires correctly mapped key value input (availability_domain:capacity_reservation_id) for worker_capacity_reservation_id that can be consumed in oci_containerengine_node_pool to place nodes in respective capacity reservations

@shb-mll / @hyder / @devoncrouse - Any feedback ?

@hyder
Copy link
Contributor

hyder commented Feb 6, 2024

Or we can pick an AD by default and allow the user to change?

@syedthameem85
Copy link
Member

@hyder Can you please explain in detail what do you mean by picking up an AD? The ADs are automatically gathered and cannot be input by user. Not sure how the user would map AD and capacity reservation as an input.

@hyder
Copy link
Contributor

hyder commented Feb 6, 2024

I was wondering if we can pick the 1st AD by default but allow the user to change the default. @devoncrouse what you think?

@syedthameem85
Copy link
Member

@hyder - I think for multi ad region, we can map the capacity_reservation_id to first AD by default, provided the user always provide the capacity_reservation_id from first AD (which can be documented)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants