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

v1: fixing timeouts #747

Closed

Conversation

tombuildsstuff
Copy link
Member

Discovered when upgrading hashicorp/terraform-provider-azurerm#11431

The latest changes to one of the dependencies, presumably terraform-exec, return the Duration as a json.Number rather than the expected time.Duration, int64 or float64, hence this fails silently with the log message:

2021/04/22 11:01:20 [WARN] Unknown type in DefaultTimeout: "5400000000000"
2021/04/22 11:01:20 [WARN] Unknown type in DefaultTimeout: "300000000000"
2021/04/22 11:01:20 [WARN] Unknown type in DefaultTimeout: "5400000000000"
2021/04/22 11:01:20 [WARN] Unknown type in DefaultTimeout: "5400000000000

When expanding that log message to include the type (without the new switch item) - this becomes:

[WARN] Unknown type json.Number in DefaultTimeout: “5400000000000”

Arguably this warning should be a Panic and not a Warning, but that's probably outside the scope of this fix. It also appears that this affects v2 as well as v1 - so this may need to be applied to v2 as well?

// could be time.Duration, int64 or float64
func DefaultTimeout(tx interface{}) *time.Duration {
var td time.Duration
switch raw := tx.(type) {
case time.Duration:
return &raw
case int64:
td = time.Duration(raw)
case float64:
td = time.Duration(int64(raw))
default:
log.Printf("[WARN] Unknown type in DefaultTimeout: %#v", tx)
}
return &td
}

```
2021/04/22 11:01:20 [WARN] Unknown type in DefaultTimeout: "5400000000000"
2021/04/22 11:01:20 [WARN] Unknown type in DefaultTimeout: "300000000000"
2021/04/22 11:01:20 [WARN] Unknown type in DefaultTimeout: "5400000000000"
2021/04/22 11:01:20 [WARN] Unknown type in DefaultTimeout: "5400000000000
```

Which when expanding with this fix (without the new 'type' addition):

```
[WARN] Unknown type json.Number in DefaultTimeout: “5400000000000”
```

Arguably this warning should be a Panic and not a Warning, but that's probably
outside the scope of this fix. It also appears that this affects v2 as well as
v1 - so this may need to be applied to v2 as well?
@tombuildsstuff
Copy link
Member Author

Closing in favour of #748

@ghost
Copy link

ghost commented May 23, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators May 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant