Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Add configurable timeout to wait_for #238

Closed
wants to merge 3 commits into from
Closed

Conversation

jrhouston
Copy link
Contributor

Description

Adds a configurable timeout to the wait_for block.

Release Note

Release note for CHANGELOG:

Add configurable timeout to wait_for block

References

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

@jrhouston jrhouston requested a review from a team June 16, 2021 20:52
@@ -31,6 +31,7 @@ func GetResourceType(name string) (tftypes.Type, error) {
func GetProviderResourceSchema() map[string]*tfprotov5.Schema {
waitForType := tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"timeout": tftypes.String,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to make this optional, but we're currently blocked because of this: hashicorp/terraform-plugin-go#83 (comment)

&tfprotov5.Diagnostic{
Severity: tfprotov5.DiagnosticSeverityError,
Detail: err.Error(),
Summary: fmt.Sprintf(`wait_for: timed out waiting on resource %q`, rnn),
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if there's some validation that can happen sooner, to prevent this error:

╷
│ Error: wait_for: timed out waiting on resource "default/tf-k8s-test-consul-server"

│ invalid field path "metadata.0.annotations.0.test": :1,10-11: Attribute name required; Dot must be followed by attribute
│ name.
╵

I used this as my config and it exited immediately:

  wait_for  = {
    timeout = "30s"
    fields  = {
      "metadata.0.annotations.0.test" = "true"
    }
  }

Also, is it possible for me to use an annotation to test this feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, it looks like you need to use [] for indexes. We've documented it in the format you're using though so something must have changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But yes – I'll add something to the ValidateResourceTypeConfig func to check for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have added validation so you get an error like this at plan:

╷
│ Error: Invalid "wait_for" configuration
│
│   with kubernetes_manifest.test,
│   on main.tf line 44, in resource "kubernetes_manifest" "test":
│   44:   wait_for = {
│   45:       fields = {
│   46:           "()*^B)*B^()^B)&*#^&$^#*&$TN&*#" = "lol"
│   47:       }
│   48:   }
│
│ invalid field path "()*^B)*B^()^B)&*#^&$^#*&$TN&*#": :1,4-5: Unsupported operator; Bitwise operators are not supported., and
│ 4 other diagnostic(s)
╵

@jrhouston
Copy link
Contributor Author

@jrhouston jrhouston closed this Aug 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants