Skip to content

Commit 51e9551

Browse files
committed
LoadBalancer V2: add monitor Create MaxRetriesDown
Add loadbalancer/v2/monitors.CreateOpts.MaxRetriesDown. Update tests and docs.
1 parent 794fbdb commit 51e9551

5 files changed

Lines changed: 31 additions & 23 deletions

File tree

acceptance/openstack/loadbalancer/v2/loadbalancer.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,13 @@ func CreateMonitor(t *testing.T, client *gophercloud.ServiceClient, lb *loadbala
147147
t.Logf("Attempting to create monitor %s", monitorName)
148148

149149
createOpts := monitors.CreateOpts{
150-
PoolID: pool.ID,
151-
Name: monitorName,
152-
Delay: 10,
153-
Timeout: 5,
154-
MaxRetries: 5,
155-
Type: monitors.TypePING,
150+
PoolID: pool.ID,
151+
Name: monitorName,
152+
Delay: 10,
153+
Timeout: 5,
154+
MaxRetries: 5,
155+
MaxRetriesDown: 4,
156+
Type: monitors.TypePING,
156157
}
157158

158159
monitor, err := monitors.Create(client, createOpts).Extract()

openstack/loadbalancer/v2/monitors/doc.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ Example to List Monitors
2525
Example to Create a Monitor
2626
2727
createOpts := monitors.CreateOpts{
28-
Type: "HTTP",
29-
Name: "db",
30-
PoolID: "84f1b61f-58c4-45bf-a8a9-2dafb9e5214d",
31-
Delay: 20,
32-
Timeout: 10,
33-
MaxRetries: 5,
34-
URLPath: "/check",
35-
ExpectedCodes: "200-299",
28+
Type: "HTTP",
29+
Name: "db",
30+
PoolID: "84f1b61f-58c4-45bf-a8a9-2dafb9e5214d",
31+
Delay: 20,
32+
Timeout: 10,
33+
MaxRetries: 5,
34+
MaxRetriesDown: 4,
35+
URLPath: "/check",
36+
ExpectedCodes: "200-299",
3637
}
3738
3839
monitor, err := monitors.Create(networkClient, createOpts).Extract()

openstack/loadbalancer/v2/monitors/requests.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ type CreateOpts struct {
107107
// status to INACTIVE. Must be a number between 1 and 10.
108108
MaxRetries int `json:"max_retries" required:"true"`
109109

110+
// Number of permissible ping failures befor changing the member's
111+
// status to ERROR. Must be a number between 1 and 10.
112+
MaxRetriesDown int `json:"max_retries_down,omitempty"`
113+
110114
// URI path that will be accessed if Monitor type is HTTP or HTTPS.
111115
URLPath string `json:"url_path,omitempty"`
112116

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ func HandleHealthmonitorCreationSuccessfully(t *testing.T, response string) {
160160
"name":"db",
161161
"timeout":10,
162162
"max_retries":5,
163+
"max_retries_down":4,
163164
"url_path":"/check",
164165
"expected_codes":"200-299"
165166
}

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,16 @@ func TestCreateHealthmonitor(t *testing.T) {
5858
HandleHealthmonitorCreationSuccessfully(t, SingleHealthmonitorBody)
5959

6060
actual, err := monitors.Create(fake.ServiceClient(), monitors.CreateOpts{
61-
Type: "HTTP",
62-
Name: "db",
63-
PoolID: "84f1b61f-58c4-45bf-a8a9-2dafb9e5214d",
64-
ProjectID: "453105b9-1754-413f-aab1-55f1af620750",
65-
Delay: 20,
66-
Timeout: 10,
67-
MaxRetries: 5,
68-
URLPath: "/check",
69-
ExpectedCodes: "200-299",
61+
Type: "HTTP",
62+
Name: "db",
63+
PoolID: "84f1b61f-58c4-45bf-a8a9-2dafb9e5214d",
64+
ProjectID: "453105b9-1754-413f-aab1-55f1af620750",
65+
Delay: 20,
66+
Timeout: 10,
67+
MaxRetries: 5,
68+
MaxRetriesDown: 4,
69+
URLPath: "/check",
70+
ExpectedCodes: "200-299",
7071
}).Extract()
7172
th.AssertNoErr(t, err)
7273

0 commit comments

Comments
 (0)