Skip to content
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

Merged
merged 1 commit into from
Apr 15, 2021
Merged

Conversation

ytsarev
Copy link
Member

@ytsarev ytsarev commented Apr 14, 2021

Signed-off-by: Yury Tsarev [email protected]

@@ -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")
Copy link
Collaborator

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?

Copy link
Member Author

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

strToInt := func(string string) int {
intValue, err := strconv.Atoi(string)
if err != nil {
log.Err(err)
Copy link
Collaborator

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....)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kuritka amended, thanks

@@ -240,6 +243,23 @@ func (r *GslbReconciler) SetupWithManager(mgr ctrl.Manager) error {
},
}

strToInt := func(string string) int {
Copy link
Contributor

@somaritane somaritane Apr 15, 2021

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)

Copy link
Collaborator

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).

Copy link
Member Author

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

Copy link
Member Author

@ytsarev ytsarev Apr 15, 2021

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)

Copy link
Collaborator

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.

Copy link
Member Author

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]>
Copy link
Contributor

@somaritane somaritane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ytsarev ytsarev merged commit e6f0a39 into master Apr 15, 2021
@ytsarev ytsarev deleted the annotation-spec branch April 15, 2021 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for k8gb.io/dns-ttl-seconds and k8gb.io/splitbrain-threshold-seconds strategy annotations
4 participants