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

helper/schema: Add configurable Timeouts #12311

Merged
merged 23 commits into from
Mar 2, 2017
Merged

Conversation

catsby
Copy link
Contributor

@catsby catsby commented Feb 28, 2017

This adds to helper/schema the concept of Timeouts, allowing Provider developers to opt-in to offering customizable timeouts for a given Create, Read, Update, Delete action. By exposing timeouts per action, operators can customize the amount of time Terraform is allowed to operate a specific action before timing out.

A concrete example can be found in aws_db_instance.go, a resource that notoriously takes a very long time to provision. In the past there have been frequent requests to increase the amount of time allowed for provisioning, modification, and deletion. Because these actions vary on configuration (instance size, backup creation requirements), some require more time than others. While bumping the timeout is generally fine, it does have drawbacks, mainly being that any change requires a new release of Terraform, and there exists possibilities of unknown issues that would cause an operation to get stuck in a retry loop, thus taking a very long time to surface a currently uncaught error.

With Timeouts, Resource/Provider developers expose configurable options for users like so:

  • The Resource defines Timeouts for Create, Update, and Delete operations, alongside the schema:
Schema: &schema.Schema{
  [...],
},
Timeouts: &schema.ResourceTimeout{
  Create: schema.DefaultTimeout(40 * time.Minute),
  Update: schema.DefaultTimeout(80 * time.Minute),
  Delete: schema.DefaultTimeout(40 * time.Minute),
},
  • The Resource code references these via the new ResourceData method Timeout:
    d.Timeout("create") 
  • Users can overwrite these builtin times in their configuration:
resource "aws_db_instance" "timeout_example" {
  allocated_storage    = 10
  engine               = "mysql"
  engine_version       = "5.6.17"
  instance_class       = "db.t1.micro"
  name                 = "mydb"
  [...]

  timeout {
    create = "60m"
    delete = "2h"
  }
}

This allows Provider/Resource developers the ability to provide good default timeouts for operations, but allows for users with possibly very different workload expectations to customize this time.

@catsby catsby merged commit 2fe5976 into master Mar 2, 2017
@mitchellh mitchellh deleted the f-helperschema-timeout branch March 2, 2017 17:08
yanndegat pushed a commit to yanndegat/terraform that referenced this pull request Mar 13, 2017
* helper/schema: Add custom Timeout block for resources

* refactor DefaultTimeout to suuport multiple types. Load meta in Refresh from Instance State

* update vpc but it probably wont last anyway

* refactor test into table test for more cases

* rename constant keys

* refactor configdecode

* remove VPC demo

* remove comments

* remove more comments

* refactor some

* rename timeKeys to timeoutKeys

* remove note

* documentation/resources: Document the Timeout block

* document timeouts

* have a test case that covers 'hours'

* restore a System default timeout of 20 minutes, instead of 0

* restore system default timeout of 20 minutes, refactor tests, add test method to handle system default

* rename timeout key constants

* test applying timeout to state

* refactor test

* Add resource Diff test

* clarify docs

* update to use constants
iceycake pushed a commit to ticketmaster/terraform that referenced this pull request May 10, 2017
@ghost
Copy link

ghost commented Apr 16, 2020

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 and limited conversation to collaborators Apr 16, 2020
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.

2 participants