-
Notifications
You must be signed in to change notification settings - Fork 101
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
Support for optional Ingress strategy annotations #445
Conversation
@@ -61,6 +61,8 @@ func TestK8gbIngressAnnotationFailover(t *testing.T) { | |||
assertGslbStatus(t, options, "test-gslb-annotation-failover", "notfound.cloud.example.com:NotFound roundrobin.cloud.example.com:NotFound unhealthy.cloud.example.com:NotFound") | |||
assertGslbSpec(t, options, "test-gslb-annotation-failover", ".spec.strategy.type", "failover") | |||
assertGslbSpec(t, options, "test-gslb-annotation-failover", ".spec.strategy.primaryGeoTag", "eu") | |||
assertGslbSpec(t, options, "test-gslb-annotation-failover", ".spec.strategy.dnsTtlSeconds", "60") |
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.
aren't values supposed to be ints?
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.
@k0da yeah, good point, but it checks with kubectl based jsonpath behind the scenes, so everything is string in the e2e test context. See https://github.com/AbsaOSS/k8gb/blob/master/terratest/test/helpers.go#L159-L164 for details
controllers/gslb_controller.go
Outdated
strToInt := func(string string) int { | ||
intValue, err := strconv.Atoi(string) | ||
if err != nil { | ||
log.Err(err) |
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.
logger will not print message, use
log.Err(err).Msg("")
// or
log.Err(err).Msg(use some text....)
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.
@kuritka amended, thanks
controllers/gslb_controller.go
Outdated
@@ -240,6 +243,23 @@ func (r *GslbReconciler) SetupWithManager(mgr ctrl.Manager) error { | |||
}, | |||
} | |||
|
|||
strToInt := func(string string) int { |
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.
func(string string)
looks a bit confusing, consider renaming the parameter, so it doesn't clash with the type name)
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 better readability, consider to put function declaration to the beginning of the caller function (between variable, constant declarations).
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.
@kuritka could you point me to the location you mean? I'm not 100% sure I'm getting you 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.
@somaritane renamed to str
, amended)
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.
@ytsarev basically is up to you. You can keep it as it is, because the function is preceded only by some initializations. Also strToInt is used only in context of createGslbFromIngress handler and nowhere else.
Another place to put this func is under SetupWithManager, so it is at the same level as other funcs.
Both seems totally equal.
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.
Also strToInt is used only in context of createGslbFromIngress handler and nowhere else.
That's exactly why I decided to declare it inline and next to the actual invocation.
I think I will keep it as it is for now and we move it out to some other level when/if there will be another case of strToInt
usage in the codebase.
Thanks a lot for a careful review.
* Cover additional Gslb spec options with annotated Ingress * Resolves #316 Signed-off-by: Yury Tsarev <[email protected]>
a012efa
to
afa2473
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
k8gb.io/dns-ttl-seconds
andk8gb.io/splitbrain-threshold-seconds
strategy annotations #316Signed-off-by: Yury Tsarev [email protected]