provider/scaleway: work around API concurrency issue (#12707)
when creating IPs concurrently the Scaleway API starts to return 500 internal server errors. since the error goes away when limiting concurrent requests, as well as the fact that the golang net/http client is safe for concurrent use, I'm assuming this is an API error on Scaleways side. this CS introduces a workaround so terraform does not crash for now. the work around needs to be removed once Scaleway fixes their API
This commit is contained in:
parent
8ccd38013e
commit
fcaafee06b
|
@ -2,6 +2,7 @@ package scaleway
|
|||
|
||||
import (
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/scaleway/scaleway-cli/pkg/api"
|
||||
|
@ -30,8 +31,12 @@ func resourceScalewayIP() *schema.Resource {
|
|||
}
|
||||
}
|
||||
|
||||
var mu = sync.Mutex{}
|
||||
|
||||
func resourceScalewayIPCreate(d *schema.ResourceData, m interface{}) error {
|
||||
scaleway := m.(*Client).scaleway
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
resp, err := scaleway.NewIP()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -8,6 +8,23 @@ import (
|
|||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccScalewayIP_Count(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckScalewayIPDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccCheckScalewayIPConfig_Count,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckScalewayIPExists("scaleway_ip.base.0"),
|
||||
testAccCheckScalewayIPExists("scaleway_ip.base.1"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccScalewayIP_Basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -129,6 +146,12 @@ resource "scaleway_ip" "base" {
|
|||
}
|
||||
`
|
||||
|
||||
var testAccCheckScalewayIPConfig_Count = `
|
||||
resource "scaleway_ip" "base" {
|
||||
count = 2
|
||||
}
|
||||
`
|
||||
|
||||
var testAccCheckScalewayIPAttachConfig = fmt.Sprintf(`
|
||||
resource "scaleway_server" "base" {
|
||||
name = "test"
|
||||
|
|
Loading…
Reference in New Issue