Skip to content
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

Fix grpc healthcheck behaviour. #3883

Merged
merged 1 commit into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions templates/terraform/encoders/health_check_type.erb
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,19 @@ if _, ok := d.GetOk("ssl_health_check"); ok {
return obj, nil
}

if _, ok := d.GetOk("grpc_health_check"); ok {
hc := d.Get("grpc_health_check").([]interface{})[0]
ps := hc.(map[string]interface{})["port_specification"]
pn := hc.(map[string]interface{})["port_name"]

if ps == "USE_FIXED_PORT" || (ps == "" && pn == "") {
m := obj["grpcHealthCheck"].(map[string]interface{})
if m["port"] == nil {
return nil, fmt.Errorf("error in HealthCheck %s: `port` must be set for GRPC health checks`.", d.Get("name").(string))
}
}
obj["type"] = "GRPC"
return obj, nil
}

return nil, fmt.Errorf("error in HealthCheck %s: No health check block specified.", d.Get("name").(string))
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func TestAccComputeHealthCheck_tcpAndSsl_shouldFail(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccComputeHealthCheck_tcpAndSsl_shouldFail(hckName),
ExpectError: regexp.MustCompile("only one of `http2_health_check,http_health_check,https_health_check,ssl_health_check,tcp_health_check` can be specified"),
ExpectError: regexp.MustCompile("only one of `grpc_health_check,http2_health_check,http_health_check,https_health_check,ssl_health_check,tcp_health_check` can be specified"),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func TestAccComputeRegionHealthCheck_tcpAndSsl_shouldFail(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccComputeRegionHealthCheck_tcpAndSsl_shouldFail(hckName),
ExpectError: regexp.MustCompile("only one of `http2_health_check,http_health_check,https_health_check,ssl_health_check,tcp_health_check` can be specified"),
ExpectError: regexp.MustCompile("only one of `grpc_health_check,http2_health_check,http_health_check,https_health_check,ssl_health_check,tcp_health_check` can be specified"),
},
},
})
Expand Down