Skip to content

Commit 147fffe

Browse files
committed
LoadBalancer V2: add monitor body MaxRetriesDown
Add loadbalancer/v2/monitors.Monitor.MaxRetriesDown. Update tests and docs.
1 parent f5ebf69 commit 147fffe

4 files changed

Lines changed: 54 additions & 34 deletions

File tree

acceptance/openstack/loadbalancer/v2/loadbalancer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ func CreateMonitor(t *testing.T, client *gophercloud.ServiceClient, lb *loadbala
169169

170170
th.AssertEquals(t, monitor.Name, monitorName)
171171
th.AssertEquals(t, monitor.Type, monitors.TypePING)
172+
th.AssertEquals(t, monitor.Delay, 10)
173+
th.AssertEquals(t, monitor.Timeout, 5)
174+
th.AssertEquals(t, monitor.MaxRetries, 5)
175+
th.AssertEquals(t, monitor.MaxRetriesDown, 4)
172176

173177
return monitor, nil
174178
}

acceptance/openstack/loadbalancer/v2/loadbalancers_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ func TestLoadbalancersCRUD(t *testing.T) {
406406

407407
th.AssertEquals(t, newMonitor.Name, monName)
408408
th.AssertEquals(t, newMonitor.Delay, newDelay)
409+
th.AssertEquals(t, newMonitor.MaxRetriesDown, newMaxRetriesDown)
409410
}
410411

411412
func TestLoadbalancersCascadeCRUD(t *testing.T) {
@@ -508,8 +509,10 @@ func TestLoadbalancersCascadeCRUD(t *testing.T) {
508509
th.AssertNoErr(t, err)
509510

510511
newDelay := tools.RandomInt(20, 30)
512+
newMaxRetriesDown := tools.RandomInt(4, 10)
511513
updateMonitorOpts := monitors.UpdateOpts{
512-
Delay: newDelay,
514+
Delay: newDelay,
515+
MaxRetriesDown: newMaxRetriesDown,
513516
}
514517
_, err = monitors.Update(lbClient, monitor.ID, updateMonitorOpts).Extract()
515518
th.AssertNoErr(t, err)
@@ -523,4 +526,6 @@ func TestLoadbalancersCascadeCRUD(t *testing.T) {
523526

524527
tools.PrintResource(t, newMonitor)
525528

529+
th.AssertEquals(t, newMonitor.Delay, newDelay)
530+
th.AssertEquals(t, newMonitor.MaxRetriesDown, newMaxRetriesDown)
526531
}

openstack/loadbalancer/v2/monitors/results.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ type Monitor struct {
5050
// member to INACTIVE. A valid value is from 1 to 10.
5151
MaxRetries int `json:"max_retries"`
5252

53+
// Number of allowed connection failures before changing the status of the
54+
// member to Error. A valid value is from 1 to 10.
55+
MaxRetriesDown int `json:"max_retries_down"`
56+
5357
// The HTTP method that the monitor uses for requests.
5458
HTTPMethod string `json:"http_method"`
5559

openstack/loadbalancer/v2/monitors/testing/fixtures.go

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const HealthmonitorsListBody = `
2020
"delay":10,
2121
"name":"web",
2222
"max_retries":1,
23+
"max_retries_down":7,
2324
"timeout":1,
2425
"type":"PING",
2526
"pools": [{"id": "84f1b61f-58c4-45bf-a8a9-2dafb9e5214d"}],
@@ -32,6 +33,7 @@ const HealthmonitorsListBody = `
3233
"name":"db",
3334
"expected_codes":"200",
3435
"max_retries":2,
36+
"max_retries_down":4,
3537
"http_method":"GET",
3638
"timeout":2,
3739
"url_path":"/",
@@ -53,6 +55,7 @@ const SingleHealthmonitorBody = `
5355
"name":"db",
5456
"expected_codes":"200",
5557
"max_retries":2,
58+
"max_retries_down":4,
5659
"http_method":"GET",
5760
"timeout":2,
5861
"url_path":"/",
@@ -73,6 +76,7 @@ const PostUpdateHealthmonitorBody = `
7376
"name":"NewHealthmonitorName",
7477
"expected_codes":"301",
7578
"max_retries":10,
79+
"max_retries_down":8,
7680
"http_method":"GET",
7781
"timeout":20,
7882
"url_path":"/another_check",
@@ -85,43 +89,46 @@ const PostUpdateHealthmonitorBody = `
8589

8690
var (
8791
HealthmonitorWeb = monitors.Monitor{
88-
AdminStateUp: true,
89-
Name: "web",
90-
ProjectID: "83657cfcdfe44cd5920adaf26c48ceea",
91-
Delay: 10,
92-
MaxRetries: 1,
93-
Timeout: 1,
94-
Type: "PING",
95-
ID: "466c8345-28d8-4f84-a246-e04380b0461d",
96-
Pools: []monitors.PoolID{{ID: "84f1b61f-58c4-45bf-a8a9-2dafb9e5214d"}},
92+
AdminStateUp: true,
93+
Name: "web",
94+
ProjectID: "83657cfcdfe44cd5920adaf26c48ceea",
95+
Delay: 10,
96+
MaxRetries: 1,
97+
MaxRetriesDown: 7,
98+
Timeout: 1,
99+
Type: "PING",
100+
ID: "466c8345-28d8-4f84-a246-e04380b0461d",
101+
Pools: []monitors.PoolID{{ID: "84f1b61f-58c4-45bf-a8a9-2dafb9e5214d"}},
97102
}
98103
HealthmonitorDb = monitors.Monitor{
99-
AdminStateUp: true,
100-
Name: "db",
101-
ProjectID: "83657cfcdfe44cd5920adaf26c48ceea",
102-
Delay: 5,
103-
ExpectedCodes: "200",
104-
MaxRetries: 2,
105-
Timeout: 2,
106-
URLPath: "/",
107-
Type: "HTTP",
108-
HTTPMethod: "GET",
109-
ID: "5d4b5228-33b0-4e60-b225-9b727c1a20e7",
110-
Pools: []monitors.PoolID{{ID: "d459f7d8-c6ee-439d-8713-d3fc08aeed8d"}},
104+
AdminStateUp: true,
105+
Name: "db",
106+
ProjectID: "83657cfcdfe44cd5920adaf26c48ceea",
107+
Delay: 5,
108+
ExpectedCodes: "200",
109+
MaxRetries: 2,
110+
MaxRetriesDown: 4,
111+
Timeout: 2,
112+
URLPath: "/",
113+
Type: "HTTP",
114+
HTTPMethod: "GET",
115+
ID: "5d4b5228-33b0-4e60-b225-9b727c1a20e7",
116+
Pools: []monitors.PoolID{{ID: "d459f7d8-c6ee-439d-8713-d3fc08aeed8d"}},
111117
}
112118
HealthmonitorUpdated = monitors.Monitor{
113-
AdminStateUp: true,
114-
Name: "NewHealthmonitorName",
115-
ProjectID: "83657cfcdfe44cd5920adaf26c48ceea",
116-
Delay: 3,
117-
ExpectedCodes: "301",
118-
MaxRetries: 10,
119-
Timeout: 20,
120-
URLPath: "/another_check",
121-
Type: "HTTP",
122-
HTTPMethod: "GET",
123-
ID: "5d4b5228-33b0-4e60-b225-9b727c1a20e7",
124-
Pools: []monitors.PoolID{{ID: "d459f7d8-c6ee-439d-8713-d3fc08aeed8d"}},
119+
AdminStateUp: true,
120+
Name: "NewHealthmonitorName",
121+
ProjectID: "83657cfcdfe44cd5920adaf26c48ceea",
122+
Delay: 3,
123+
ExpectedCodes: "301",
124+
MaxRetries: 10,
125+
MaxRetriesDown: 8,
126+
Timeout: 20,
127+
URLPath: "/another_check",
128+
Type: "HTTP",
129+
HTTPMethod: "GET",
130+
ID: "5d4b5228-33b0-4e60-b225-9b727c1a20e7",
131+
Pools: []monitors.PoolID{{ID: "d459f7d8-c6ee-439d-8713-d3fc08aeed8d"}},
125132
}
126133
)
127134

0 commit comments

Comments
 (0)