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

azurerm_search_service:Update basic SKU partition count from 1 to 3 #28105

Merged
Show file tree
Hide file tree
Changes from 7 commits
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
18 changes: 14 additions & 4 deletions internal/services/search/search_service_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,19 @@ func resourceSearchServiceCreate(d *pluginsdk.ResourceData, meta interface{}) er
return fmt.Errorf("'hosting_mode' can only be defined if the 'sku' field is set to the %q SKU, got %q", string(services.SkuNameStandardThree), skuName)
}

// NOTE: 'partition_count' values greater than 1 are not valid for 'free' or 'basic' SKUs...
// NOTE: 'partition_count' values greater than 1 are not valid for 'free' SKU...
partitionCount := int64(d.Get("partition_count").(int))

if (skuName == services.SkuNameFree || skuName == services.SkuNameBasic) && partitionCount > 1 {
if (skuName == services.SkuNameFree) && partitionCount > 1 {
return fmt.Errorf("'partition_count' values greater than 1 cannot be set for the %q SKU, got %d)", string(skuName), partitionCount)
}

// NOTE: 'partition_count' values greater than 3 are not valid for 'basic' SKU...

if (skuName == services.SkuNameBasic) && partitionCount > 3 {
return fmt.Errorf("'partition_count' values greater than 3 cannot be set for the %q SKU, got %d)", string(skuName), partitionCount)
}

// NOTE: 'standard3' services with 'hostingMode' set to 'highDensity' the
// 'partition_count' must be between 1 and 3.
if skuName == services.SkuNameStandardThree && partitionCount > 3 && hostingMode == services.HostingModeHighDensity {
Expand Down Expand Up @@ -452,10 +458,14 @@ func resourceSearchServiceUpdate(d *pluginsdk.ResourceData, meta interface{}) er

if d.HasChange("partition_count") {
partitionCount := int64(d.Get("partition_count").(int))
// NOTE: 'partition_count' values greater than 1 are not valid for 'free' or 'basic' SKUs...
if (pointer.From(model.Sku.Name) == services.SkuNameFree || pointer.From(model.Sku.Name) == services.SkuNameBasic) && partitionCount > 1 {
// NOTE: 'partition_count' values greater than 1 are not valid for 'free' SKUs...
if (pointer.From(model.Sku.Name) == services.SkuNameFree) && partitionCount > 1 {
return fmt.Errorf("'partition_count' values greater than 1 cannot be set for the %q SKU, got %d)", pointer.From(model.Sku.Name), partitionCount)
}
// NOTE: 'partition_count' values greater than 3 are not valid for 'basic' SKUs...
if (pointer.From(model.Sku.Name) == services.SkuNameBasic) && partitionCount > 3 {
return fmt.Errorf("'partition_count' values greater than 3 cannot be set for the %q SKU, got %d)", pointer.From(model.Sku.Name), partitionCount)
}

// NOTE: If SKU is 'standard3' and the 'hosting_mode' is set to 'highDensity' the maximum number of partitions allowed is 3
// where if 'hosting_mode' is set to 'default' the maximum number of partitions is 12...
Expand Down
2 changes: 1 addition & 1 deletion internal/services/search/search_service_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func TestAccSearchService_partitionCountInvalidBySku(t *testing.T) {
{
Config: r.partitionCount(data, "basic", 3),
Gnana-Bharathi-K marked this conversation as resolved.
Show resolved Hide resolved
Check: acceptance.ComposeTestCheckFunc(),
ExpectError: regexp.MustCompile("values greater than 1 cannot be set"),
ExpectError: regexp.MustCompile("values greater than 3 cannot be set"),
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/search_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ The following arguments are supported:

* `local_authentication_enabled` - (Optional) Specifies whether the Search Service allows authenticating using API Keys? Defaults to `true`.

* `partition_count` - (Optional) Specifies the number of partitions which should be created. This field cannot be set when using a `free` or `basic` sku ([see the Microsoft documentation](https://learn.microsoft.com/azure/search/search-sku-tier)). Possible values include `1`, `2`, `3`, `4`, `6`, or `12`. Defaults to `1`.
* `partition_count` - (Optional) Specifies the number of partitions which should be created. This field cannot be set when using a `free` sku ([see the Microsoft documentation](https://learn.microsoft.com/azure/search/search-sku-tier)). Possible values include `1`, `2`, `3`, `4`, `6`, or `12`. Defaults to `1`.

-> **NOTE:** when `hosting_mode` is set to `highDensity` the maximum number of partitions allowed is `3`.

Expand Down