-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[exporter/loadbalancing] Fix inconsistent handling of endpoints without port #13745
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
[exporter/loadbalancing] Fix inconsistent handling of endpoints without port #13745
Conversation
…ever contain host-strings with port
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 makes sense, looks like we had inconsistent values in some places. Have you experimented going the other direction? Removing the port from the existing place(s), adding it only on the backing exporter instantiation? Here:
oCfg.Endpoint = endpoint |
// verify | ||
assert.Len(t, p.exporters, 1) | ||
assert.NotContains(t, p.exporters, "endpoint-2") | ||
assert.Contains(t, p.exporters, endpointWithPort("endpoint-1")) |
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.
While the effect is the same, we should indeed assert that endpoint-2
does not exist here, as it has been removed.
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.
Sure. I figured asserting that the Len is 1, and that the 1 is endpoint-1 should cover all cases. But I can revert that.
// verify | ||
assert.Len(t, p.exporters, 1) | ||
assert.NotContains(t, p.exporters, "endpoint-2") | ||
assert.Contains(t, p.exporters, "endpoint-1:4317") |
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 one was a good change, thanks for that!
assert.Nil(t, res) | ||
} | ||
|
||
func TestConsumeLogsExporterNotFound(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.
Why was this test removed?
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 no longer works. It seemed to rely on the bug I fixed, i.e. that removeMissing would remove some endpoints. There's no way to make
res := p.ConsumeLogs(context.Background(), simpleLogs())
fail in this way.
} | ||
} | ||
|
||
func TestConsumeTracesExporterNotFound(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.
Same about this one.
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.
Ditto. It relied on the broken behavior to 'work'.
No, I didn't consider that, mainly because I think that could cause issues if we wind up with an endpoint with the same hostname, but different ports, like Edit: It's not possible in the dns resolver, but with the static resolver? Any future resolver? |
True, it's indeed realistic to have that as part of the static resolver. I think we even use that in the examples. |
Fixes #10321 |
Description:
Fixes the problem where a dns-resolver is defined without a
Port
element. This SHOULD result in the default port (4317) being used, but leads to some problems. See linked issue.The gist of the fix is to ensure that the strings in the lb.exporters map always have the port, and are always looked up with the port. Some of the unit-tests (logs and traces) can no longer happen as written and have been removed.
A deeper fix would likely require more refactoring, since the host (with or without port) is also used in the
items
ring.Link to tracking Issue:
#10321
Testing:
Unit tests performed.
Ran test-config from the linked issue, which worked.
Documentation:
No documentation added or changed.