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

Add L7 ILB fields to RegionBackendService #2547

Merged
merged 2 commits into from
Nov 5, 2019
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
2 changes: 1 addition & 1 deletion build/ansible
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
2 changes: 1 addition & 1 deletion build/terraform-mapper
551 changes: 475 additions & 76 deletions products/compute/api.yaml

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,20 @@ overrides: !ruby/object:Overrides::ResourceOverrides
vars:
region_backend_service_name: "region-backend-service"
health_check_name: "health-check"
- !ruby/object:Provider::Terraform::Examples
name: "region_backend_service_ilb_round_robin"
min_version: beta
primary_resource_id: "default"
vars:
region_backend_service_name: "region-backend-service"
health_check_name: "health-check"
- !ruby/object:Provider::Terraform::Examples
name: "region_backend_service_ilb_ring_hash"
min_version: beta
primary_resource_id: "default"
vars:
region_backend_service_name: "region-backend-service"
health_check_name: "health-check"
custom_code: !ruby/object:Provider::Terraform::CustomCode
constants: 'templates/terraform/constants/migrate_state_noop.go.erb'
resource_definition: 'templates/terraform/resource_definition/region_backend_service.go.erb'
Expand All @@ -282,6 +296,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
backends.group: !ruby/object:Overrides::Terraform::PropertyOverride
diff_suppress_func: 'compareSelfLinkRelativePaths'
custom_flatten: templates/terraform/custom_flatten/guard_self_link.go.erb
backends.capacityScaler: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
connectionDraining: !ruby/object:Overrides::Terraform::PropertyOverride
flatten_object: true
connectionDraining.drainingTimeoutSec: !ruby/object:Overrides::Terraform::PropertyOverride
Expand All @@ -292,6 +308,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
is_set: true
set_hash_func: 'selfLinkRelativePathHash'
custom_flatten: templates/terraform/custom_flatten/guard_self_link_array.go.erb
id: !ruby/object:Overrides::Terraform::PropertyOverride
exclude: true
protocol: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
sessionAffinity: !ruby/object:Overrides::Terraform::PropertyOverride
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
resource "google_compute_region_backend_service" "<%= ctx[:primary_resource_id] %>" {
provider = "google-beta"

region = "us-central1"
name = "<%= ctx[:vars]['region_backend_service_name'] %>"
health_checks = ["${google_compute_health_check.health_check.self_link}"]
load_balancing_scheme = "INTERNAL_MANAGED"
locality_lb_policy = "RING_HASH"
session_affinity = "HTTP_COOKIE"
protocol = "HTTP"
circuit_breakers {
max_connections = 10
}
consistent_hash {
http_cookie {
ttl {
seconds = 11
nanos = 1111
}
name = "mycookie"
}
}
outlier_detection {
consecutive_errors = 2
}
}

resource "google_compute_health_check" "health_check" {
provider = "google-beta"

name = "<%= ctx[:vars]['health_check_name'] %>"
http_health_check {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "google_compute_region_backend_service" "<%= ctx[:primary_resource_id] %>" {
provider = "google-beta"

region = "us-central1"
name = "<%= ctx[:vars]['region_backend_service_name'] %>"
health_checks = ["${google_compute_health_check.health_check.self_link}"]
protocol = "HTTP"
load_balancing_scheme = "INTERNAL_MANAGED"
locality_lb_policy = "ROUND_ROBIN"
}

resource "google_compute_health_check" "health_check" {
provider = "google-beta"

name = "<%= ctx[:vars]['health_check_name'] %>"
http_health_check {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,280 @@ func TestAccComputeRegionBackendService_withConnectionDrainingAndUpdate(t *testi
})
}

<% unless version == 'ga' -%>
func TestAccComputeRegionBackendService_ilbUpdateBasic(t *testing.T) {
t.Parallel()

backendName := fmt.Sprintf("foo-%s", acctest.RandString(10))
checkName := fmt.Sprintf("bar-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeRegionBackendServiceDestroy,
Steps: []resource.TestStep{
{
Config: testAccComputeRegionBackendService_ilbBasic(backendName, checkName),
},
{
ResourceName: "google_compute_region_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeRegionBackendService_ilbUpdateBasic(backendName, checkName),
},
{
ResourceName: "google_compute_region_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
<% end -%>

<% unless version == 'ga' -%>
func TestAccComputeRegionBackendService_ilbUpdateFull(t *testing.T) {
t.Parallel()

randString := acctest.RandString(10)

backendName := fmt.Sprintf("foo-%s", randString)
checkName := fmt.Sprintf("bar-%s", randString)
igName := fmt.Sprintf("baz-%s", randString)
instanceName := fmt.Sprintf("boz-%s", randString)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeRegionBackendServiceDestroy,
Steps: []resource.TestStep{
{
Config: testAccComputeRegionBackendService_ilbFull(backendName, checkName),
},
{
ResourceName: "google_compute_region_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeRegionBackendService_ilbUpdateFull(backendName, igName, instanceName, checkName),
},
{
ResourceName: "google_compute_region_backend_service.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
<% end -%>

<% unless version == 'ga' -%>
func testAccComputeRegionBackendService_ilbBasic(serviceName, checkName string) string {
return fmt.Sprintf(`
resource "google_compute_region_backend_service" "foobar" {

name = "%s"
health_checks = ["${google_compute_health_check.health_check.self_link}"]
protocol = "HTTP"
load_balancing_scheme = "INTERNAL_MANAGED"
locality_lb_policy = "RING_HASH"
circuit_breakers {
max_connections = 10
}
consistent_hash {
http_cookie {
ttl {
seconds = 11
nanos = 1234
}
name = "mycookie"
}
}
outlier_detection {
consecutive_errors = 2
}
}

resource "google_compute_health_check" "health_check" {

name = "%s"
http_health_check {

}
}
`, serviceName, checkName)
}
<% end -%>

<% unless version == 'ga' -%>
func testAccComputeRegionBackendService_ilbUpdateBasic(serviceName, checkName string) string {
return fmt.Sprintf(`
resource "google_compute_region_backend_service" "foobar" {

name = "%s"
health_checks = ["${google_compute_health_check.health_check.self_link}"]
protocol = "HTTP"
load_balancing_scheme = "INTERNAL_MANAGED"
locality_lb_policy = "RANDOM"
circuit_breakers {
max_connections = 10
}
outlier_detection {
consecutive_errors = 2
}
}

resource "google_compute_health_check" "health_check" {

name = "%s"
http_health_check {

}
}
`, serviceName, checkName)
}
<% end -%>

<% unless version == 'ga' -%>
func testAccComputeRegionBackendService_ilbFull(serviceName, checkName string) string {
return fmt.Sprintf(`
resource "google_compute_region_backend_service" "foobar" {

name = "%s"
health_checks = ["${google_compute_health_check.health_check.self_link}"]
protocol = "HTTP"
load_balancing_scheme = "INTERNAL_MANAGED"
locality_lb_policy = "MAGLEV"
circuit_breakers {
max_connections = 10
}
consistent_hash {
http_cookie {
ttl {
seconds = 11
nanos = 1234
}
name = "mycookie"
}
}
outlier_detection {
consecutive_errors = 2
}
}

resource "google_compute_health_check" "health_check" {

name = "%s"
http_health_check {

}
}
`, serviceName, checkName)
}
<% end -%>

<% unless version == 'ga' -%>
func testAccComputeRegionBackendService_ilbUpdateFull(serviceName, igName, instanceName, checkName string) string {
return fmt.Sprintf(`
resource "google_compute_region_backend_service" "foobar" {

name = "%s"
health_checks = ["${google_compute_health_check.health_check.self_link}"]
protocol = "HTTP"
load_balancing_scheme = "INTERNAL_MANAGED"
locality_lb_policy = "MAGLEV"
backend {
balancing_mode = "UTILIZATION"
capacity_scaler = 0.5
description = "The backend"
group = google_compute_instance_group.group.self_link
max_rate = 6
max_utilization = 0.5
}
circuit_breakers {
connect_timeout {
seconds = 3
nanos = 4
}
max_connections = 11
max_requests_per_connection = 12
max_pending_requests = 13
max_requests = 14
max_retries = 15
}
consistent_hash {
http_cookie {
ttl {
seconds = 12
}
name = "mycookie2"
path = "mycookie2/path"
}
minimum_ring_size = 16
}
log_config {
enable = true
sample_rate = 0.5
}
outlier_detection {
base_ejection_time {
seconds = 0
nanos = 5
}
consecutive_errors = 1
consecutive_gateway_failure = 3
enforcing_consecutive_errors = 4
enforcing_consecutive_gateway_failure = 5
enforcing_success_rate = 6
interval {
seconds = 7
}
max_ejection_percent = 99
success_rate_minimum_hosts = 98
success_rate_request_volume = 97
success_rate_stdev_factor = 1800
}
}

resource "google_compute_instance_group" "group" {
name = "%s"
instances = [ "${google_compute_instance.ig_instance.self_link}" ]
}

data "google_compute_image" "my_image" {
family = "debian-9"
project = "debian-cloud"
}

resource "google_compute_instance" "ig_instance" {
name = "%s"
machine_type = "n1-standard-1"

boot_disk {
initialize_params {
image = "${data.google_compute_image.my_image.self_link}"
}
}

network_interface {
network = "default"
}
}

resource "google_compute_health_check" "health_check" {

name = "%s"
http_health_check {

}
}
`, serviceName, igName, instanceName, checkName)
}
<% end -%>

func testAccComputeRegionBackendService_basic(serviceName, checkName string) string {
return fmt.Sprintf(`
resource "google_compute_region_backend_service" "foobar" {
Expand Down