-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Description
Using fields in the wait attribute, it does not appear that one can compare two fields of the current Kubernetes object. I reviewed the code as well and this appears to be expected.
For example, if I want to wait until the observedGeneration matches generation, I am unable to do so. Example:
wait {
fields = {
# The Provider considers this to be a regular string comparison.
"status.observedGeneration" = "metadata.generation"
}
}As a workaround, I can use a kubernetes_resources Data Provider to get the current generation at the time of planning, add 1, and set that as the desired observedGeneration in wait. However, even if there are no changes to the manifest, the wait field is still shown as changing. Subsequently applying the resource then causes TF to hang as it waits for the observedGeneration to be bumped.
Example code for workaround:
data "kubernetes_resources" "test_current" {
api_version = "test/v1"
kind = "TestResource"
field_selector = "metadata.name=sample-resource,metadata.namespace=default"
}
resource "kubernetes_manifest" "test" {
manifest = local.test_data
wait {
fields = {
"status.observedGeneration" = length(data.kubernetes_resources.test_current.objects) > 0 ? data.kubernetes_resources.test_current.objects[0].status.observedGeneration + 1 : 1
}
}
}Has this been considered before, or is it technically possible today some other way?
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment