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

resolving host before enabling tracing #6872

Closed
wants to merge 1 commit into from

Conversation

timmysilv
Copy link
Contributor

What this PR does / why we need it:

While testing a new Jaeger C++ client, @miry found that configuring tracing with a domain that doesn't resolve causes ingress-nginx to fail bootup. This tries to resolve the domain in Go before letting the tracing client libraries do it and cause fatal errors. If it can't resolve, it simply won't enable tracing.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Which issue/s this PR fixes

How Has This Been Tested?

Updated the old test cases to use localhost since that should always resolve (and not hit this error), and added a new test case to ensure that an invalid domain causes an error and doesn't write to the template file.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 12, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @timmysilv. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 12, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: timmysilv
To complete the pull request process, please assign elvinefendi after the PR has been reviewed.
You can assign the PR to them by writing /assign @elvinefendi in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 12, 2021
@@ -1165,7 +1165,7 @@ func TestBuildOpenTracing(t *testing.T) {

cfgJaeger := config.Configuration{
EnableOpentracing: true,
JaegerCollectorHost: "jaeger-host.com",
JaegerCollectorHost: "localhost",
Copy link
Contributor

@miry miry Feb 16, 2021

Choose a reason for hiding this comment

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

What do you think to use: jaeger.lvh.me or similar? It would test resolving not just by /etc/hosts, but also use DNS resolving:

$ nslookup jaeger.lvh.me - 1.1.1.1
Server:		1.1.1.1
Address:	1.1.1.1#53

Non-authoritative answer:
Name:	jaeger.lvh.me
Address: 127.0.0.1

I have not tested locally, if there are any restrictions in the test environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made this change, should pass tests fine. I don't think it's necessarily important to test that resolvers themselves work here, but why not match production as much as possible?

Copy link
Contributor

@miry miry Feb 16, 2021

Choose a reason for hiding this comment

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

Thank you for the changes.

why not match production as much as possible?

I think a general deployment of ingress and collector will be deployed to different node pools.
Discovery would be through the kubernetes services, that would use resolving through nameservers.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 10, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 26, 2021
@timmysilv
Copy link
Contributor Author

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 27, 2021
using lvh.me to actually test with DNS
return ""
}
buf.WriteString("opentracing_load_tracer /usr/local/lib/libjaegertracing_plugin.so /etc/nginx/opentracing.json;")
host = strings.Split(hostMatch[4], ":")[0]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the above logic is taken from the client code. I'm keeping the regex confined to cfg.JaegerEndpoint because that regex expects something more specific. For example, just saying mydomain.com (for Zipkin, let's say) would actually result in regex match group 5 (not 4) but should still be valid. Meeting Jaeger endpoint standards simplifies the logic required in ingress-nginx, but I still do the split on :// afterward in case another configuration included a protocol.

@timmysilv
Copy link
Contributor Author

After thinking on it, changing nginx-opentracing to not fail hard when the client-specific tracer doesn't load properly would be more elegant so I'll look into that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants