-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat!: add support for pod_cidr_overprovision_config #2452
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
base: main
Are you sure you want to change the base?
feat!: add support for pod_cidr_overprovision_config #2452
Conversation
94683b9
to
3aaeedc
Compare
/gcbrun |
From the TEST CI:
|
moving to draft, will test locally |
apeabody should be good and added a keeper for node level as the arg is ForceNew in the provider (ill see if i can open an upstream PR to make it updateable) |
/gcbrun |
1 similar comment
/gcbrun |
Signed-off-by: drfaust92 <[email protected]>
Signed-off-by: drfaust92 <[email protected]>
Signed-off-by: drfaust92 <[email protected]>
Signed-off-by: drfaust92 <[email protected]>
9ab7925
to
1460744
Compare
/gcbrun |
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds support for pod_cidr_overprovision_config
at both the cluster and node pool levels across various GKE modules. While the feature addition is valuable, the implementation has a critical flaw in all modules where the cluster-level configuration is applied. The for_each
argument in a dynamic block is being used with an object, which is invalid and will cause Terraform to fail. I've suggested replacing the dynamic block with a static one. Additionally, there's a recurring medium-severity issue in how the node-pool level configuration is conditionally applied, making the code fragile. I've provided suggestions to make this more robust. These issues are present in multiple files due to the templated nature of the repository.
dynamic "pod_cidr_overprovision_config" { | ||
for_each = var.pod_cidr_overprovision_config | ||
content { | ||
disabled = var.pod_cidr_overprovision_config.disabled | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The for_each
in this dynamic block is set to var.pod_cidr_overprovision_config
, which is an object. The for_each
meta-argument only accepts a map or a set of strings, so this will cause a Terraform error. Since var.pod_cidr_overprovision_config
has a default value, this block is always intended to be present. It should be defined as a static block instead of a dynamic one.
pod_cidr_overprovision_config {
disabled = var.pod_cidr_overprovision_config.disabled
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DrFaust92 - We should keep as a dynamic block as it could be set to null
, however probably need to pass as a map
.
dynamic "pod_cidr_overprovision_config" { | ||
for_each = var.pod_cidr_overprovision_config | ||
content { | ||
disabled = var.pod_cidr_overprovision_config.disabled | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The for_each
in this dynamic block is set to var.pod_cidr_overprovision_config
, which is an object. The for_each
meta-argument only accepts a map or a set of strings, so this will cause a Terraform error. Since var.pod_cidr_overprovision_config
has a default value, this block is always intended to be present. It should be defined as a static block instead of a dynamic one.
pod_cidr_overprovision_config {
disabled = var.pod_cidr_overprovision_config.disabled
}
dynamic "pod_cidr_overprovision_config" { | ||
for_each = var.pod_cidr_overprovision_config | ||
content { | ||
disabled = var.pod_cidr_overprovision_config.disabled | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The for_each
in this dynamic block is set to var.pod_cidr_overprovision_config
, which is an object. The for_each
meta-argument only accepts a map or a set of strings, so this will cause a Terraform error. Since var.pod_cidr_overprovision_config
has a default value, this block is always intended to be present. It should be defined as a static block instead of a dynamic one.
pod_cidr_overprovision_config {
disabled = var.pod_cidr_overprovision_config.disabled
}
dynamic "pod_cidr_overprovision_config" { | ||
for_each = var.pod_cidr_overprovision_config | ||
content { | ||
disabled = var.pod_cidr_overprovision_config.disabled | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The for_each
in this dynamic block is set to var.pod_cidr_overprovision_config
, which is an object. The for_each
meta-argument only accepts a map or a set of strings, so this will cause a Terraform error. Since var.pod_cidr_overprovision_config
has a default value, this block is always intended to be present. It should be defined as a static block instead of a dynamic one.
pod_cidr_overprovision_config {
disabled = var.pod_cidr_overprovision_config.disabled
}
dynamic "pod_cidr_overprovision_config" { | ||
for_each = var.pod_cidr_overprovision_config | ||
content { | ||
disabled = var.pod_cidr_overprovision_config.disabled | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The for_each
in this dynamic block is set to var.pod_cidr_overprovision_config
, which is an object. The for_each
meta-argument only accepts a map or a set of strings, so this will cause a Terraform error. Since var.pod_cidr_overprovision_config
has a default value, this block is always intended to be present. It should be defined as a static block instead of a dynamic one.
pod_cidr_overprovision_config {
disabled = var.pod_cidr_overprovision_config.disabled
}
enable_private_nodes = lookup(network_config.value, "enable_private_nodes", var.enable_private_nodes) | ||
|
||
dynamic "pod_cidr_overprovision_config" { | ||
for_each = lookup(network_config.value, "pod_cidr_overprovision_config", "") != "" ? [1] : [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition lookup(..., "") != ""
is fragile for checking if an optional attribute is set. It's more robust to check against null
. This ensures that the logic is not dependent on how different types are converted to strings.
for_each = lookup(network_config.value, "pod_cidr_overprovision_config", null) != null ? [1] : []
enable_private_nodes = lookup(network_config.value, "enable_private_nodes", var.enable_private_nodes) | ||
|
||
dynamic "pod_cidr_overprovision_config" { | ||
for_each = lookup(network_config.value, "pod_cidr_overprovision_config", "") != "" ? [1] : [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition lookup(..., "") != ""
is fragile for checking if an optional attribute is set. It's more robust to check against null
. This ensures that the logic is not dependent on how different types are converted to strings.
for_each = lookup(network_config.value, "pod_cidr_overprovision_config", null) != null ? [1] : []
{% endif %} | ||
|
||
dynamic "pod_cidr_overprovision_config" { | ||
for_each = lookup(network_config.value, "pod_cidr_overprovision_config", "") != "" ? [1] : [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition lookup(..., "") != ""
is fragile for checking if an optional attribute is set. It's more robust to check against null
. This ensures that the logic is not dependent on how different types are converted to strings.
for_each = lookup(network_config.value, "pod_cidr_overprovision_config", null) != null ? [1] : []
enable_private_nodes = lookup(network_config.value, "enable_private_nodes", var.enable_private_nodes) | ||
|
||
dynamic "pod_cidr_overprovision_config" { | ||
for_each = lookup(network_config.value, "pod_cidr_overprovision_config", "") != "" ? [1] : [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition lookup(..., "") != ""
is fragile for checking if an optional attribute is set. It's more robust to check against null
. This ensures that the logic is not dependent on how different types are converted to strings.
for_each = lookup(network_config.value, "pod_cidr_overprovision_config", null) != null ? [1] : []
enable_private_nodes = lookup(network_config.value, "enable_private_nodes", var.enable_private_nodes) | ||
|
||
dynamic "pod_cidr_overprovision_config" { | ||
for_each = lookup(network_config.value, "pod_cidr_overprovision_config", "") != "" ? [1] : [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition lookup(..., "") != ""
is fragile for checking if an optional attribute is set. It's more robust to check against null
. This ensures that the logic is not dependent on how different types are converted to strings.
for_each = lookup(network_config.value, "pod_cidr_overprovision_config", null) != null ? [1] : []
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution @DrFaust92!
Two notes, and please add to an example (e.g. node_pool) for test coverage.
No description provided.