Skip to content

Commit f2be9b5

Browse files
authored
Prepare 0.2.8 (#400)
* Pre-release fixing * Added NAT to BYOVPC terraform module * added instance profile locks * Added sync block for instance profiles integration tests * Fix #383 Cleaning up clusters that fail to start * Added log delivery use case docs * Fix #382 - ignore changes to deployment_name * Fix test and lints * Fix #382 by ignoring incoming prefix for deployment_name for databricks_mws_workspaces * Improve documentation to fix #368 * fix linting issues Co-authored-by: Serge Smertin <[email protected]>
1 parent e3236b5 commit f2be9b5

21 files changed

+587
-351
lines changed

CHANGELOG.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
# Version changelog
22

3-
## 0.2.9
4-
5-
* Fixed restarting cluster on changes in cluster configuration aren't related to the cluster configuration ([issue #379](https://github.com/databrickslabs/terraform-provider-databricks/issues/379))
6-
73
## 0.2.8
84

9-
* Added [databricks_workspace_conf](https://github.com/databrickslabs/terraform-provider-databricks/pull/398) resource
5+
* Added [databricks_workspace_conf](https://github.com/databrickslabs/terraform-provider-databricks/pull/398) resource.
106
* Added [databricks_mws_log_delivery](https://github.com/databrickslabs/terraform-provider-databricks/pull/343) resource for billable usage & audit logs consumption.
117
* Added [databricks_node_type](https://github.com/databrickslabs/terraform-provider-databricks/pull/376) data source for simpler selection of node types across AWS & Azure.
12-
* Added [Azure Key Vault support](https://github.com/databrickslabs/terraform-provider-databricks/pull/381) for databricks_secret_scope for Azure CLI authenticated users.
8+
* Added [Azure Key Vault support](https://github.com/databrickslabs/terraform-provider-databricks/pull/381) for `databricks_secret_scope` for Azure CLI authenticated users.
139
* Added [is_pinned](https://github.com/databrickslabs/terraform-provider-databricks/pull/348) support for `databricks_cluster` resource.
14-
* Fixed [single node clusters](https://docs.databricks.com/clusters/single-node.html) support by allowing [`num_workers` to be `0`](https://github.com/databrickslabs/terraform-provider-databricks/pull/375).
10+
* Fixed restarting cluster on changes in cluster configuration aren't related to the cluster configuration ([issue #379](https://github.com/databrickslabs/terraform-provider-databricks/issues/379))
11+
* Fixed issue [#383](https://github.com/databrickslabs/terraform-provider-databricks/issues/383) by cleaning up clusters that fail to start.
12+
* Fixed issue [#382](https://github.com/databrickslabs/terraform-provider-databricks/issues/382) by ignoring any incoming changes to deployment name of `databricks_mws_workspaces`, as well as propagating the right error messages.
1513
* Internal: API for retrieval of the cluster events.
14+
* Increased code coverage to 71%.
1615

1716
Updated dependency versions:
1817

@@ -22,6 +21,9 @@ Updated dependency versions:
2221
* github.com/Azure/go-autorest/autorest/azure/cli v0.4.2
2322
* gopkg.in/ini.v1 1.62.0
2423

24+
**Deprecations**
25+
* `network_error_messages` from `databricks_mws_workspaces` is deprecated and going to be removed in 0.3
26+
2527
## 0.2.7
2628

2729
* Small fixes

access/resource_secret_scope.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (a SecretScopesAPI) Read(scopeName string) (SecretScope, error) {
106106
// ResourceSecretScope manages secret scopes
107107
func ResourceSecretScope() *schema.Resource {
108108
s := internal.StructToSchema(SecretScope{}, func(s map[string]*schema.Schema) map[string]*schema.Schema {
109-
// TODO: CustomDiffFunc for initial_manage_principal & importing
109+
// TODO: DiffSuppressFunc for initial_manage_principal & importing
110110
s["name"].ForceNew = true
111111
s["initial_manage_principal"].ForceNew = true
112112
s["keyvault_metadata"].ForceNew = true

common/version.go

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,14 @@ package common
22

33
import (
44
"fmt"
5-
"os/exec"
6-
"strings"
7-
"sync"
85
)
96

107
var (
11-
version = ""
12-
onceGitVer sync.Once
8+
version = "0.2.8"
139
)
1410

15-
func versionFromGit() string {
16-
out, err := exec.Command("git", "describe",
17-
"--always", "--long").Output()
18-
ee, ok := err.(*exec.ExitError)
19-
if ok && !ee.Success() || err != nil {
20-
return "dev"
21-
}
22-
return strings.TrimSpace(strings.ReplaceAll(string(out), "v", ""))
23-
}
24-
2511
// Version returns version of provider
2612
func Version() string {
27-
if version == "" {
28-
onceGitVer.Do(func() {
29-
// calling git once per process to know
30-
// the version that integration tests are running
31-
version = versionFromGit()
32-
})
33-
}
3413
return version
3514
}
3615

compute/clusters.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ func (a ClustersAPI) Create(cluster Cluster) (info ClusterInfo, err error) {
3232
return
3333
}
3434
info, err = a.waitForClusterStatus(ci.ClusterID, ClusterStateRunning)
35+
if err != nil {
36+
// https://github.com/databrickslabs/terraform-provider-databricks/issues/383
37+
log.Printf("[ERROR] Cleaning up created cluster, that failed to start: %s", err.Error())
38+
deleteErr := a.PermanentDelete(ci.ClusterID)
39+
if deleteErr != nil {
40+
log.Printf("[ERROR] Failed : %s", deleteErr.Error())
41+
err = deleteErr
42+
}
43+
}
3544
return
3645
}
3746

compute/clusters_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,7 @@ func TestAzureAccNodeTypes(t *testing.T) {
596596
clustersAPI := NewClustersAPI(common.CommonEnvironmentClient())
597597
m := map[string]NodeTypeRequest{
598598
"Standard_F4s": {},
599-
"Standard_L8s_v2": {LocalDisk: true},
600-
"Standard_NC6s_v3": {MinGPUs: 1},
599+
"Standard_NC12": {MinGPUs: 1},
601600
"Standard_L32s_v2": {MinCores: 32, GBPerCore: 8},
602601
}
603602

compute/model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ type Cluster struct {
228228
ClusterName string `json:"cluster_name,omitempty"`
229229

230230
SparkVersion string `json:"spark_version"` // TODO: perhaps make a default
231-
NumWorkers int32 `json:"num_workers" tf:"group:size"`
231+
NumWorkers int32 `json:"num_workers,omitempty" tf:"group:size"`
232232
Autoscale *AutoScale `json:"autoscale,omitempty" tf:"group:size"`
233233
EnableElasticDisk bool `json:"enable_elastic_disk,omitempty" tf:"computed"`
234234
EnableLocalDiskEncryption bool `json:"enable_local_disk_encryption,omitempty"`
@@ -260,7 +260,7 @@ type ClusterList struct {
260260

261261
// ClusterInfo contains the information when getting cluster info from the get request.
262262
type ClusterInfo struct {
263-
NumWorkers int32 `json:"num_workers"`
263+
NumWorkers int32 `json:"num_workers,omitempty"`
264264
AutoScale *AutoScale `json:"autoscale,omitempty"`
265265
ClusterID string `json:"cluster_id,omitempty"`
266266
CreatorUserName string `json:"creator_user_name,omitempty"`

compute/resource_cluster.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,6 @@ func resourceClusterSchema() map[string]*schema.Schema {
102102
p.Sensitive = true
103103
}
104104
s["autotermination_minutes"].Default = 60
105-
s["num_workers"] = &schema.Schema{
106-
Type: schema.TypeInt,
107-
Optional: true,
108-
Default: 0,
109-
}
110105
s["idempotency_token"].ForceNew = true
111106
s["cluster_id"] = &schema.Schema{
112107
Type: schema.TypeString,

compute/resource_cluster_test.go

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -495,73 +495,6 @@ func TestResourceClusterCreate_WithLibraries(t *testing.T) {
495495
assert.Equal(t, "abc", d.Id())
496496
}
497497

498-
func TestResourceClusterCreate_WithoutNumWorkers(t *testing.T) {
499-
d, err := qa.ResourceFixture{
500-
Fixtures: []qa.HTTPFixture{
501-
{
502-
Method: "POST",
503-
Resource: "/api/2.0/clusters/create",
504-
ExpectedRequest: Cluster{
505-
NumWorkers: 0,
506-
ClusterName: "Single Node Cluster",
507-
SparkVersion: "7.1-scala12",
508-
NodeTypeID: "dev-tier-node",
509-
AutoterminationMinutes: 120,
510-
},
511-
Response: ClusterInfo{
512-
ClusterID: "abc",
513-
State: ClusterStateRunning,
514-
},
515-
},
516-
{
517-
Method: "POST",
518-
Resource: "/api/2.0/clusters/events",
519-
ExpectedRequest: EventsRequest{
520-
ClusterID: "abc",
521-
Limit: 1,
522-
Order: SortDescending,
523-
EventTypes: []ClusterEventType{EvTypePinned, EvTypeUnpinned},
524-
},
525-
Response: EventsResponse{
526-
Events: []ClusterEvent{},
527-
TotalCount: 0,
528-
},
529-
},
530-
{
531-
Method: "GET",
532-
ReuseRequest: true,
533-
Resource: "/api/2.0/clusters/get?cluster_id=abc",
534-
Response: ClusterInfo{
535-
ClusterID: "abc",
536-
ClusterName: "Single Node Cluster",
537-
SparkVersion: "7.1-scala12",
538-
NodeTypeID: "dev-tier-node",
539-
AutoterminationMinutes: 120,
540-
State: ClusterStateRunning,
541-
},
542-
},
543-
{
544-
Method: "GET",
545-
Resource: "/api/2.0/libraries/cluster-status?cluster_id=abc",
546-
Response: ClusterLibraryStatuses{
547-
LibraryStatuses: []LibraryStatus{},
548-
},
549-
},
550-
},
551-
Create: true,
552-
Resource: ResourceCluster(),
553-
State: map[string]interface{}{
554-
"autotermination_minutes": 120,
555-
"cluster_name": "Single Node Cluster",
556-
"spark_version": "7.1-scala12",
557-
"node_type_id": "dev-tier-node",
558-
"is_pinned": false,
559-
},
560-
}.Apply(t)
561-
assert.NoError(t, err, err)
562-
assert.Equal(t, 0, d.Get("num_workers"))
563-
}
564-
565498
func TestResourceClusterCreate_Error(t *testing.T) {
566499
d, err := qa.ResourceFixture{
567500
Fixtures: []qa.HTTPFixture{

docs/resources/cluster.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ disable automatic termination. _It is highly recommended to have this setting pr
3535
* `idempotency_token` - (Optional) An optional token that can be used to guarantee the idempotency of cluster creation requests. If an active cluster with the provided token already exists, the request will not create a new cluster, but it will return the ID of the existing cluster instead. The existence of a cluster with the same token is not checked against terminated clusters. If you specify the idempotency token, upon failure you can retry until the request succeeds. Databricks will guarantee that exactly one cluster will be launched with that idempotency token. This token should have at most 64 characters.
3636
* `ssh_public_keys` - (Optional) SSH public key contents that will be added to each Spark node in this cluster. The corresponding private keys can be used to login with the user name ubuntu on port 2200. Up to 10 keys can be specified.
3737
* `spark_env_vars` - (Optional) Map with environment variable key-value pairs to fine tune Spark clusters. Key-value pair of the form (X,Y) are exported as is (i.e., export X='Y') while launching the driver and workers. To specify an additional set of SPARK_DAEMON_JAVA_OPTS, we recommend appending them to $SPARK_DAEMON_JAVA_OPTS as shown in the example below. This ensures that all default databricks managed environmental variables are included as well.
38-
* `custom_tags` - (Optional) Additional tags for cluster resources. Databricks will tag all cluster resources (e.g., AWS instances and EBS volumes) with these tags in addition to `default_tags`.
38+
* `custom_tags` - (Optional) Additional tags for cluster resources. Databricks will tag all cluster resources (e.g., AWS EC2 instances and EBS volumes) with these tags in addition to `default_tags`.
3939
* `spark_conf` - (Optional) Map with key-value pairs to fine tune Spark clusters, where you can provide custom pSpark configuration properties](https://spark.apache.org/docs/latest/configuration.html) in a cluster configuration. You can also pass in a string of extra JVM options to the driver and the executors via `spark.driver.extraJavaOptions` and `spark.executor.extraJavaOptions` respectively. It is advised to keep all common configurations in [Cluster Policies](cluster_policy.md) to maintain control of the environments launched.
4040
* `is_pinned` - (Optional) boolean value specifying if cluster is pinned (not pinned by default). If flag is set, then cluster is pinned using [corresponding API](https://docs.databricks.com/dev-tools/api/latest/clusters.html#pin). You must be a Databricks administrator to use this. The maximal number of the pinned clusters is also [limited to 20](https://docs.databricks.com/clusters/clusters-manage.html#pin-a-cluster), so task may fail if you have more than that.
4141

@@ -67,10 +67,6 @@ resource "databricks_cluster" "shared_autoscaling" {
6767

6868
When you [create a Databricks cluster](https://docs.databricks.com/clusters/configure.html#cluster-size-and-autoscaling), you can either provide a `num_workers` for the fixed size cluster or provide `min_workers` and/or `max_workers` for the cluster withing `autoscale` group. When you provide a fixed size cluster, Databricks ensures that your cluster has the specified number of workers. When you provide a range for the number of workers, Databricks chooses the appropriate number of workers required to run your job. This is referred to as autoscaling. With autoscaling, Databricks dynamically reallocates workers to account for the characteristics of your job. Certain parts of your pipeline may be more computationally demanding than others, and Databricks automatically adds additional workers during these phases of your job (and removes them when they’re no longer needed). It is advised to keep all common configurations in [Cluster Policies](cluster_policy.md) to maintain control of the environments launched.
6969

70-
When using a [Single Node cluster](https://docs.databricks.com/clusters/single-node.html), `num_workers` needs to be `0`. In this case you can choose to explicitly add the argument or not, as it defaults to `0`.
71-
72-
* `num_workers` - (Optional) Number of worker nodes that this cluster should have. A cluster has one Spark Driver and num_workers Executors for a total of num_workers + 1 Spark node. Set to `0` when not provided.
73-
7470
`autoscale` optional configuration block supports the following:
7571

7672
* `min_workers` - (Optional) The minimum number of workers to which the cluster can scale down when underutilized. It is also the initial number of workers the cluster will have after creation.

docs/resources/mws_log_delivery.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ resource "databricks_mws_log_delivery" "audit_logs" {
8383

8484
## Billable Usage
8585

86-
CSV files with [static schema](https://docs.databricks.com/administration-guide/account-settings/usage.html) are delivered to `<delivery_path_prefix>/billable-usage/csv/`. Files are named `workspaceId=<workspace-id>-usageMonth=<month>.csv`, which are delivered daily by overwriting the month's CSV file for each workspace.
86+
CSV files are delivered to `<delivery_path_prefix>/billable-usage/csv/` and are named `workspaceId=<workspace-id>-usageMonth=<month>.csv`, which are delivered daily by overwriting the month's CSV file for each workspace. Format of CSV file, as well as some usage examples, can be found [here](https://docs.databricks.com/administration-guide/account-settings/usage.html#download-usage-as-a-csv-file).
87+
88+
Common processing scenario is to apply [cost allocation tags](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html), that could be enforced by setting [custom_tags](cluster.md#custom_tags) on a cluster or through [cluster policy](cluster_policy.md). Report contains `clusterId` field, that could be joined with data from AWS [cost and usage reports](https://docs.aws.amazon.com/cur/latest/userguide/cur-create.html), that can be joined with `user:ClusterId` tag from AWS usage report.
8789

8890
```hcl
8991
resource "databricks_mws_log_delivery" "usage_logs" {

0 commit comments

Comments
 (0)