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

Added runtime_engine support for databricks_cluster #1686

Merged
merged 3 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clusters/clusters_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ type Cluster struct {
SingleUserName string `json:"single_user_name,omitempty"`
IdempotencyToken string `json:"idempotency_token,omitempty" tf:"force_new"`
WorkloadType *WorkloadType `json:"workload_type,omitempty"`
RuntimeEngine string `json:"runtime_engine,omitempty"`
}

func (cluster Cluster) Validate() error {
Expand Down Expand Up @@ -489,6 +490,7 @@ type ClusterInfo struct {
ClusterLogStatus *LogSyncStatus `json:"cluster_log_status,omitempty"`
TerminationReason *TerminationReason `json:"termination_reason,omitempty"`
DataSecurityMode string `json:"data_security_mode,omitempty"`
RuntimeEngine string `json:"runtime_engine,omitempty"`
}

// IsRunningOrResizing returns true if cluster is running or resizing
Expand Down
2 changes: 2 additions & 0 deletions clusters/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ func resourceClusterSchema() map[string]*schema.Schema {
s["driver_node_type_id"].ConflictsWith = []string{"driver_instance_pool_id", "instance_pool_id"}
s["node_type_id"].ConflictsWith = []string{"driver_instance_pool_id", "instance_pool_id"}

s["runtime_engine"].ValidateFunc = validation.StringInSlice([]string{"PHOTON", "STANDARD"}, false)

s["is_pinned"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Expand Down
72 changes: 72 additions & 0 deletions clusters/resource_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,78 @@ func TestResourceClusterCreate_WithLibraries(t *testing.T) {
assert.Equal(t, "abc", d.Id())
}

func TestResourceClusterCreatePhoton(t *testing.T) {
d, err := qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
{
Method: "POST",
Resource: "/api/2.0/clusters/create",
ExpectedRequest: Cluster{
NumWorkers: 100,
ClusterName: "Shared Autoscaling",
SparkVersion: "7.1-scala12",
NodeTypeID: "i3.xlarge",
AutoterminationMinutes: 15,
RuntimeEngine: "PHOTON",
},
Response: ClusterInfo{
ClusterID: "abc",
State: ClusterStateRunning,
},
},
{
Method: "GET",
ReuseRequest: true,
Resource: "/api/2.0/clusters/get?cluster_id=abc",
Response: ClusterInfo{
ClusterID: "abc",
NumWorkers: 100,
ClusterName: "Shared Autoscaling",
SparkVersion: "7.1-scala12",
NodeTypeID: "i3.xlarge",
AutoterminationMinutes: 15,
State: ClusterStateRunning,
RuntimeEngine: "PHOTON",
},
},
{
Method: "POST",
Resource: "/api/2.0/clusters/events",
ExpectedRequest: EventsRequest{
ClusterID: "abc",
Limit: 1,
Order: SortDescending,
EventTypes: []ClusterEventType{EvTypePinned, EvTypeUnpinned},
},
Response: EventsResponse{
Events: []ClusterEvent{},
TotalCount: 0,
},
},
{
Method: "GET",
Resource: "/api/2.0/libraries/cluster-status?cluster_id=abc",
Response: libraries.ClusterLibraryStatuses{
LibraryStatuses: []libraries.LibraryStatus{},
},
},
},
Create: true,
Resource: ResourceCluster(),
State: map[string]any{
"autotermination_minutes": 15,
"cluster_name": "Shared Autoscaling",
"spark_version": "7.1-scala12",
"node_type_id": "i3.xlarge",
"num_workers": 100,
"is_pinned": false,
"runtime_engine": "PHOTON",
},
}.Apply(t)
assert.NoError(t, err, err)
assert.Equal(t, "abc", d.Id())
}

func TestResourceClusterCreate_Error(t *testing.T) {
d, err := qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
Expand Down
4 changes: 3 additions & 1 deletion docs/data-sources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ data "databricks_cluster" "all" {
## Attribute Reference

This data source exports the following attributes:

* `cluster_info` block, consisting of following fields:
* `cluster_name` - Cluster name, which doesn’t have to be unique.
* `spark_version` - [Runtime version](https://docs.databricks.com/runtime/index.html) of the cluster.
* `runtime_engine` - The type of runtime of the cluster
* `driver_node_type_id` - The node type of the Spark driver.
* `node_type_id` - Any supported [databricks_node_type](../data-sources/node_type.md) id.
* `instance_pool_id` The [pool of idle instances](instance_pool.md) the cluster is attached to.
Expand All @@ -58,4 +60,4 @@ The following resources are often used in the same context:
* [databricks_instance_pool](../resources/instance_pool.md) to manage [instance pools](https://docs.databricks.com/clusters/instance-pools/index.html) to reduce [cluster](../resources/cluster.md) start and auto-scaling times by maintaining a set of idle, ready-to-use instances.
* [databricks_job](../resources/job.md) to manage [Databricks Jobs](https://docs.databricks.com/jobs.html) to run non-interactive code in a [databricks_cluster](../resources/cluster.md).
* [databricks_library](../resources/library.md) to install a [library](https://docs.databricks.com/libraries/index.html) on [databricks_cluster](../resources/cluster.md).
* [databricks_pipeline](../resources/pipeline.md) to deploy [Delta Live Tables](https://docs.databricks.com/data-engineering/delta-live-tables/index.html).
* [databricks_pipeline](../resources/pipeline.md) to deploy [Delta Live Tables](https://docs.databricks.com/data-engineering/delta-live-tables/index.html).
Loading