Skip to content

Commit

Permalink
FourPointOh - remove from service/hdinsight (#28349)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreallymatt authored Dec 23, 2024
1 parent 1872180 commit 17f403e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/hashicorp/go-azure-sdk/resource-manager/hdinsight/2021-06-01/clusters"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
"github.com/hashicorp/terraform-provider-azurerm/utils"
Expand All @@ -35,11 +34,10 @@ var hdInsightInteractiveQueryClusterHeadNodeDefinition = HDInsightNodeDefinition
}

var hdInsightInteractiveQueryClusterWorkerNodeDefinition = HDInsightNodeDefinition{
CanSpecifyInstanceCount: true,
MinInstanceCount: 1,
CanSpecifyDisks: false,
CanAutoScaleByCapacityDeprecated4PointOh: true,
CanAutoScaleOnSchedule: true,
CanSpecifyInstanceCount: true,
MinInstanceCount: 1,
CanSpecifyDisks: false,
CanAutoScaleOnSchedule: true,
}

var hdInsightInteractiveQueryClusterZookeeperNodeDefinition = HDInsightNodeDefinition{
Expand All @@ -51,7 +49,7 @@ var hdInsightInteractiveQueryClusterZookeeperNodeDefinition = HDInsightNodeDefin
}

func resourceHDInsightInteractiveQueryCluster() *pluginsdk.Resource {
resource := &pluginsdk.Resource{
return &pluginsdk.Resource{
Create: resourceHDInsightInteractiveQueryClusterCreate,
Read: resourceHDInsightInteractiveQueryClusterRead,
Update: hdinsightClusterUpdate("Interactive Query", resourceHDInsightInteractiveQueryClusterRead),
Expand All @@ -78,6 +76,21 @@ func resourceHDInsightInteractiveQueryCluster() *pluginsdk.Resource {

"cluster_version": SchemaHDInsightClusterVersion(),

"roles": {
Type: pluginsdk.TypeList,
Required: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"head_node": SchemaHDInsightNodeDefinition("roles.0.head_node", hdInsightInteractiveQueryClusterHeadNodeDefinition, true),

"worker_node": SchemaHDInsightNodeDefinition("roles.0.worker_node", hdInsightInteractiveQueryClusterWorkerNodeDefinition, true),

"zookeeper_node": SchemaHDInsightNodeDefinition("roles.0.zookeeper_node", hdInsightInteractiveQueryClusterZookeeperNodeDefinition, true),
},
},
},

"tier": SchemaHDInsightTier(),

"tls_min_version": SchemaHDInsightTls(),
Expand Down Expand Up @@ -138,41 +151,6 @@ func resourceHDInsightInteractiveQueryCluster() *pluginsdk.Resource {
"extension": SchemaHDInsightsExtension(),
},
}

if !features.FourPointOh() {
resource.Schema["roles"] = &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Required: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"head_node": SchemaHDInsightNodeDefinition("roles.0.head_node", hdInsightInteractiveQueryClusterHeadNodeDefinition, true),

"worker_node": SchemaHDInsightNodeDefinition("roles.0.worker_node", hdInsightInteractiveQueryClusterWorkerNodeDefinition, true),

"zookeeper_node": SchemaHDInsightNodeDefinition("roles.0.zookeeper_node", hdInsightInteractiveQueryClusterZookeeperNodeDefinition, true),
},
},
}
} else {
hdInsightInteractiveQueryClusterWorkerNodeDefinition.CanAutoScaleByCapacityDeprecated4PointOh = false
resource.Schema["roles"] = &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Required: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"head_node": SchemaHDInsightNodeDefinition("roles.0.head_node", hdInsightInteractiveQueryClusterHeadNodeDefinition, true),

"worker_node": SchemaHDInsightNodeDefinition("roles.0.worker_node", hdInsightInteractiveQueryClusterWorkerNodeDefinition, true),

"zookeeper_node": SchemaHDInsightNodeDefinition("roles.0.zookeeper_node", hdInsightInteractiveQueryClusterZookeeperNodeDefinition, true),
},
},
}
}

return resource
}

func resourceHDInsightInteractiveQueryClusterCreate(d *pluginsdk.ResourceData, meta interface{}) error {
Expand Down
66 changes: 2 additions & 64 deletions internal/services/hdinsight/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1157,8 +1157,6 @@ type HDInsightNodeDefinition struct {
FixedTargetInstanceCount *int64
CanAutoScaleByCapacity bool
CanAutoScaleOnSchedule bool
// todo remove in 4.0
CanAutoScaleByCapacityDeprecated4PointOh bool
}

func SchemaHDInsightNodeDefinition(schemaLocation string, definition HDInsightNodeDefinition, required bool) *pluginsdk.Schema {
Expand Down Expand Up @@ -1255,37 +1253,7 @@ func SchemaHDInsightNodeDefinition(schemaLocation string, definition HDInsightNo
}
}
}
// managing `azurerm_hdinsight_interactive_query_cluster` autoscaling through `capacity` doesn't work so we'll deprecate this portion of the schema for 4.0
if definition.CanAutoScaleByCapacityDeprecated4PointOh {
autoScales["capacity"] = &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Optional: true,
MaxItems: 1,
ConflictsWith: []string{
fmt.Sprintf("%s.0.autoscale.0.recurrence", schemaLocation),
},
Deprecated: "HDInsight interactive query clusters can no longer be configured through `autoscale.0.capacity`. Use `autoscale.0.recurrence` instead.",
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"min_instance_count": {
Type: pluginsdk.TypeInt,
Required: true,
ValidateFunc: countValidation,
},
"max_instance_count": {
Type: pluginsdk.TypeInt,
Required: true,
ValidateFunc: countValidation,
},
},
},
}
if definition.CanAutoScaleOnSchedule {
autoScales["capacity"].ConflictsWith = []string{
fmt.Sprintf("%s.0.autoscale.0.recurrence", schemaLocation),
}
}
}

if definition.CanAutoScaleOnSchedule {
autoScales["recurrence"] = &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Expand Down Expand Up @@ -1472,37 +1440,7 @@ func SchemaHDInsightNodeDefinitionKafka(schemaLocation string, definition HDInsi
}
}
}
// managing `azurerm_hdinsight_interactive_query_cluster` autoscaling through `capacity` doesn't work so we'll deprecate this portion of the schema for 4.0
if definition.CanAutoScaleByCapacityDeprecated4PointOh {
autoScales["capacity"] = &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Optional: true,
MaxItems: 1,
ConflictsWith: []string{
fmt.Sprintf("%s.0.autoscale.0.recurrence", schemaLocation),
},
Deprecated: "HDInsight interactive query clusters can no longer be configured through `autoscale.0.capacity`. Use `autoscale.0.recurrence` instead.",
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"min_instance_count": {
Type: pluginsdk.TypeInt,
Required: true,
ValidateFunc: countValidation,
},
"max_instance_count": {
Type: pluginsdk.TypeInt,
Required: true,
ValidateFunc: countValidation,
},
},
},
}
if definition.CanAutoScaleOnSchedule {
autoScales["capacity"].ConflictsWith = []string{
fmt.Sprintf("%s.0.autoscale.0.recurrence", schemaLocation),
}
}
}

if definition.CanAutoScaleOnSchedule {
autoScales["recurrence"] = &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Expand Down

0 comments on commit 17f403e

Please sign in to comment.