-
Notifications
You must be signed in to change notification settings - Fork 2k
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 slow-start support in vs/vsr #655
Conversation
3a004c1
to
c15e1a4
Compare
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.
Hey @b-v-r thanks for the PR!
I've found 2 small issues and made some suggestion to fix them. Let me know what you think
internal/configs/virtualserver.go
Outdated
@@ -342,6 +347,12 @@ func generateUpstream(upstreamName string, upstream conf_v1alpha1.Upstream, isEx | |||
FailTimeout: generateString(upstream.FailTimeout, cfgParams.FailTimeout), | |||
MaxConns: generateIntFromPointer(upstream.MaxConns, cfgParams.MaxConns), | |||
Resolve: isExternalNameSvc, | |||
SlowStart: upstream.SlowStart, | |||
} | |||
if incompatibleLBMethods[upstream.LBMethod] { |
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.
If upstream.LBMethod
is not defined, the cfgParams.LBMethod
will be used (check line 363 of this file: generateLBMethod(upstream.LBMethod, cfgParams.LBMethod),
). That's why using the upstream.LBMethod
here is not the good option.
I suggest create a variable lbMethod = generateLBMethod(upstream.LBMethod, cfgParams.LBMethod),
and use that variable here incompatibleLBMethods[lbMethod]
and in line 363
.
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.
Apart from that, I would move this check outside the for
loop. All the servers for the upstream will work the same way. This way we only do the check once, and also we can create a variable for slowStart
and make everything more explicit (instead of changing the s.SlowStart
afterwards)
I mean this:
incompatibleLBMethods := map[string]bool{
"random": true,
"ip-hash": true,
"hash": true,
}
lbMethod := generateLBMethod(upstream.LBMethod, cfgParams.LBMethod)
slowStart := upstream.SlowStart
if upstream.SlowStart != "" && incompatibleLBMethods[lbMethod] {
// do the warning
slowStart = ""
}
for _, e := range endpoints {
s := version2.UpstreamServer{
Address: e,
MaxFails: generateIntFromPointer(upstream.MaxFails, cfgParams.MaxFails),
FailTimeout: generateString(upstream.FailTimeout, cfgParams.FailTimeout),
MaxConns: generateIntFromPointer(upstream.MaxConns, cfgParams.MaxConns),
Resolve: isExternalNameSvc,
SlowStart: slowStart,
}
upsServers = append(upsServers, s)
}
return version2.Upstream{
Name: upstreamName,
Servers: upsServers,
LBMethod: lbMethod,
Keepalive: generateIntFromPointer(upstream.Keepalive, cfgParams.Keepalive),
}
Let me know your thoughts!
PS: Code is not tested, just to point the idea.
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.
I would further suggest putting the logic for checking for incompatible method in a separate function and writing a unit test for that function.
lbMethod := generateLBMethod(upstream.LBMethod, cfgParams.LBMethod)
slowStart := for _, e := range endpoints {
s := version2.UpstreamServer{
Address: e,
MaxFails: generateIntFromPointer(upstream.MaxFails, cfgParams.MaxFails),
FailTimeout: generateString(upstream.FailTimeout, cfgParams.FailTimeout),
MaxConns: generateIntFromPointer(upstream.MaxConns, cfgParams.MaxConns),
Resolve: isExternalNameSvc,
SlowStart: generateSlowStart(lbMethod, upstream.SlowStart, isPlus)
,
}
upsServers = append(upsServers, s)
}
return version2.Upstream{
Name: upstreamName,
Servers: upsServers,
LBMethod: lbMethod,
Keepalive: generateIntFromPointer(upstream.Keepalive, cfgParams.Keepalive),
}
Note that isPlus
will have to be added to the list of generateUpstream
arguments. We need it because slow start only works for NGINX Plus.
Additionally, also note that hash
method is defined by hash
+ some varialble(s), for example $hash $request_id
. As a result, the check incompatibleLBMethods[lbMethod]
for hash method won't work. We need to check for the prefix, not the exact match here. Please also see the implementation of ParseLBMethod function https://github.com/nginxinc/kubernetes-ingress/blob/master/internal/configs/parsing_helpers.go#L92
Also, I suggest renaming incompatibleLBMethods
to incompatibleLBMethodsForSlowStart
and making it a global variable similar to https://github.com/nginxinc/kubernetes-ingress/blob/master/internal/configs/parsing_helpers.go#L119 so that the map is only created once.
internal/configs/virtualserver.go
Outdated
} | ||
if incompatibleLBMethods[upstream.LBMethod] { | ||
//TODO trigger warning | ||
glog.Warningf("The parameter slow-start cannot be used along with %s, load balancing method", upstream.LBMethod) |
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.
I think we can add also, at the end of the message, something like: "slow-start will be disabled for the Upstream %v", Upstream.Name
, to make sure the user understands that slow-start is not working even if they set it due to conflicts. What do you think?
Also, the warning doesn't make sense when SlowStart == "", so we should check that (eg, if slowStart = "" it means the user didn't set it, so there's no point of checking and warning the user)
PS: @pleshakov I think is better if we use a warning for now, because emitting events from virtualserver.go
can be tricky. Maybe we can do that in a future PR? Revisiting the warnings/errors and make sure to update them to Events when necessary?
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.
@Rulox warningf for now works OK. we can add a PR later to support emitting events for warnings.
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.
@b-v-r please see my comments.
Additionally, I suggest renaming the commit message and PR name to Add slow-start support in vs/vsr
so that it reflects that we're adding the slow-start support to our VirtualServer/VirtualServerRoutes resources. This will also be consistent with the previous similar commits https://github.com/nginxinc/kubernetes-ingress/commits/master
@@ -212,6 +212,7 @@ tls: | |||
| `next-upstream-tries` | The number of possible tries for passing a request to the next upstream server. See the [proxy_next_upstream_tries](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream_tries) directive. The `0` value turns off this limit. The default is `0`. | `int` | No | | |||
| `tls` | The TLS configuration for the Upstream. | [`tls`](#UpstreamTLS) | No | | |||
| `healthCheck` | The health check configuration for the Upstream. See the [health_check](http://nginx.org/en/docs/http/ngx_http_upstream_hc_module.html#health_check) directive. Note: this feature is supported only in NGINX Plus. | [`healthcheck`](#UpstreamHealthcheck) | No | | |||
| `slow-start` | The slow‑start allows an upstream server to gradually recover its weight from 0 to its nominal value after it has been recovered or became available or when the server becomes available after a period of time it was considered unavailable. Default value is zero seconds ("0s"), i.e. slow start is disabled. See the [slow-start](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#slow_start) parameter of the server directive. Note: The parameter cannot be used along with the hash and ip_hash load balancing methods. | `string` | No | |
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.
| `slow-start` | The slow‑start allows an upstream server to gradually recover its weight from 0 to its nominal value after it has been recovered or became available or when the server becomes available after a period of time it was considered unavailable. Default value is zero seconds ("0s"), i.e. slow start is disabled. See the [slow-start](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#slow_start) parameter of the server directive. Note: The parameter cannot be used along with the hash and ip_hash load balancing methods. | `string` | No | | |
| `slow-start` | The slow start allows an upstream server to gradually recover its weight from 0 to its nominal value after it has been recovered or became available or when the server becomes available after a period of time it was considered unavailable. By default, the slow start is disabled. See the [slow_start](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#slow_start) parameter of the server directive. Note: The parameter cannot be used along with the `random`, `hash` or `ip_hash` load balancing methods and will be ignored. | `string` | No | |
@@ -5,7 +5,7 @@ upstream {{ $u.Name }} { | |||
{{ if $u.LBMethod }}{{ $u.LBMethod }};{{ end }} | |||
|
|||
{{ range $s := $u.Servers }} | |||
server {{ $s.Address }} max_fails={{ $s.MaxFails }} fail_timeout={{ $s.FailTimeout }} max_conns={{ $s.MaxConns }}{{ if $s.Resolve }} resolve{{ end }}; | |||
server {{ $s.Address }} max_fails={{ $s.MaxFails }} fail_timeout={{ $s.FailTimeout }}{{if $s.SlowStart }} slow_start={{ $s.SlowStart }}{{end}} max_conns={{ $s.MaxConns }}{{ if $s.Resolve }} resolve{{ end }}; |
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 need to use the curly brackets in a consistent manner.
server {{ $s.Address }} max_fails={{ $s.MaxFails }} fail_timeout={{ $s.FailTimeout }}{{if $s.SlowStart }} slow_start={{ $s.SlowStart }}{{end}} max_conns={{ $s.MaxConns }}{{ if $s.Resolve }} resolve{{ end }}; | |
server {{ $s.Address }} max_fails={{ $s.MaxFails }} fail_timeout={{ $s.FailTimeout }}{{ if $s.SlowStart }} slow_start={{ $s.SlowStart }}{{ end }} max_conns={{ $s.MaxConns }}{{ if $s.Resolve }} resolve{{ end }}; |
@@ -238,7 +238,7 @@ func TestGenerateVirtualServerConfig(t *testing.T) { | |||
Name: "vs_default_cafe_tea", |
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.
please fix the formatting in this file using gofmt
.
internal/configs/virtualserver.go
Outdated
@@ -342,6 +347,12 @@ func generateUpstream(upstreamName string, upstream conf_v1alpha1.Upstream, isEx | |||
FailTimeout: generateString(upstream.FailTimeout, cfgParams.FailTimeout), | |||
MaxConns: generateIntFromPointer(upstream.MaxConns, cfgParams.MaxConns), | |||
Resolve: isExternalNameSvc, | |||
SlowStart: upstream.SlowStart, | |||
} | |||
if incompatibleLBMethods[upstream.LBMethod] { |
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.
I would further suggest putting the logic for checking for incompatible method in a separate function and writing a unit test for that function.
lbMethod := generateLBMethod(upstream.LBMethod, cfgParams.LBMethod)
slowStart := for _, e := range endpoints {
s := version2.UpstreamServer{
Address: e,
MaxFails: generateIntFromPointer(upstream.MaxFails, cfgParams.MaxFails),
FailTimeout: generateString(upstream.FailTimeout, cfgParams.FailTimeout),
MaxConns: generateIntFromPointer(upstream.MaxConns, cfgParams.MaxConns),
Resolve: isExternalNameSvc,
SlowStart: generateSlowStart(lbMethod, upstream.SlowStart, isPlus)
,
}
upsServers = append(upsServers, s)
}
return version2.Upstream{
Name: upstreamName,
Servers: upsServers,
LBMethod: lbMethod,
Keepalive: generateIntFromPointer(upstream.Keepalive, cfgParams.Keepalive),
}
Note that isPlus
will have to be added to the list of generateUpstream
arguments. We need it because slow start only works for NGINX Plus.
Additionally, also note that hash
method is defined by hash
+ some varialble(s), for example $hash $request_id
. As a result, the check incompatibleLBMethods[lbMethod]
for hash method won't work. We need to check for the prefix, not the exact match here. Please also see the implementation of ParseLBMethod function https://github.com/nginxinc/kubernetes-ingress/blob/master/internal/configs/parsing_helpers.go#L92
Also, I suggest renaming incompatibleLBMethods
to incompatibleLBMethodsForSlowStart
and making it a global variable similar to https://github.com/nginxinc/kubernetes-ingress/blob/master/internal/configs/parsing_helpers.go#L119 so that the map is only created once.
internal/configs/virtualserver.go
Outdated
} | ||
if incompatibleLBMethods[upstream.LBMethod] { | ||
//TODO trigger warning | ||
glog.Warningf("The parameter slow-start cannot be used along with %s, load balancing method", upstream.LBMethod) |
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.
@Rulox warningf for now works OK. we can add a PR later to support emitting events for warnings.
@@ -41,6 +41,7 @@ type Upstream struct { | |||
ProxyNextUpstreamTries int `json:"next-upstream-tries"` | |||
TLS UpstreamTLS `json:"tls"` | |||
HealthCheck *HealthCheck `json:"healthCheck"` | |||
SlowStart string `json:"slow-start,omitempty"` |
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.
omitempty
is not necessary here
c15e1a4
to
29e22eb
Compare
29e22eb
to
ce8439c
Compare
ce8439c
to
849b35c
Compare
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.
Please see my comments.
Additionally, multiple files are not properly formatted. Make sure the code is formatted using gofmt
tool. You can also configure your editor to do that when saving a file.
internal/configs/virtualserver.go
Outdated
var upsServers []version2.UpstreamServer | ||
lbMethod := generateLBMethod(upstream.LBMethod, cfgParams.LBMethod) | ||
slowStart := generateSlowStartForPlus(upstream, lbMethod) |
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.
instead of
if isPlus {
s.SlowStart = slowStart
}
I suggest to do the following:
slowStart := ""
if isPlus {
slowStart := generateSlowStartForPlus(upstream, lbMethod)
}
this way generateSlowStartForPlus
will only be invoked for Plus.
internal/configs/virtualserver.go
Outdated
@@ -354,6 +366,23 @@ func generateUpstream(upstreamName string, upstream conf_v1alpha1.Upstream, isEx | |||
} | |||
} | |||
|
|||
func generateSlowStartForPlus(upstream conf_v1alpha1.Upstream, lbMethod string) string { | |||
|
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.
the empty line is not necessary
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.
this wasn't addressed. we don't put empty lines at the beginning of the function
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.
the empty line is back :) please remove
@@ -354,6 +366,23 @@ func generateUpstream(upstreamName string, upstream conf_v1alpha1.Upstream, isEx | |||
} | |||
} | |||
|
|||
func generateSlowStartForPlus(upstream conf_v1alpha1.Upstream, lbMethod string) string { |
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.
this function needs to be rewritten as it doesn't implement the slow start logic completely. The logic is below:
- if slowStart is "" , return ""
- if the lbMethod is either
random
,ip_hash
orhash
, print a warning and return "" . Note that the hash method is defined as hash + some varialble(s), for example$hash $request_id
. The current implementation incorrectly allows methods like$hash $request_id
. Also, the random method is similar to the hash, but has a finite number of possible values. Please see them here -- https://github.com/nginxinc/kubernetes-ingress/blob/master/internal/configs/parsing_helpers.go#L122-L126 Those should be excluded as well. - return slowStart
Also, the corresponding unit test must be rewritten as well. For the test, consider the following test cases:
Positive cases:
- slow start is "" and the method is "least_conn", expects ""
- slow_start is "10s" and the method is "least_conn", expects "10s"
Negative cases:
- slow_start is "10s" and the method is "hash $something", expects ""
- slow_start is "10s" and the method is "ip_hash", expects ""
- slow_start is "10s" and the method is "random", expects "". Note, this can be repeated for all allowed variations of the random method -- https://github.com/nginxinc/kubernetes-ingress/blob/master/internal/configs/parsing_helpers.go#L122-L126
Please add any additional cases if necessary.
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.
It looks better now! Great job. I am not 100% sure about the incompatibleLBMethodsForSlowStart
so let's wait til @pleshakov has another look 🤔
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.
Normally we have a preference for using a map
like: https://github.com/nginxinc/kubernetes-ingress/blob/master/pkg/apis/configuration/validation/validation.go#L343-L357 which I think should be possible.
If sticking with a slice is necessary, you should be able to make it const
, right?
f42d1d3
to
59707e9
Compare
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.
Looks good. 👍
Just small comments in the TestCases only for consistency. Overall looks good, waiting on @pleshakov final review too as I wasn't sure of 1 thing.
@@ -1960,3 +1961,51 @@ func TestGenerateEndpointsForUpstream(t *testing.T) { | |||
} | |||
} | |||
} | |||
|
|||
func TestGenerateSlowStartForPlus(t *testing.T) { |
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.
TestGenerateSlowStartForPlus
doesn't follow the rest of the file consistency.
- Why do we need the
{
}
blocks delimiters? I think they are redundant - If there are more than 1 test case, normally we define the test cases in a slice of structs
tests := []struct {...}
and iterate over them. For instance, we could have 2 different Test functions. 1 for the incompatible methods and another one for compatible ones. That way you can still use thefor loop
in one of the functions (iterating overincompatibleLBMethodsForSlowStart
) and another function using a[]struct {...}
for the other 2 cases with valid lbMethods, to keep consistency with the rest of the file. - Comments with all the cases are not needed as code should be auto explained (unless there's a weird edge case there)
Let me know if this makes sense to you and your thoughts!
internal/configs/virtualserver.go
Outdated
|
||
for _, nLBMethod := range incompatibleLBMethodsForSlowStart { | ||
if strings.Contains(lbMethod, nLBMethod) { | ||
//TODO trigger warning |
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.
The //TODO
comment is not needed. I think we should avoid things like TODO
or FIXME
when merging to master.
@@ -354,6 +366,23 @@ func generateUpstream(upstreamName string, upstream conf_v1alpha1.Upstream, isEx | |||
} | |||
} | |||
|
|||
func generateSlowStartForPlus(upstream conf_v1alpha1.Upstream, lbMethod string) string { |
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.
It looks better now! Great job. I am not 100% sure about the incompatibleLBMethodsForSlowStart
so let's wait til @pleshakov has another look 🤔
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.
Looks pretty good. Just some code style to fix from @Rulox and my feedback and I'll approve.
@@ -354,6 +366,23 @@ func generateUpstream(upstreamName string, upstream conf_v1alpha1.Upstream, isEx | |||
} | |||
} | |||
|
|||
func generateSlowStartForPlus(upstream conf_v1alpha1.Upstream, lbMethod string) string { |
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.
Normally we have a preference for using a map
like: https://github.com/nginxinc/kubernetes-ingress/blob/master/pkg/apis/configuration/validation/validation.go#L343-L357 which I think should be possible.
If sticking with a slice is necessary, you should be able to make it const
, right?
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.
Please see my suggestions +1 to @Rulox and @Dean-Coakley 's comments
internal/configs/virtualserver.go
Outdated
return "" | ||
} | ||
|
||
for _, nLBMethod := range incompatibleLBMethodsForSlowStart { |
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.
to check for the incompatible method, I suggest using approach similar to https://github.com/nginxinc/kubernetes-ingress/blob/master/internal/configs/parsing_helpers.go#L141-L148 :
- first check if the method starts with hash
- check if the method is in the map. This will require changing
incompatibleLBMethodsForSlowStart
to a map.
d229a0b
to
353ecca
Compare
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.
Looks good to me!
@@ -1960,3 +1961,44 @@ func TestGenerateEndpointsForUpstream(t *testing.T) { | |||
} | |||
} | |||
} | |||
|
|||
func TestGenerateSlowStartForPlusWithInCompatibleLBMethods(t *testing.T) { | |||
name := "test-slowstart-with-incompatible-LBMethods" |
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.
Completely optional: but personally I'd name this var serviceName
or change the value to include the suffix -svc
At first glance I thought this was a name of a test case.
(Same applies to TestGenerateSlowStartForPlus
)
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.
@b-v-r thanks for the updates. Please see my comments
internal/configs/virtualserver.go
Outdated
if slowStart == "" { | ||
return "" | ||
} | ||
method := strings.TrimSpace(lbMethod) |
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.
there is no need for TrimSpace
, as lbMethod
in this function has already been parsed.
internal/configs/virtualserver.go
Outdated
} | ||
method := strings.TrimSpace(lbMethod) | ||
if strings.HasPrefix(method, "hash") { | ||
method = "hash" |
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.
for readability and clarity, it is better to return "" and print a warning in this block right way, rather than assigning it to the method
variable.
internal/configs/virtualserver.go
Outdated
@@ -14,6 +14,16 @@ import ( | |||
|
|||
const nginx502Server = "unix:/var/run/nginx-502-server.sock" | |||
|
|||
var incompatibleLBMethodsForSlowStart = map[string]bool{ | |||
"random": true, | |||
"ip-hash": true, |
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.
the correct method is ip_hash
} | ||
|
||
for _, test := range tests { | ||
lbMethod := generateLBMethod(test.upstream.LBMethod, "least_conn") |
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.
there is no need to call generateLBMethod
. I suggest making the method the third field of the struct you use in tests array.
upstream := conf_v1alpha1.Upstream{Service: name, Port: 80, SlowStart: "10s"} | ||
expected := "" | ||
|
||
for lbMethod, _ := range incompatibleLBMethodsForSlowStart { |
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.
it is better to have an array of the input parameters like you have in the TestGenerateSlowStartForPlus
. this will make the tests much more readable.
expected := "" | ||
|
||
for lbMethod, _ := range incompatibleLBMethodsForSlowStart { | ||
nlbMethod := generateLBMethod(upstream.LBMethod, lbMethod) |
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.
there is no need to call generateLBMethod
. this is the same comment as for line 1998.
cb5cc3d
to
8423006
Compare
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.
@b-v-r thanks for the changes. looks like we're almost there. please see my suggestions.
internal/configs/virtualserver.go
Outdated
var incompatibleLBMethodsForSlowStart = map[string]bool{ | ||
"random": true, | ||
"ip_hash": true, | ||
"hash": true, |
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.
hash is not required here, considering this change https://github.com/nginxinc/kubernetes-ingress/pull/655/files#diff-d8f2204ffe0ef11d167489c09e9f4170R380
} | ||
|
||
for _, test := range tests { | ||
for lbMethod, _ := range incompatibleLBMethodsForSlowStart { |
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.
this suggestion wasn't implemented #655 (comment) please have a list of input parameters rather than taking lb methods from incompatibleLBMethodsForSlowStart
internal/configs/virtualserver.go
Outdated
Keepalive: generateIntFromPointer(upstream.Keepalive, cfgParams.Keepalive), | ||
} | ||
} | ||
|
||
func generateSlowStartForPlus(upstream conf_v1alpha1.Upstream, lbMethod string) string { | ||
slowStart := upstream.SlowStart |
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 don't usually create auxiliary variables like this one. Note that is only used twice. Can we just use upstream.SlowStart
instead?
8423006
to
6e18d66
Compare
@pleshakov can you please review changes |
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.
@b-v-r please see the comments about the new changes
internal/configs/virtualserver.go
Outdated
@@ -354,6 +366,23 @@ func generateUpstream(upstreamName string, upstream conf_v1alpha1.Upstream, isEx | |||
} | |||
} | |||
|
|||
func generateSlowStartForPlus(upstream conf_v1alpha1.Upstream, lbMethod string) string { | |||
|
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.
the empty line is back :) please remove
4546260
to
facb764
Compare
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.
lgtm 🚀
Proposed changes
Describe the use case and detail of the change. If this PR addresses an issue on GitHub, make sure to include a link to that issue here in this description (not in the title of the PR).
Checklist
Before creating a PR, run through this checklist and mark each as complete.