Skip to content

Commit

Permalink
Adding resource create/update/delete timeout configuration ability an…
Browse files Browse the repository at this point in the history
…d corresponding documentation for timeouts.

This is specifically to resolve issue: rancher/terraform-provider-rancher2#19
  • Loading branch information
Oats87 committed Dec 26, 2018
1 parent 38cd2a4 commit 0178be7
Show file tree
Hide file tree
Showing 18 changed files with 153 additions and 29 deletions.
11 changes: 8 additions & 3 deletions rancher2/resource_rancher2_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ func resourceRancher2Catalog() *schema.Resource {
},

Schema: catalogFields(),
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
}
}

Expand All @@ -164,7 +169,7 @@ func resourceRancher2CatalogCreate(d *schema.ResourceData, meta interface{}) err
Pending: []string{"refreshed"},
Target: []string{"active"},
Refresh: catalogStateRefreshFunc(client, newCatalog.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -237,7 +242,7 @@ func resourceRancher2CatalogUpdate(d *schema.ResourceData, meta interface{}) err
Pending: []string{"refreshed"},
Target: []string{"active"},
Refresh: catalogStateRefreshFunc(client, newCatalog.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutUpdate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -279,7 +284,7 @@ func resourceRancher2CatalogDelete(d *schema.ResourceData, meta interface{}) err
Pending: []string{"active"},
Target: []string{"removed"},
Refresh: catalogStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutDelete),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down
14 changes: 10 additions & 4 deletions rancher2/resource_rancher2_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ func resourceRancher2Cluster() *schema.Resource {
State: resourceRancher2ClusterImport,
},
Schema: clusterFields(),
// Setting default timeouts to be liberal in order to accommodate managed Kubernetes providers like EKS, GKE, and AKS
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(30 * time.Minute),
Update: schema.DefaultTimeout(30 * time.Minute),
Delete: schema.DefaultTimeout(30 * time.Minute),
},
}
}

Expand Down Expand Up @@ -300,7 +306,7 @@ func resourceRancher2ClusterCreate(d *schema.ResourceData, meta interface{}) err
Pending: []string{},
Target: []string{expectedState},
Refresh: clusterStateRefreshFunc(client, newCluster.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand All @@ -327,7 +333,7 @@ func resourceRancher2ClusterCreate(d *schema.ResourceData, meta interface{}) err
Pending: []string{},
Target: []string{"active"},
Refresh: clusterRegistrationTokenStateRefreshFunc(client, newClusterRegistrationToken.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -436,7 +442,7 @@ func resourceRancher2ClusterUpdate(d *schema.ResourceData, meta interface{}) err
Pending: []string{"active", "provisioning", "pending"},
Target: []string{"active", "provisioning", "pending"},
Refresh: clusterStateRefreshFunc(client, newCluster.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutUpdate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -477,7 +483,7 @@ func resourceRancher2ClusterDelete(d *schema.ResourceData, meta interface{}) err
Pending: []string{"removing"},
Target: []string{"removed"},
Refresh: clusterStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutDelete),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down
11 changes: 8 additions & 3 deletions rancher2/resource_rancher2_cluster_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ func resourceRancher2ClusterLogging() *schema.Resource {
},

Schema: clusterLoggingFields(),
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
}
}

Expand Down Expand Up @@ -342,7 +347,7 @@ func resourceRancher2ClusterLoggingCreate(d *schema.ResourceData, meta interface
Pending: []string{"provisioning"},
Target: []string{"active"},
Refresh: clusterLoggingStateRefreshFunc(client, newClusterLogging.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -448,7 +453,7 @@ func resourceRancher2ClusterLoggingUpdate(d *schema.ResourceData, meta interface
Pending: []string{"updating"},
Target: []string{"active"},
Refresh: clusterLoggingStateRefreshFunc(client, newClusterLogging.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutUpdate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -490,7 +495,7 @@ func resourceRancher2ClusterLoggingDelete(d *schema.ResourceData, meta interface
Pending: []string{"active"},
Target: []string{"removed"},
Refresh: clusterLoggingStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutDelete),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down
11 changes: 8 additions & 3 deletions rancher2/resource_rancher2_cluster_role_template_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ func resourceRancher2ClusterRoleTemplateBinding() *schema.Resource {
},

Schema: clusterRoleTemplateBindingFields(),
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
}
}

Expand Down Expand Up @@ -193,7 +198,7 @@ func resourceRancher2ClusterRoleTemplateBindingCreate(d *schema.ResourceData, me
Pending: []string{"active"},
Target: []string{"active"},
Refresh: clusterRoleTemplateBindingStateRefreshFunc(client, newClusterRole.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -267,7 +272,7 @@ func resourceRancher2ClusterRoleTemplateBindingUpdate(d *schema.ResourceData, me
Pending: []string{"active"},
Target: []string{"active"},
Refresh: clusterRoleTemplateBindingStateRefreshFunc(client, newClusterRole.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutUpdate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -309,7 +314,7 @@ func resourceRancher2ClusterRoleTemplateBindingDelete(d *schema.ResourceData, me
Pending: []string{"active"},
Target: []string{"removed"},
Refresh: clusterRoleTemplateBindingStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutDelete),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down
11 changes: 8 additions & 3 deletions rancher2/resource_rancher2_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ func resourceRancher2Namespace() *schema.Resource {
},

Schema: namespaceFields(),
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
}
}

Expand Down Expand Up @@ -207,7 +212,7 @@ func resourceRancher2NamespaceCreate(d *schema.ResourceData, meta interface{}) e
Pending: []string{"activating"},
Target: []string{"active"},
Refresh: namespaceStateRefreshFunc(client, newNs.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -296,7 +301,7 @@ func resourceRancher2NamespaceUpdate(d *schema.ResourceData, meta interface{}) e
Pending: []string{"active"},
Target: []string{"active"},
Refresh: namespaceStateRefreshFunc(client, newNs.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutUpdate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -348,7 +353,7 @@ func resourceRancher2NamespaceDelete(d *schema.ResourceData, meta interface{}) e
Pending: []string{"removing"},
Target: []string{"removed"},
Refresh: namespaceStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutDelete),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down
11 changes: 8 additions & 3 deletions rancher2/resource_rancher2_node_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ func resourceRancher2NodePool() *schema.Resource {
},

Schema: nodePoolFields(),
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
}
}

Expand Down Expand Up @@ -192,7 +197,7 @@ func resourceRancher2NodePoolCreate(d *schema.ResourceData, meta interface{}) er
Pending: []string{},
Target: []string{"active"},
Refresh: nodePoolStateRefreshFunc(client, newNodePool.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -264,7 +269,7 @@ func resourceRancher2NodePoolUpdate(d *schema.ResourceData, meta interface{}) er
Pending: []string{"active"},
Target: []string{"active"},
Refresh: nodePoolStateRefreshFunc(client, newNodePool.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutUpdate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -306,7 +311,7 @@ func resourceRancher2NodePoolDelete(d *schema.ResourceData, meta interface{}) er
Pending: []string{"removing"},
Target: []string{"removed"},
Refresh: nodePoolStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutDelete),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down
11 changes: 8 additions & 3 deletions rancher2/resource_rancher2_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ func resourceRancher2Project() *schema.Resource {
},

Schema: projectFields(),
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
}
}

Expand All @@ -173,7 +178,7 @@ func resourceRancher2ProjectCreate(d *schema.ResourceData, meta interface{}) err
Pending: []string{"active"},
Target: []string{"active"},
Refresh: projectStateRefreshFunc(client, newProject.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -251,7 +256,7 @@ func resourceRancher2ProjectUpdate(d *schema.ResourceData, meta interface{}) err
Pending: []string{"active"},
Target: []string{"active"},
Refresh: projectStateRefreshFunc(client, newProject.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutUpdate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -293,7 +298,7 @@ func resourceRancher2ProjectDelete(d *schema.ResourceData, meta interface{}) err
Pending: []string{"removing"},
Target: []string{"removed"},
Refresh: projectStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutDelete),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down
11 changes: 8 additions & 3 deletions rancher2/resource_rancher2_project_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ func resourceRancher2ProjectLogging() *schema.Resource {
},

Schema: projectLoggingFields(),
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
}
}

Expand Down Expand Up @@ -344,7 +349,7 @@ func resourceRancher2ProjectLoggingCreate(d *schema.ResourceData, meta interface
Pending: []string{"provisioning"},
Target: []string{"active"},
Refresh: projectLoggingStateRefreshFunc(client, newProjectLogging.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -450,7 +455,7 @@ func resourceRancher2ProjectLoggingUpdate(d *schema.ResourceData, meta interface
Pending: []string{"updating"},
Target: []string{"active"},
Refresh: projectLoggingStateRefreshFunc(client, newProjectLogging.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutUpdate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -492,7 +497,7 @@ func resourceRancher2ProjectLoggingDelete(d *schema.ResourceData, meta interface
Pending: []string{"active"},
Target: []string{"removed"},
Refresh: projectLoggingStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutDelete),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down
11 changes: 8 additions & 3 deletions rancher2/resource_rancher2_project_role_template_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ func resourceRancher2ProjectRoleTemplateBinding() *schema.Resource {
},

Schema: projectRoleTemplateBindingFields(),
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
}
}

Expand Down Expand Up @@ -193,7 +198,7 @@ func resourceRancher2ProjectRoleTemplateBindingCreate(d *schema.ResourceData, me
Pending: []string{"active"},
Target: []string{"active"},
Refresh: projectRoleTemplateBindingStateRefreshFunc(client, newProjectRole.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -267,7 +272,7 @@ func resourceRancher2ProjectRoleTemplateBindingUpdate(d *schema.ResourceData, me
Pending: []string{"active"},
Target: []string{"active"},
Refresh: projectRoleTemplateBindingStateRefreshFunc(client, newProjectRole.ID),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutUpdate),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down Expand Up @@ -309,7 +314,7 @@ func resourceRancher2ProjectRoleTemplateBindingDelete(d *schema.ResourceData, me
Pending: []string{"active"},
Target: []string{"removed"},
Refresh: projectRoleTemplateBindingStateRefreshFunc(client, id),
Timeout: 10 * time.Minute,
Timeout: d.Timeout(schema.TimeoutDelete),
Delay: 1 * time.Second,
MinTimeout: 3 * time.Second,
}
Expand Down
9 changes: 9 additions & 0 deletions website/docs/r/catalog.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ The following arguments are supported:
* `kind` - (Optional) The kind of the catalog. Just helm by the moment.
* `branch` - (Optional) The branch of the catalog repo to use.

### Timeouts

`rancher2_catalog` provides the following
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:

- `create` - (Default `10 minutes`) Used for creating catalogs.
- `update` - (Default `10 minutes`) Used for catalog modifications.
- `delete` - (Default `10 minutes`) Used for deleting catalogs.

## Attributes Reference

The following attributes are exported:
Expand Down
9 changes: 9 additions & 0 deletions website/docs/r/cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,15 @@ The following arguments are supported:
* `sub_network` - (Required) Subnetwork for GKE cluster (string)
* `zone` - (Required) Zone GKE cluster (string)

### Timeouts

`rancher2_cluster` provides the following
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:

- `create` - (Default `30 minutes`) Used for creating clusters.
- `update` - (Default `30 minutes`) Used for cluster modifications.
- `delete` - (Default `30 minutes`) Used for deleting clusters.

## Attributes Reference

The following attributes are exported:
Expand Down
Loading

0 comments on commit 0178be7

Please sign in to comment.