Skip to content

Commit

Permalink
feat(load_balancer): HTTP/2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
villevsv-upcloud committed Nov 14, 2023
1 parent 0cee563 commit 0edbc78
Show file tree
Hide file tree
Showing 10 changed files with 1,431 additions and 759 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)

### Added
- Managed Load Balancer: `TLSConfigs` field to `LoadBalancerBackend` to control backend TLS configurations
- Managed Load Balancer: `TLSEnabled`, `TLSUseSystemCA`, `TLSVerify` & `HTTP2Enabled` fields to `LoadBalancerBackendProperties`
- Managed Load Balancer: `HTTP2Enabled` field to `LoadBalancerFrontendProperties`

### Changed
- **Breaking**, Managed Load Balancer: `InboundProxyProtocol` field to a boolean pointer in `LoadBalancerFrontendProperties`

## [6.9.0]
### Added
Expand Down
9 changes: 7 additions & 2 deletions upcloud/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ type LoadBalancerFrontendTLSConfig struct {

// LoadBalancerFrontendProperties represents frontend properties
type LoadBalancerFrontendProperties struct {
TimeoutClient int `json:"timeout_client,omitempty"`
InboundProxyProtocol bool `json:"inbound_proxy_protocol"`
TimeoutClient int `json:"timeout_client,omitempty"`
InboundProxyProtocol *bool `json:"inbound_proxy_protocol,omitempty"`
HTTP2Enabled *bool `json:"http2_enabled,omitempty"`
}

// LoadBalancerBackend represents service backend
Expand Down Expand Up @@ -217,6 +218,10 @@ type LoadBalancerBackendProperties struct {
HealthCheckExpectedStatus int `json:"health_check_expected_status,omitempty"`
StickySessionCookieName string `json:"sticky_session_cookie_name,omitempty"`
OutboundProxyProtocol LoadBalancerProxyProtocolVersion `json:"outbound_proxy_protocol,omitempty"`
TLSEnabled *bool `json:"tls_enabled,omitempty"`
TLSVerify *bool `json:"tls_verify,omitempty"`
TLSUseSystemCA *bool `json:"tls_use_system_ca,omitempty"`
HTTP2Enabled *bool `json:"http2_enabled,omitempty"`
}

// LoadBalancerResolver represents domain name resolver
Expand Down
55 changes: 47 additions & 8 deletions upcloud/load_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,7 @@ func TestLoadBalancerFrontend(t *testing.T) {
"port": 443,
"default_backend": "example-backend",
"properties": {
"timeout_client": 10,
"inbound_proxy_protocol": false
"timeout_client": 10
},
"created_at": "2021-12-07T13:58:30.817272Z",
"updated_at": "2022-02-11T17:33:08.490581Z"
Expand Down Expand Up @@ -350,16 +349,15 @@ func TestLoadBalancerFrontendProperties(t *testing.T) {
},
`
{
"timeout_client": 10,
"inbound_proxy_protocol": false
"timeout_client": 10
}
`,
)
testJSON(t,
&LoadBalancerFrontendProperties{},
&LoadBalancerFrontendProperties{
TimeoutClient: 10,
InboundProxyProtocol: true,
InboundProxyProtocol: BoolPtr(true),
},
`
{
Expand All @@ -372,7 +370,7 @@ func TestLoadBalancerFrontendProperties(t *testing.T) {
&LoadBalancerFrontendProperties{},
&LoadBalancerFrontendProperties{
TimeoutClient: 10,
InboundProxyProtocol: false,
InboundProxyProtocol: BoolPtr(false),
},
`
{
Expand All @@ -381,6 +379,36 @@ func TestLoadBalancerFrontendProperties(t *testing.T) {
}
`,
)
testJSON(t,
&LoadBalancerFrontendProperties{},
&LoadBalancerFrontendProperties{
TimeoutClient: 10,
InboundProxyProtocol: BoolPtr(false),
HTTP2Enabled: BoolPtr(false),
},
`
{
"timeout_client": 10,
"inbound_proxy_protocol": false,
"http2_enabled": false
}
`,
)
testJSON(t,
&LoadBalancerFrontendProperties{},
&LoadBalancerFrontendProperties{
TimeoutClient: 10,
InboundProxyProtocol: BoolPtr(false),
HTTP2Enabled: BoolPtr(true),
},
`
{
"timeout_client": 10,
"inbound_proxy_protocol": false,
"http2_enabled": true
}
`,
)
}

func TestLoadBalancerRule(t *testing.T) {
Expand Down Expand Up @@ -570,8 +598,19 @@ func TestLoadBalancerBackendProperties(t *testing.T) {
)
testJSON(t,
&LoadBalancerBackendProperties{},
&LoadBalancerBackendProperties{},
`{}`,
&LoadBalancerBackendProperties{
TLSVerify: BoolPtr(true),
TLSEnabled: BoolPtr(true),
TLSUseSystemCA: BoolPtr(true),
HTTP2Enabled: BoolPtr(true),
},
`{
"tls_verify": true,
"tls_enabled": true,
"tls_use_system_ca": true,
"http2_enabled": true
}
`,
)
}

Expand Down
2 changes: 1 addition & 1 deletion upcloud/request/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (r *GetLoadBalancerBackendsRequest) RequestURL() string {
return fmt.Sprintf("/load-balancer/%s/backends", r.ServiceUUID)
}

// BalancerBackend represents the payload for CreateLoadBalancerBackendRequest
// LoadBalancerBackend represents the payload for CreateLoadBalancerBackendRequest
type LoadBalancerBackend struct {
Name string `json:"name"`
Resolver string `json:"resolver,omitempty"`
Expand Down
12 changes: 8 additions & 4 deletions upcloud/request/load_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ func TestModifyLoadBalancerBackendRequest(t *testing.T) {
HealthCheckExpectedStatus: 200,
StickySessionCookieName: "SERVERID",
OutboundProxyProtocol: upcloud.LoadBalancerProxyProtocolVersion1,
HTTP2Enabled: upcloud.BoolPtr(true),
},
},
}
Expand All @@ -315,7 +316,8 @@ func TestModifyLoadBalancerBackendRequest(t *testing.T) {
"health_check_url": "/health",
"health_check_expected_status": 200,
"sticky_session_cookie_name": "SERVERID",
"outbound_proxy_protocol": "v1"
"outbound_proxy_protocol": "v1",
"http2_enabled": true
}
}`

Expand Down Expand Up @@ -748,7 +750,7 @@ func TestCreateLoadBalancerFrontendRequest(t *testing.T) {
DefaultBackend: "example-backend",
Properties: &upcloud.LoadBalancerFrontendProperties{
TimeoutClient: 10,
InboundProxyProtocol: false,
InboundProxyProtocol: upcloud.BoolPtr(false),
},
Rules: []LoadBalancerFrontendRule{{
Name: "example-rule-1",
Expand Down Expand Up @@ -788,7 +790,8 @@ func TestModifyLoadBalancerFrontendRequest(t *testing.T) {
"default_backend": "example-backend",
"properties": {
"timeout_client": 10,
"inbound_proxy_protocol": false
"inbound_proxy_protocol": false,
"http2_enabled": false
}
}`
r := ModifyLoadBalancerFrontendRequest{
Expand All @@ -801,7 +804,8 @@ func TestModifyLoadBalancerFrontendRequest(t *testing.T) {
DefaultBackend: "example-backend",
Properties: &upcloud.LoadBalancerFrontendProperties{
TimeoutClient: 10,
InboundProxyProtocol: false,
InboundProxyProtocol: upcloud.BoolPtr(false),
HTTP2Enabled: upcloud.BoolPtr(false),
},
},
}
Expand Down
Loading

0 comments on commit 0edbc78

Please sign in to comment.