-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Adding the Match parameter to the Probes to check on the response code #1446
Changes from 1 commit
0906516
ebf4c1d
a5103a5
cdb8ff6
949e539
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -457,6 +457,29 @@ func resourceArmApplicationGateway() *schema.Resource { | |
Type: schema.TypeInt, | ||
Required: true, | ||
}, | ||
|
||
"match": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
MaxItems: 1, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"body": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Default: "*", | ||
}, | ||
|
||
"status_code": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. given this is a status code, can we make this a TypeInt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. People can specify status codes as ranges also like 200-300. |
||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -1162,6 +1185,21 @@ func expandApplicationGatewayProbes(d *schema.ResourceData) *[]network.Applicati | |
}, | ||
} | ||
|
||
if matchConfigs := data["match"].([]interface{}); matchConfigs != nil { | ||
match := matchConfigs[0].(map[string]interface{}) | ||
matchBody := match["body"].(string) | ||
|
||
statusCodes := []string{} | ||
for _, statusCode := range match["status_code"].([]interface{}) { | ||
|
||
statusCodes = append(statusCodes, statusCode.(string)) | ||
} | ||
setting.ApplicationGatewayProbePropertiesFormat.Match = &network.ApplicationGatewayProbeHealthResponseMatch{ | ||
Body: &matchBody, | ||
StatusCodes: &statusCodes, | ||
} | ||
} | ||
|
||
backendSettings = append(backendSettings, setting) | ||
} | ||
|
||
|
@@ -1608,6 +1646,20 @@ func flattenApplicationGatewayProbes(input *[]network.ApplicationGatewayProbe) [ | |
if threshold := props.UnhealthyThreshold; threshold != nil { | ||
settings["unhealthy_threshold"] = int(*threshold) | ||
} | ||
|
||
if match := props.Match; match != nil { | ||
|
||
matchConfig := map[string]interface{}{ | ||
"body": *match.Body, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's a potential crash here if
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Fixed it. |
||
} | ||
|
||
statusCodes := make([]interface{}, 0) | ||
for _, status := range *match.StatusCodes { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's a potential crash here if the API returns a bad response, can we make this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
statusCodes = append(statusCodes, status) | ||
} | ||
matchConfig["status_code"] = statusCodes | ||
settings["match"] = matchConfig | ||
} | ||
} | ||
|
||
result = append(result, settings) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -477,6 +477,16 @@ resource "azurerm_application_gateway" "test" { | |
timeout = 120 | ||
interval = 300 | ||
unhealthy_threshold = 8 | ||
match = { | ||
body = "*" | ||
status_code = [ | ||
200, | ||
203, | ||
202, | ||
] | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this is an optional block, can we add a test specifically for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added a separate test that verifies the presence of Match block in the probe is being set. |
||
|
||
|
||
} | ||
|
||
url_path_map { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also add documentation for this block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.