Skip to content

Commit

Permalink
Fixed replacement of instance_pool_id in databricks_cluster (data…
Browse files Browse the repository at this point in the history
…bricks#850)

Added corner case to fix issue databricks#824 where `driver_instance_pool_id` was not explicitly specified and old driver instance pool sent in cluster update request
  • Loading branch information
nfx committed Oct 6, 2021
1 parent 4f2069d commit 31996b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Already deleted `databricks_token` don't fail the apply ([#808](https://github.com/databrickslabs/terraform-provider-databricks/pull/808))
* Default `terraform-mount` clusters created for mounting for `databricks_aws_s3_mount`, `databricks_azure_adls_gen1_mount`, `databricks_azure_adls_gen2_mount`, and `databricks_azure_blob_mount` have now `spark.scheduler.mode` as `FIFO` ([#828](https://github.com/databrickslabs/terraform-provider-databricks/pull/828))
* Fixed crash when using non-Azure authentication to mount Azure resources ([#831](https://github.com/databrickslabs/terraform-provider-databricks/issues/831))
* Fixed replacement of `instance_pool_id` in `databricks_cluster`, when `driver_instance_pool_id` was not explicitly specified ([#824](https://github.com/databrickslabs/terraform-provider-databricks/issues/824))
* Multiple documentation improvements

**Deprecations**
Expand Down
12 changes: 12 additions & 0 deletions compute/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,17 @@ func hasClusterConfigChanged(d *schema.ResourceData) bool {
return false
}

// https://github.com/databrickslabs/terraform-provider-databricks/issues/824
func fixInstancePoolChangeIfAny(d *schema.ResourceData, cluster *Cluster) {
oldInstancePool, newInstancePool := d.GetChange("instance_pool_id")
oldDriverPool, newDriverPool := d.GetChange("driver_instance_pool_id")
if oldInstancePool != newInstancePool &&
oldDriverPool == oldInstancePool &&
oldDriverPool == newDriverPool {
cluster.DriverInstancePoolID = cluster.InstancePoolID
}
}

func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
clusters := NewClustersAPI(ctx, c)
clusterID := d.Id()
Expand All @@ -266,6 +277,7 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, c *commo
return err
}
modifyClusterRequest(&cluster)
fixInstancePoolChangeIfAny(d, &cluster)
clusterInfo, err = clusters.Edit(cluster)
if err != nil {
return err
Expand Down

0 comments on commit 31996b4

Please sign in to comment.