From c1c51929f6d348fe341136c3f69f7ff29727aa5e Mon Sep 17 00:00:00 2001 From: Akihiko Horiuchi <12ff5b8@gmail.com> Date: Mon, 19 Feb 2024 15:26:50 +0900 Subject: [PATCH] Add idle_timeout to Policy of Managed Load Balancer --- .../managed_load_balancer/v1/policies/doc.go | 4 +++ .../v1/policies/requests.go | 30 +++++++++++++++++++ .../v1/policies/results.go | 18 +++++++++++ .../v1/policies/testing/fixtures.go | 19 ++++++++++++ .../v1/policies/testing/requests_test.go | 4 +++ 5 files changed, 75 insertions(+) diff --git a/v2/ecl/managed_load_balancer/v1/policies/doc.go b/v2/ecl/managed_load_balancer/v1/policies/doc.go index fc217d1..28e6272 100644 --- a/v2/ecl/managed_load_balancer/v1/policies/doc.go +++ b/v2/ecl/managed_load_balancer/v1/policies/doc.go @@ -37,6 +37,7 @@ Example to create a policy Tags: tags, Algorithm: "round-robin", Persistence: "cookie", + IdleTimeout: 600, SorryPageUrl: "https://example.com/sorry", SourceNat: "enable", CertificateID: "f57a98fe-d63e-4048-93a0-51fe163f30d7", @@ -105,6 +106,7 @@ Example to create staged policy configurations createStagedOpts := policies.CreateStagedOpts{ Algorithm: "round-robin", Persistence: "cookie", + IdleTimeout: 600, SorryPageUrl: "https://example.com/sorry", SourceNat: "enable", CertificateID: "f57a98fe-d63e-4048-93a0-51fe163f30d7", @@ -136,6 +138,7 @@ Example to update staged policy configurations algorithm := "round-robin" persistence := "cookie" + idleTimeout := 600 sorryPageUrl := "https://example.com/sorry" sourceNat := "enable" certificateID := "f57a98fe-d63e-4048-93a0-51fe163f30d7" @@ -146,6 +149,7 @@ Example to update staged policy configurations updateStagedOpts := policies.UpdateStagedOpts{ Algorithm: &algorithm, Persistence: &persistence, + IdleTimeout: &idleTimeout, SorryPageUrl: &sorryPageUrl, SourceNat: &sourceNat, CertificateID: &certificateID, diff --git a/v2/ecl/managed_load_balancer/v1/policies/requests.go b/v2/ecl/managed_load_balancer/v1/policies/requests.go index b0fd81e..a8e1634 100644 --- a/v2/ecl/managed_load_balancer/v1/policies/requests.go +++ b/v2/ecl/managed_load_balancer/v1/policies/requests.go @@ -39,6 +39,9 @@ type ListOpts struct { // - Persistence setting of the policy Persistence string `q:"persistence"` + // - The duration (in seconds) during which a session is allowed to remain inactive + IdleTimeout int `q:"idle_timeout"` + // - URL of the sorry page to which accesses are redirected if all members in the target group are down SorryPageUrl string `q:"sorry_page_url"` @@ -126,6 +129,15 @@ type CreateOpts struct { // - If `listener.protocol` is `"http"` or `"https"`, `"cookie"` is available Persistence string `json:"persistence,omitempty"` + // - The duration (in seconds) during which a session is allowed to remain inactive + // - There may be a time difference up to 60 seconds, between the set value and the actual timeout + // - If `listener.protocol` is `"tcp"` or `"udp"` + // - Default value is 120 + // - If `listener.protocol` is `"http"` or `"https"` + // - Default value is 600 + // - On session timeout, the load balancer sends TCP RST packets to both the client and the real server + IdleTimeout int `json:"idle_timeout,omitempty"` + // - URL of the sorry page to which accesses are redirected if all members in the target group are down // - If `listener.protocol` is `"http"` or `"https"`, this parameter can be set // - If `listener.protocol` is neither `"http"` nor `"https"`, must not set this parameter or set `""` @@ -306,6 +318,15 @@ type CreateStagedOpts struct { // - If `listener.protocol` is `"http"` or `"https"`, `"cookie"` is available Persistence string `json:"persistence,omitempty"` + // - The duration (in seconds) during which a session is allowed to remain inactive + // - There may be a time difference up to 60 seconds, between the set value and the actual timeout + // - If `listener.protocol` is `"tcp"` or `"udp"` + // - Default value is 120 + // - If `listener.protocol` is `"http"` or `"https"` + // - Default value is 600 + // - On session timeout, the load balancer sends TCP RST packets to both the client and the real server + IdleTimeout int `json:"idle_timeout,omitempty"` + // - URL of the sorry page to which accesses are redirected if all members in the target group are down // - If `listener.protocol` is `"http"` or `"https"`, this parameter can be set // - If `listener.protocol` is neither `"http"` nor `"https"`, must not set this parameter or set `""` @@ -399,6 +420,15 @@ type UpdateStagedOpts struct { // - If `listener.protocol` is `"http"` or `"https"`, `"cookie"` is available Persistence *string `json:"persistence,omitempty"` + // - The duration (in seconds) during which a session is allowed to remain inactive + // - There may be a time difference up to 60 seconds, between the set value and the actual timeout + // - If `listener.protocol` is `"tcp"` or `"udp"` + // - Default value is 120 + // - If `listener.protocol` is `"http"` or `"https"` + // - Default value is 600 + // - On session timeout, the load balancer sends TCP RST packets to both the client and the real server + IdleTimeout *int `json:"idle_timeout,omitempty"` + // - URL of the sorry page to which accesses are redirected if all members in the target group are down // - If `listener.protocol` is `"http"` or `"https"`, this parameter can be set // - If `listener.protocol` is neither `"http"` nor `"https"`, must not set this parameter or set `""` diff --git a/v2/ecl/managed_load_balancer/v1/policies/results.go b/v2/ecl/managed_load_balancer/v1/policies/results.go index 9a3ad8f..7a345db 100644 --- a/v2/ecl/managed_load_balancer/v1/policies/results.go +++ b/v2/ecl/managed_load_balancer/v1/policies/results.go @@ -70,6 +70,15 @@ type ConfigurationInResponse struct { // - If `listener.protocol` is `"http"` or `"https"`, `"cookie"` is available Persistence string `json:"persistence,omitempty"` + // - The duration (in seconds) during which a session is allowed to remain inactive + // - There may be a time difference up to 60 seconds, between the set value and the actual timeout + // - If `listener.protocol` is `"tcp"` or `"udp"` + // - Default value is 120 + // - If `listener.protocol` is `"http"` or `"https"` + // - Default value is 600 + // - On session timeout, the load balancer sends TCP RST packets to both the client and the real server + IdleTimeout int `json:"idle_timeout,omitempty"` + // - URL of the sorry page to which accesses are redirected if all members in the target group are down // - If protocol is not `"http"` or `"https"`, returns `""` SorryPageUrl string `json:"sorry_page_url,omitempty"` @@ -157,6 +166,15 @@ type Policy struct { // - If `listener.protocol` is `"http"` or `"https"`, `"cookie"` is available Persistence string `json:"persistence,omitempty"` + // - The duration (in seconds) during which a session is allowed to remain inactive + // - There may be a time difference up to 60 seconds, between the set value and the actual timeout + // - If `listener.protocol` is `"tcp"` or `"udp"` + // - Default value is 120 + // - If `listener.protocol` is `"http"` or `"https"` + // - Default value is 600 + // - On session timeout, the load balancer sends TCP RST packets to both the client and the real server + IdleTimeout int `json:"idle_timeout,omitempty"` + // - URL of the sorry page to which accesses are redirected if all members in the target group are down // - If protocol is not `"http"` or `"https"`, returns `""` SorryPageUrl string `json:"sorry_page_url,omitempty"` diff --git a/v2/ecl/managed_load_balancer/v1/policies/testing/fixtures.go b/v2/ecl/managed_load_balancer/v1/policies/testing/fixtures.go index d21e388..ad4dc1d 100644 --- a/v2/ecl/managed_load_balancer/v1/policies/testing/fixtures.go +++ b/v2/ecl/managed_load_balancer/v1/policies/testing/fixtures.go @@ -28,6 +28,7 @@ var listResponse = fmt.Sprintf(` "tenant_id": "34f5c98ef430457ba81292637d0c6fd0", "algorithm": "round-robin", "persistence": "cookie", + "idle_timeout": 600, "sorry_page_url": "https://example.com/sorry", "source_nat": "enable", "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7", @@ -59,6 +60,7 @@ func listResult() []policies.Policy { policy1.TenantID = "34f5c98ef430457ba81292637d0c6fd0" policy1.Algorithm = "round-robin" policy1.Persistence = "cookie" + policy1.IdleTimeout = 600 policy1.SorryPageUrl = "https://example.com/sorry" policy1.SourceNat = "enable" policy1.CertificateID = "f57a98fe-d63e-4048-93a0-51fe163f30d7" @@ -80,6 +82,7 @@ var createRequest = fmt.Sprintf(` }, "algorithm": "round-robin", "persistence": "cookie", + "idle_timeout": 600, "sorry_page_url": "https://example.com/sorry", "source_nat": "enable", "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7", @@ -106,6 +109,7 @@ var createResponse = fmt.Sprintf(` "tenant_id": "34f5c98ef430457ba81292637d0c6fd0", "algorithm": null, "persistence": null, + "idle_timeout": null, "sorry_page_url": null, "source_nat": null, "certificate_id": null, @@ -136,6 +140,7 @@ func createResult() *policies.Policy { policy.TenantID = "34f5c98ef430457ba81292637d0c6fd0" policy.Algorithm = "" policy.Persistence = "" + policy.IdleTimeout = 0 policy.SorryPageUrl = "" policy.SourceNat = "" policy.CertificateID = "" @@ -162,6 +167,7 @@ var showResponse = fmt.Sprintf(` "tenant_id": "34f5c98ef430457ba81292637d0c6fd0", "algorithm": "round-robin", "persistence": "cookie", + "idle_timeout": 600, "sorry_page_url": "https://example.com/sorry", "source_nat": "enable", "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7", @@ -172,6 +178,7 @@ var showResponse = fmt.Sprintf(` "current": { "algorithm": "round-robin", "persistence": "cookie", + "idle_timeout": 600, "sorry_page_url": "https://example.com/sorry", "source_nat": "enable", "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7", @@ -191,6 +198,7 @@ func showResult() *policies.Policy { current := policies.ConfigurationInResponse{ Algorithm: "round-robin", Persistence: "cookie", + IdleTimeout: 600, SorryPageUrl: "https://example.com/sorry", SourceNat: "enable", CertificateID: "f57a98fe-d63e-4048-93a0-51fe163f30d7", @@ -217,6 +225,7 @@ func showResult() *policies.Policy { policy.TenantID = "34f5c98ef430457ba81292637d0c6fd0" policy.Algorithm = "round-robin" policy.Persistence = "cookie" + policy.IdleTimeout = 600 policy.SorryPageUrl = "https://example.com/sorry" policy.SourceNat = "enable" policy.CertificateID = "f57a98fe-d63e-4048-93a0-51fe163f30d7" @@ -256,6 +265,7 @@ var updateResponse = fmt.Sprintf(` "tenant_id": "34f5c98ef430457ba81292637d0c6fd0", "algorithm": null, "persistence": null, + "idle_timeout": null, "sorry_page_url": null, "source_nat": null, "certificate_id": null, @@ -286,6 +296,7 @@ func updateResult() *policies.Policy { policy.TenantID = "34f5c98ef430457ba81292637d0c6fd0" policy.Algorithm = "" policy.Persistence = "" + policy.IdleTimeout = 0 policy.SorryPageUrl = "" policy.SourceNat = "" policy.CertificateID = "" @@ -302,6 +313,7 @@ var createStagedRequest = fmt.Sprintf(` "policy": { "algorithm": "round-robin", "persistence": "cookie", + "idle_timeout": 600, "sorry_page_url": "https://example.com/sorry", "source_nat": "enable", "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7", @@ -317,6 +329,7 @@ var createStagedResponse = fmt.Sprintf(` "policy": { "algorithm": "round-robin", "persistence": "cookie", + "idle_timeout": 600, "sorry_page_url": "https://example.com/sorry", "source_nat": "enable", "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7", @@ -332,6 +345,7 @@ func createStagedResult() *policies.Policy { policy.Algorithm = "round-robin" policy.Persistence = "cookie" + policy.IdleTimeout = 600 policy.SorryPageUrl = "https://example.com/sorry" policy.SourceNat = "enable" policy.CertificateID = "f57a98fe-d63e-4048-93a0-51fe163f30d7" @@ -348,6 +362,7 @@ var showStagedResponse = fmt.Sprintf(` "policy": { "algorithm": "round-robin", "persistence": "cookie", + "idle_timeout": 600, "sorry_page_url": "https://example.com/sorry", "source_nat": "enable", "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7", @@ -363,6 +378,7 @@ func showStagedResult() *policies.Policy { policy.Algorithm = "round-robin" policy.Persistence = "cookie" + policy.IdleTimeout = 600 policy.SorryPageUrl = "https://example.com/sorry" policy.SourceNat = "enable" policy.CertificateID = "f57a98fe-d63e-4048-93a0-51fe163f30d7" @@ -379,6 +395,7 @@ var updateStagedRequest = fmt.Sprintf(` "policy": { "algorithm": "round-robin", "persistence": "cookie", + "idle_timeout": 600, "sorry_page_url": "https://example.com/sorry", "source_nat": "enable", "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7", @@ -394,6 +411,7 @@ var updateStagedResponse = fmt.Sprintf(` "policy": { "algorithm": "round-robin", "persistence": "cookie", + "idle_timeout": 600, "sorry_page_url": "https://example.com/sorry", "source_nat": "enable", "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7", @@ -409,6 +427,7 @@ func updateStagedResult() *policies.Policy { policy.Algorithm = "round-robin" policy.Persistence = "cookie" + policy.IdleTimeout = 600 policy.SorryPageUrl = "https://example.com/sorry" policy.SourceNat = "enable" policy.CertificateID = "f57a98fe-d63e-4048-93a0-51fe163f30d7" diff --git a/v2/ecl/managed_load_balancer/v1/policies/testing/requests_test.go b/v2/ecl/managed_load_balancer/v1/policies/testing/requests_test.go index 4e61f8b..3f97b16 100644 --- a/v2/ecl/managed_load_balancer/v1/policies/testing/requests_test.go +++ b/v2/ecl/managed_load_balancer/v1/policies/testing/requests_test.go @@ -97,6 +97,7 @@ func TestCreatePolicy(t *testing.T) { Tags: tags, Algorithm: "round-robin", Persistence: "cookie", + IdleTimeout: 600, SorryPageUrl: "https://example.com/sorry", SourceNat: "enable", CertificateID: "f57a98fe-d63e-4048-93a0-51fe163f30d7", @@ -223,6 +224,7 @@ func TestCreateStagedPolicy(t *testing.T) { createStagedOpts := policies.CreateStagedOpts{ Algorithm: "round-robin", Persistence: "cookie", + IdleTimeout: 600, SorryPageUrl: "https://example.com/sorry", SourceNat: "enable", CertificateID: "f57a98fe-d63e-4048-93a0-51fe163f30d7", @@ -284,6 +286,7 @@ func TestUpdateStagedPolicy(t *testing.T) { algorithm := "round-robin" persistence := "cookie" + idleTimeout := 600 sorryPageUrl := "https://example.com/sorry" sourceNat := "enable" certificateID := "f57a98fe-d63e-4048-93a0-51fe163f30d7" @@ -294,6 +297,7 @@ func TestUpdateStagedPolicy(t *testing.T) { updateStagedOpts := policies.UpdateStagedOpts{ Algorithm: &algorithm, Persistence: &persistence, + IdleTimeout: &idleTimeout, SorryPageUrl: &sorryPageUrl, SourceNat: &sourceNat, CertificateID: &certificateID,