Skip to content

Commit

Permalink
Merge pull request #19792 from neil-yechenwei/fixlrobugs
Browse files Browse the repository at this point in the history
Batch Fix - convert sync call to async call for the existing resources
  • Loading branch information
tombuildsstuff committed Jan 3, 2023
2 parents 63b877a + f50e063 commit 4cc9fce
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .teamcity/components/settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ var serviceTestConfigurationOverrides = mapOf(
// netapp has a max of 10 accounts per subscription so lets limit it to 3 to account for broken ones, run Monday, Wednesday, Friday
"netapp" to testConfiguration(parallelism = 3, daysOfWeek = "2,4,6", useDevTestSubscription = true),

// Orbital is only available in certain locations
"orbital" to testConfiguration(locationOverride = LocationConfiguration("eastus", "southcentralus", "westus2", false)),

"policy" to testConfiguration(useAltSubscription = true),

// Private DNS Resolver is only available in certain locations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func resourceArmStackHCIClusterDelete(d *pluginsdk.ResourceData, meta interface{
return err
}

if _, err := client.Delete(ctx, *id); err != nil {
if err := client.DeleteThenPoll(ctx, *id); err != nil {
return fmt.Errorf("deleting %s: %+v", *id, err)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ func (r AccessConnectorResource) Create() sdk.ResourceFunc {
Identity: expandedIdentity,
}

_, err = client.CreateOrUpdate(ctx, id, accessConnector)
if err != nil {
if err = client.CreateOrUpdateThenPoll(ctx, id, accessConnector); err != nil {
return fmt.Errorf("creating %s: %+v", id, err)
}

Expand Down Expand Up @@ -131,8 +130,7 @@ func (r AccessConnectorResource) Update() sdk.ResourceFunc {
existing.Model.Tags = &state.Tags
}

_, err = client.CreateOrUpdate(ctx, *id, *existing.Model)
if err != nil {
if err = client.CreateOrUpdateThenPoll(ctx, *id, *existing.Model); err != nil {
return fmt.Errorf("updating %s: %+v", id, err)
}

Expand Down Expand Up @@ -192,8 +190,7 @@ func (r AccessConnectorResource) Delete() sdk.ResourceFunc {

client := metadata.Client.DataBricks.AccessConnectorClient

_, err = client.Delete(ctx, *id)
if err != nil {
if err = client.DeleteThenPoll(ctx, *id); err != nil {
return fmt.Errorf("deleting %s: %+v", *id, err)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,16 @@ func resourceDatadogSingleSignOnConfigurationsCreateorUpdate(d *pluginsdk.Resour
EnterpriseAppID: utils.String(enterpriseAppID),
},
}
if _, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.MonitorName, configurationName, &body); err != nil {

future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.MonitorName, configurationName, &body)
if err != nil {
return fmt.Errorf("configuring SingleSignOn on Datadog Monitor %q (Resource Group %q): %+v", id.MonitorName, id.ResourceGroup, err)
}

if err = future.WaitForCompletionRef(ctx, client.Client); err != nil {
return fmt.Errorf("waiting on configuring SingleSignOn on Datadog Monitor %s: %+v", id, err)
}

d.SetId(ssoId)
return resourceDatadogSingleSignOnConfigurationsRead(d, meta)
}
Expand Down Expand Up @@ -166,9 +172,15 @@ func resourceDatadogSingleSignOnConfigurationsDelete(d *pluginsdk.ResourceData,
EnterpriseAppID: utils.String(enterpriseAppID),
},
}
if _, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.MonitorName, id.SingleSignOnConfigurationName, &body); err != nil {

future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.MonitorName, id.SingleSignOnConfigurationName, &body)
if err != nil {
return fmt.Errorf("removing SingleSignOnConfiguration on Datadog Monitor %q (Resource Group %q): %+v", id.MonitorName, id.ResourceGroup, err)
}

if err = future.WaitForCompletionRef(ctx, client.Client); err != nil {
return fmt.Errorf("waiting on removing SingleSignOnConfiguration on Datadog Monitor %s: %+v", id, err)
}

return nil
}
13 changes: 7 additions & 6 deletions internal/services/orbital/contact_profile_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ func (r ContactProfileResource) Create() sdk.ResourceFunc {
Tags: &model.Tags,
}

if _, err := client.ContactProfilesCreateOrUpdate(ctx, id, contactProfile); err != nil {
if err := client.ContactProfilesCreateOrUpdateThenPoll(ctx, id, contactProfile); err != nil {
return fmt.Errorf("creating %s: %+v", id, err)
}

metadata.SetID(id)
return nil
},
Expand Down Expand Up @@ -216,11 +217,10 @@ func (r ContactProfileResource) Delete() sdk.ResourceFunc {

metadata.Logger.Infof("deleting %s", *id)

if resp, err := client.ContactProfilesDelete(ctx, *id); err != nil {
if !response.WasNotFound(resp.HttpResponse) {
return fmt.Errorf("deleting %s: %+v", *id, err)
}
if err := client.ContactProfilesDeleteThenPoll(ctx, *id); err != nil {
return fmt.Errorf("deleting %s: %+v", *id, err)
}

return nil
},
}
Expand Down Expand Up @@ -269,7 +269,8 @@ func (r ContactProfileResource) Update() sdk.ResourceFunc {
},
Tags: &state.Tags,
}
if _, err := client.ContactProfilesCreateOrUpdate(ctx, *id, contactProfile); err != nil {

if err := client.ContactProfilesCreateOrUpdateThenPoll(ctx, *id, contactProfile); err != nil {
return fmt.Errorf("updating %s: %+v", *id, err)
}
}
Expand Down
12 changes: 6 additions & 6 deletions internal/services/orbital/spacecraft_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (r SpacecraftResource) Create() sdk.ResourceFunc {
Properties: &spacecraftProperties,
Tags: &model.Tags,
}
if _, err = client.CreateOrUpdate(ctx, id, spacecraft); err != nil {
if err = client.CreateOrUpdateThenPoll(ctx, id, spacecraft); err != nil {
return fmt.Errorf("creating %s: %+v", id, err)
}
metadata.SetID(id)
Expand Down Expand Up @@ -191,11 +191,10 @@ func (r SpacecraftResource) Delete() sdk.ResourceFunc {

metadata.Logger.Infof("deleting %s", *id)

if resp, err := client.Delete(ctx, *id); err != nil {
if !response.WasNotFound(resp.HttpResponse) {
return fmt.Errorf("deleting %s: %+v", *id, err)
}
if err := client.DeleteThenPoll(ctx, *id); err != nil {
return fmt.Errorf("deleting %s: %+v", *id, err)
}

return nil
},
}
Expand Down Expand Up @@ -237,7 +236,8 @@ func (r SpacecraftResource) Update() sdk.ResourceFunc {
},
Tags: &state.Tags,
}
if _, err := client.CreateOrUpdate(ctx, *id, spacecraft); err != nil {

if err := client.CreateOrUpdateThenPoll(ctx, *id, spacecraft); err != nil {
return fmt.Errorf("updating %s: %+v", *id, err)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,10 @@ func (r AppServiceConnectorResource) Delete() sdk.ResourceFunc {

metadata.Logger.Infof("deleting %s", *id)

if resp, err := client.LinkerDelete(ctx, *id); err != nil {
if !response.WasNotFound(resp.HttpResponse) {
return fmt.Errorf("deleting %s: %+v", *id, err)
}
if err := client.LinkerDeleteThenPoll(ctx, *id); err != nil {
return fmt.Errorf("deleting %s: %+v", *id, err)
}

return nil
},
}
Expand Down Expand Up @@ -274,9 +273,10 @@ func (r AppServiceConnectorResource) Update() sdk.ResourceFunc {
Properties: &linkerProps,
}

if _, err := client.LinkerUpdate(ctx, *id, props); err != nil {
if err := client.LinkerUpdateThenPoll(ctx, *id, props); err != nil {
return fmt.Errorf("updating %s: %+v", *id, err)
}

return nil
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,10 @@ func (r SpringCloudConnectorResource) Delete() sdk.ResourceFunc {

metadata.Logger.Infof("deleting %s", *id)

if resp, err := client.LinkerDelete(ctx, *id); err != nil {
if !response.WasNotFound(resp.HttpResponse) {
return fmt.Errorf("deleting %s: %+v", *id, err)
}
if err := client.LinkerDeleteThenPoll(ctx, *id); err != nil {
return fmt.Errorf("deleting %s: %+v", *id, err)
}

return nil
},
}
Expand Down Expand Up @@ -275,7 +274,7 @@ func (r SpringCloudConnectorResource) Update() sdk.ResourceFunc {
Properties: &linkerProps,
}

if _, err := client.LinkerUpdate(ctx, *id, props); err != nil {
if err := client.LinkerUpdateThenPoll(ctx, *id, props); err != nil {
return fmt.Errorf("updating %s: %+v", *id, err)
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,10 @@ func (r ClusterResource) Delete() sdk.ResourceFunc {

metadata.Logger.Infof("deleting %s", *id)

if resp, err := client.Delete(ctx, *id); err != nil {
if !response.WasNotFound(resp.HttpResponse) {
return fmt.Errorf("deleting %s: %+v", *id, err)
}
if err := client.DeleteThenPoll(ctx, *id); err != nil {
return fmt.Errorf("deleting %s: %+v", *id, err)
}

return nil
},
}
Expand Down

0 comments on commit 4cc9fce

Please sign in to comment.