mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #94180 from feiskyer/fix-backoff
Ensure backoff step is set to 1 for Azure armclient
This commit is contained in:
commit
54f3b85dc7
@ -64,10 +64,11 @@ func New(authorizer autorest.Authorizer, baseURI, userAgent, apiVersion, clientR
|
|||||||
|
|
||||||
backoff := clientBackoff
|
backoff := clientBackoff
|
||||||
if backoff == nil {
|
if backoff == nil {
|
||||||
|
backoff = &retry.Backoff{}
|
||||||
|
}
|
||||||
|
if backoff.Steps == 0 {
|
||||||
// 1 steps means no retry.
|
// 1 steps means no retry.
|
||||||
backoff = &retry.Backoff{
|
backoff.Steps = 1
|
||||||
Steps: 1,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Client{
|
return &Client{
|
||||||
|
@ -36,6 +36,22 @@ const (
|
|||||||
testResourceID = "/subscriptions/subscription/resourceGroups/rg/providers/Microsoft.Network/publicIPAddresses/testPIP"
|
testResourceID = "/subscriptions/subscription/resourceGroups/rg/providers/Microsoft.Network/publicIPAddresses/testPIP"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestNew(t *testing.T) {
|
||||||
|
backoff := &retry.Backoff{Steps: 3}
|
||||||
|
armClient := New(nil, "", "test", "2019-01-01", "eastus", backoff)
|
||||||
|
assert.NotNil(t, armClient.backoff)
|
||||||
|
assert.Equal(t, 3, armClient.backoff.Steps, "Backoff steps should be same as the value passed in")
|
||||||
|
|
||||||
|
backoff = &retry.Backoff{Steps: 0}
|
||||||
|
armClient = New(nil, "", "test", "2019-01-01", "eastus", backoff)
|
||||||
|
assert.NotNil(t, armClient.backoff)
|
||||||
|
assert.Equal(t, 1, armClient.backoff.Steps, "Backoff steps should be default to 1 if it is 0")
|
||||||
|
|
||||||
|
armClient = New(nil, "", "test", "2019-01-01", "eastus", nil)
|
||||||
|
assert.NotNil(t, armClient.backoff)
|
||||||
|
assert.Equal(t, 1, armClient.backoff.Steps, "Backoff steps should be default to 1 if it is not set")
|
||||||
|
}
|
||||||
|
|
||||||
func TestSend(t *testing.T) {
|
func TestSend(t *testing.T) {
|
||||||
count := 0
|
count := 0
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
Loading…
Reference in New Issue
Block a user