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

CD Pipeline 404 retry #4954

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
18 changes: 17 additions & 1 deletion ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"context"
"fmt"
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns"
Expand Down Expand Up @@ -591,7 +593,21 @@ func resourceIBMCdTektonPipelineRead(context context.Context, d *schema.Resource

getTektonPipelineOptions.SetID(d.Id())

tektonPipeline, response, err := cdTektonPipelineClient.GetTektonPipelineWithContext(context, getTektonPipelineOptions)
var tektonPipeline *cdtektonpipelinev2.TektonPipeline
var response *core.DetailedResponse
err = resource.RetryContext(context, 10*time.Second, func() *resource.RetryError {
tektonPipeline, response, err = cdTektonPipelineClient.GetTektonPipelineWithContext(context, getTektonPipelineOptions)
if err != nil || tektonPipeline == nil {
if response != nil && response.StatusCode == 404 {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
if conns.IsResourceTimeoutError(err) {
tektonPipeline, response, err = cdTektonPipelineClient.GetTektonPipelineWithContext(context, getTektonPipelineOptions)
}
if err != nil {
if response != nil && response.StatusCode == 404 {
d.SetId("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"context"
"fmt"
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns"
Expand Down Expand Up @@ -170,7 +172,21 @@ func resourceIBMCdTektonPipelineDefinitionRead(context context.Context, d *schem
getTektonPipelineDefinitionOptions.SetPipelineID(parts[0])
getTektonPipelineDefinitionOptions.SetDefinitionID(parts[1])

definition, response, err := cdTektonPipelineClient.GetTektonPipelineDefinitionWithContext(context, getTektonPipelineDefinitionOptions)
var definition *cdtektonpipelinev2.Definition
var response *core.DetailedResponse
err = resource.RetryContext(context, 10*time.Second, func() *resource.RetryError {
definition, response, err = cdTektonPipelineClient.GetTektonPipelineDefinitionWithContext(context, getTektonPipelineDefinitionOptions)
if err != nil || definition == nil {
if response != nil && response.StatusCode == 404 {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
if conns.IsResourceTimeoutError(err) {
definition, response, err = cdTektonPipelineClient.GetTektonPipelineDefinitionWithContext(context, getTektonPipelineDefinitionOptions)
}
if err != nil {
if response != nil && response.StatusCode == 404 {
d.SetId("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"context"
"fmt"
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns"
Expand Down Expand Up @@ -181,7 +183,21 @@ func resourceIBMCdTektonPipelinePropertyRead(context context.Context, d *schema.
getTektonPipelinePropertyOptions.SetPipelineID(parts[0])
getTektonPipelinePropertyOptions.SetPropertyName(parts[1])

property, response, err := cdTektonPipelineClient.GetTektonPipelinePropertyWithContext(context, getTektonPipelinePropertyOptions)
var property *cdtektonpipelinev2.Property
var response *core.DetailedResponse
err = resource.RetryContext(context, 10*time.Second, func() *resource.RetryError {
property, response, err = cdTektonPipelineClient.GetTektonPipelinePropertyWithContext(context, getTektonPipelinePropertyOptions)
if err != nil || property == nil {
if response != nil && response.StatusCode == 404 {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
if conns.IsResourceTimeoutError(err) {
property, response, err = cdTektonPipelineClient.GetTektonPipelinePropertyWithContext(context, getTektonPipelinePropertyOptions)
}
if err != nil {
if response != nil && response.StatusCode == 404 {
d.SetId("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import (
"fmt"
"log"
"sort"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns"
Expand Down Expand Up @@ -438,7 +440,21 @@ func resourceIBMCdTektonPipelineTriggerRead(context context.Context, d *schema.R
getTektonPipelineTriggerOptions.SetPipelineID(parts[0])
getTektonPipelineTriggerOptions.SetTriggerID(parts[1])

triggerIntf, response, err := cdTektonPipelineClient.GetTektonPipelineTriggerWithContext(context, getTektonPipelineTriggerOptions)
var triggerIntf cdtektonpipelinev2.TriggerIntf
var response *core.DetailedResponse
err = resource.RetryContext(context, 10*time.Second, func() *resource.RetryError {
triggerIntf, response, err = cdTektonPipelineClient.GetTektonPipelineTriggerWithContext(context, getTektonPipelineTriggerOptions)
if err != nil || triggerIntf == nil {
if response != nil && response.StatusCode == 404 {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
if conns.IsResourceTimeoutError(err) {
triggerIntf, response, err = cdTektonPipelineClient.GetTektonPipelineTriggerWithContext(context, getTektonPipelineTriggerOptions)
}
if err != nil {
if response != nil && response.StatusCode == 404 {
d.SetId("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"context"
"fmt"
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns"
Expand Down Expand Up @@ -199,7 +201,21 @@ func resourceIBMCdTektonPipelineTriggerPropertyRead(context context.Context, d *
getTektonPipelineTriggerPropertyOptions.SetTriggerID(parts[1])
getTektonPipelineTriggerPropertyOptions.SetPropertyName(parts[2])

triggerProperty, response, err := cdTektonPipelineClient.GetTektonPipelineTriggerPropertyWithContext(context, getTektonPipelineTriggerPropertyOptions)
var triggerProperty *cdtektonpipelinev2.TriggerProperty
var response *core.DetailedResponse
err = resource.RetryContext(context, 10*time.Second, func() *resource.RetryError {
triggerProperty, response, err = cdTektonPipelineClient.GetTektonPipelineTriggerPropertyWithContext(context, getTektonPipelineTriggerPropertyOptions)
if err != nil || triggerProperty == nil {
if response != nil && response.StatusCode == 404 {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
if conns.IsResourceTimeoutError(err) {
triggerProperty, response, err = cdTektonPipelineClient.GetTektonPipelineTriggerPropertyWithContext(context, getTektonPipelineTriggerPropertyOptions)
}
if err != nil {
if response != nil && response.StatusCode == 404 {
d.SetId("")
Expand Down
Loading