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

2.0: Enabling Custom Timeouts, New VM/VMSS Resources & Requires Imports by default #5705

Merged
merged 3 commits into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions azurerm/internal/clients/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package clients
import (
"context"
"fmt"
"time"

"github.com/hashicorp/go-azure-helpers/authentication"
"github.com/hashicorp/go-azure-helpers/sender"
Expand Down Expand Up @@ -84,7 +83,6 @@ func Build(ctx context.Context, builder ClientBuilder) (*Client, error) {
ResourceManagerAuthorizer: auth,
ResourceManagerEndpoint: endpoint,
StorageAuthorizer: storageAuth,
PollingDuration: 180 * time.Minute,
SkipProviderReg: builder.SkipProviderRegistration,
DisableCorrelationRequestID: builder.DisableCorrelationRequestID,
DisableTerraformPartnerID: builder.DisableTerraformPartnerID,
Expand Down
9 changes: 0 additions & 9 deletions azurerm/internal/common/client_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"log"
"os"
"strings"
"time"

"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
Expand Down Expand Up @@ -34,9 +33,6 @@ type ClientOptions struct {
Environment azure.Environment
Features features.UserFeatures
StorageUseAzureAD bool

// TODO: remove me in 2.0
PollingDuration time.Duration
}

func (o ClientOptions) ConfigureClient(c *autorest.Client, authorizer autorest.Authorizer) {
Expand All @@ -48,11 +44,6 @@ func (o ClientOptions) ConfigureClient(c *autorest.Client, authorizer autorest.A
if !o.DisableCorrelationRequestID {
c.RequestInspector = withCorrelationRequestID(correlationRequestID())
}

// TODO: remove in 2.0
if !features.SupportsCustomTimeouts() {
c.PollingDuration = o.PollingDuration
}
}

func setUserAgent(client *autorest.Client, tfVersion, partnerID string, disableTerraformPartnerID bool) {
Expand Down
22 changes: 0 additions & 22 deletions azurerm/internal/features/custom_timeouts.go

This file was deleted.

55 changes: 0 additions & 55 deletions azurerm/internal/features/custom_timeouts_test.go

This file was deleted.

9 changes: 9 additions & 0 deletions azurerm/internal/features/deprecated.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package features

// this feature toggle's been removed
// however to ease open PR's this is temporarily kicking around

// nolint: deadcode unused
func SupportsCustomTimeouts() bool {
return true
}
7 changes: 1 addition & 6 deletions azurerm/internal/features/requires_import.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package features

import (
"os"
"strings"
)

// ShouldResourcesBeImported returns whether the feature Requiring Resources to be Imported
// should be enabled.
//
Expand All @@ -25,5 +20,5 @@ func ShouldResourcesBeImported() bool {
// * MySQL|PostgreSQL Configuration
// since these resources can't support import
// in addition the virtual resources will need adjusting
return strings.EqualFold(os.Getenv("ARM_PROVIDER_STRICT"), "true")
return true
}
55 changes: 0 additions & 55 deletions azurerm/internal/features/requires_import_test.go

This file was deleted.

7 changes: 1 addition & 6 deletions azurerm/internal/features/two_point_oh.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package features

import (
"os"
"strings"
)

// SupportsTwoPointZeroResources returns whether the new VM and VMSS resources from 2.0
// should be supported
//
Expand All @@ -24,5 +19,5 @@ import (
// Operators wishing to beta-test these resources can opt-into them in 1.x versions of the
// Azure Provider by setting the Environment Variable 'ARM_PROVIDER_TWOPOINTZERO_RESOURCES' to 'true'
func SupportsTwoPointZeroResources() bool {
return strings.EqualFold(os.Getenv("ARM_PROVIDER_TWOPOINTZERO_RESOURCES"), "true")
return true
}
55 changes: 0 additions & 55 deletions azurerm/internal/features/two_point_oh_test.go

This file was deleted.

9 changes: 0 additions & 9 deletions azurerm/internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand Down Expand Up @@ -51,14 +50,6 @@ func AzureProvider() terraform.ResourceProvider {
}
}

// TODO: remove all of this in 2.0 once Custom Timeouts are supported
if !features.SupportsCustomTimeouts() {
// ensure any timeouts configured on the resources are removed until 2.0
for _, v := range resources {
v.Timeouts = nil
}
}

p := &schema.Provider{
Schema: map[string]*schema.Schema{
"subscription_id": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,13 @@ func resourceArmAutomationModuleCreateUpdate(d *schema.ResourceData, meta interf
return resp, "Unknown", nil
},
}
if features.SupportsCustomTimeouts() {
if d.IsNewResource() {
stateConf.Timeout = d.Timeout(schema.TimeoutCreate)
} else {
stateConf.Timeout = d.Timeout(schema.TimeoutUpdate)
}
if d.IsNewResource() {
stateConf.Timeout = d.Timeout(schema.TimeoutCreate)
} else {
stateConf.Timeout = 30 * time.Minute
stateConf.Timeout = d.Timeout(schema.TimeoutUpdate)
}

_, err := stateConf.WaitForState()
if err != nil {
if _, err := stateConf.WaitForState(); err != nil {
return fmt.Errorf("Error waiting for Module %q (Automation Account %q / Resource Group %q) to finish provisioning: %+v", name, accName, resGroup, err)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,7 @@ func resourceArmDedicatedHostDelete(d *schema.ResourceData, meta interface{}) er
Refresh: dedicatedHostDeletedRefreshFunc(ctx, client, id),
MinTimeout: 10 * time.Second,
ContinuousTargetOccurence: 10,
}

if features.SupportsCustomTimeouts() {
stateConf.Timeout = d.Timeout(schema.TimeoutDelete)
} else {
stateConf.Timeout = 10 * time.Minute
Timeout: d.Timeout(schema.TimeoutDelete),
}

if _, err = stateConf.WaitForState(); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,12 +664,7 @@ func resourceArmContainerGroupDelete(d *schema.ResourceData, meta interface{}) e
Refresh: containerGroupEnsureDetachedFromNetworkProfileRefreshFunc(ctx, networkProfileClient, networkProfileResourceGroup, networkProfileName, resourceGroup, name),
MinTimeout: 15 * time.Second,
ContinuousTargetOccurence: 5,
}

if features.SupportsCustomTimeouts() {
stateConf.Timeout = d.Timeout(schema.TimeoutDelete)
} else {
stateConf.Timeout = 10 * time.Minute
Timeout: d.Timeout(schema.TimeoutDelete),
}

if _, err := stateConf.WaitForState(); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,10 @@ func resourceArmContainerServiceCreateUpdate(d *schema.ResourceData, meta interf
MinTimeout: 15 * time.Second,
}

if features.SupportsCustomTimeouts() {
if d.IsNewResource() {
stateConf.Timeout = d.Timeout(schema.TimeoutCreate)
} else {
stateConf.Timeout = d.Timeout(schema.TimeoutUpdate)
}
if d.IsNewResource() {
stateConf.Timeout = d.Timeout(schema.TimeoutCreate)
} else {
stateConf.Timeout = 30 * time.Minute
stateConf.Timeout = d.Timeout(schema.TimeoutUpdate)
}

if _, err := stateConf.WaitForState(); err != nil {
Expand Down
Loading