-
Notifications
You must be signed in to change notification settings - Fork 94
project: UDP NodeBalancers #751
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
Open
ezilber-akamai
wants to merge
4
commits into
main
Choose a base branch
from
proj/nb-udp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+7,941
−6,561
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,26 +6,28 @@ import ( | |
|
||
// NodeBalancerConfig objects allow a NodeBalancer to accept traffic on a new port | ||
type NodeBalancerConfig struct { | ||
ID int `json:"id"` | ||
Port int `json:"port"` | ||
Protocol ConfigProtocol `json:"protocol"` | ||
ProxyProtocol ConfigProxyProtocol `json:"proxy_protocol"` | ||
Algorithm ConfigAlgorithm `json:"algorithm"` | ||
Stickiness ConfigStickiness `json:"stickiness"` | ||
Check ConfigCheck `json:"check"` | ||
CheckInterval int `json:"check_interval"` | ||
CheckAttempts int `json:"check_attempts"` | ||
CheckPath string `json:"check_path"` | ||
CheckBody string `json:"check_body"` | ||
CheckPassive bool `json:"check_passive"` | ||
CheckTimeout int `json:"check_timeout"` | ||
CipherSuite ConfigCipher `json:"cipher_suite"` | ||
NodeBalancerID int `json:"nodebalancer_id"` | ||
SSLCommonName string `json:"ssl_commonname"` | ||
SSLFingerprint string `json:"ssl_fingerprint"` | ||
SSLCert string `json:"ssl_cert"` | ||
SSLKey string `json:"ssl_key"` | ||
NodesStatus *NodeBalancerNodeStatus `json:"nodes_status"` | ||
ID int `json:"id"` | ||
Port int `json:"port"` | ||
Protocol ConfigProtocol `json:"protocol"` | ||
ProxyProtocol ConfigProxyProtocol `json:"proxy_protocol"` | ||
Algorithm ConfigAlgorithm `json:"algorithm"` | ||
Stickiness ConfigStickiness `json:"stickiness"` | ||
Check ConfigCheck `json:"check"` | ||
CheckInterval int `json:"check_interval"` | ||
CheckAttempts int `json:"check_attempts"` | ||
CheckPath string `json:"check_path"` | ||
CheckBody string `json:"check_body"` | ||
CheckPassive bool `json:"check_passive"` | ||
CheckTimeout int `json:"check_timeout"` | ||
UDPCheckPort int `json:"udp_check_port"` | ||
UDPSessionTimeout int `json:"udp_session_timeout"` | ||
CipherSuite ConfigCipher `json:"cipher_suite"` | ||
NodeBalancerID int `json:"nodebalancer_id"` | ||
SSLCommonName string `json:"ssl_commonname"` | ||
SSLFingerprint string `json:"ssl_fingerprint"` | ||
SSLCert string `json:"ssl_cert"` | ||
SSLKey string `json:"ssl_key"` | ||
NodesStatus *NodeBalancerNodeStatus `json:"nodes_status"` | ||
} | ||
|
||
// ConfigAlgorithm constants start with Algorithm and include Linode API NodeBalancer Config Algorithms | ||
|
@@ -36,6 +38,7 @@ const ( | |
AlgorithmRoundRobin ConfigAlgorithm = "roundrobin" | ||
AlgorithmLeastConn ConfigAlgorithm = "leastconn" | ||
AlgorithmSource ConfigAlgorithm = "source" | ||
AlgorithmRingHash ConfigAlgorithm = "ring_hash" | ||
) | ||
|
||
// ConfigStickiness constants start with Stickiness and include Linode API NodeBalancer Config Stickiness | ||
|
@@ -44,8 +47,10 @@ type ConfigStickiness string | |
// ConfigStickiness constants reflect the node stickiness method for a NodeBalancer Config | ||
const ( | ||
StickinessNone ConfigStickiness = "none" | ||
StickinessSession ConfigStickiness = "session" | ||
StickinessTable ConfigStickiness = "table" | ||
StickinessHTTPCookie ConfigStickiness = "http_cookie" | ||
StickinessSourceIP ConfigStickiness = "source_ip" | ||
) | ||
|
||
// ConfigCheck constants start with Check and include Linode API NodeBalancer Config Check methods | ||
|
@@ -67,12 +72,13 @@ const ( | |
ProtocolHTTP ConfigProtocol = "http" | ||
ProtocolHTTPS ConfigProtocol = "https" | ||
ProtocolTCP ConfigProtocol = "tcp" | ||
ProtocolUDP ConfigProtocol = "udp" | ||
) | ||
|
||
// ConfigProxyProtocol constants start with ProxyProtocol and include Linode API NodeBalancer Config proxy protocol versions | ||
type ConfigProxyProtocol string | ||
|
||
// ConfigProxyProtocol constatns reflect the proxy protocol version used by a NodeBalancer Config | ||
// ConfigProxyProtocol constants reflect the proxy protocol version used by a NodeBalancer Config | ||
const ( | ||
ProxyProtocolNone ConfigProxyProtocol = "none" | ||
ProxyProtocolV1 ConfigProxyProtocol = "v1" | ||
|
@@ -108,6 +114,7 @@ type NodeBalancerConfigCreateOptions struct { | |
CheckBody string `json:"check_body,omitempty"` | ||
CheckPassive *bool `json:"check_passive,omitempty"` | ||
CheckTimeout int `json:"check_timeout,omitempty"` | ||
UDPCheckPort *int `json:"udp_check_port,omitempty"` | ||
CipherSuite ConfigCipher `json:"cipher_suite,omitempty"` | ||
SSLCert string `json:"ssl_cert,omitempty"` | ||
SSLKey string `json:"ssl_key,omitempty"` | ||
|
@@ -128,6 +135,7 @@ type NodeBalancerConfigRebuildOptions struct { | |
CheckBody string `json:"check_body,omitempty"` | ||
CheckPassive *bool `json:"check_passive,omitempty"` | ||
CheckTimeout int `json:"check_timeout,omitempty"` | ||
UDPCheckPort *int `json:"udp_check_port,omitempty"` | ||
CipherSuite ConfigCipher `json:"cipher_suite,omitempty"` | ||
SSLCert string `json:"ssl_cert,omitempty"` | ||
SSLKey string `json:"ssl_key,omitempty"` | ||
|
@@ -160,6 +168,7 @@ func (i NodeBalancerConfig) GetCreateOptions() NodeBalancerConfigCreateOptions { | |
CheckPath: i.CheckPath, | ||
CheckBody: i.CheckBody, | ||
CheckPassive: copyBool(&i.CheckPassive), | ||
UDPCheckPort: &i.UDPCheckPort, | ||
CipherSuite: i.CipherSuite, | ||
SSLCert: i.SSLCert, | ||
SSLKey: i.SSLKey, | ||
|
@@ -181,6 +190,7 @@ func (i NodeBalancerConfig) GetUpdateOptions() NodeBalancerConfigUpdateOptions { | |
CheckBody: i.CheckBody, | ||
CheckPassive: copyBool(&i.CheckPassive), | ||
CheckTimeout: i.CheckTimeout, | ||
UDPCheckPort: copyInt(&i.UDPCheckPort), | ||
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. Same here, set only for UDP protocol |
||
CipherSuite: i.CipherSuite, | ||
SSLCert: i.SSLCert, | ||
SSLKey: i.SSLKey, | ||
|
@@ -202,6 +212,7 @@ func (i NodeBalancerConfig) GetRebuildOptions() NodeBalancerConfigRebuildOptions | |
CheckPath: i.CheckPath, | ||
CheckBody: i.CheckBody, | ||
CheckPassive: copyBool(&i.CheckPassive), | ||
UDPCheckPort: copyInt(&i.UDPCheckPort), | ||
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. Same here, set only for UDP protocol |
||
CipherSuite: i.CipherSuite, | ||
SSLCert: i.SSLCert, | ||
SSLKey: i.SSLKey, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should set it only if protocol is UDP. This field is not optional in
NodeBalancerConfig
, so if you don't set it there (ex for TCP protocol), it gets default 0. If then someone doesGetCreateOptions()
for thatNodeBalancerConfig
, returnedNodeBalancerConfigCreateOptions
has UDPCheckPort assigned value 0 and that will make calls to fail as udp_check_port has to be within 1 to 65535.