-
Notifications
You must be signed in to change notification settings - Fork 143
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
Always use configured host on preconnect #14
Conversation
@@ -207,7 +209,7 @@ private String parsePreconnectAndReturnHost() throws Exception { | |||
} | |||
token.put("high_security", agentConfig.isHighSecurity()); | |||
params.add(token); | |||
Object response = invokeNoRunId(CollectorMethods.PRECONNECT, compressedEncoding, params); | |||
Object response = invokeNoRunId(originalHost, CollectorMethods.PRECONNECT, compressedEncoding, params); |
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.
preconnect
should always use the original collector host.
@@ -232,7 +234,7 @@ private String parsePreconnectAndReturnHost() throws Exception { | |||
startupOptions.put(ENV_METADATA, metadata); | |||
|
|||
params.add(startupOptions); | |||
Object response = invokeNoRunId(CollectorMethods.CONNECT, compressedEncoding, params); | |||
Object response = invokeNoRunId(redirectHost, CollectorMethods.CONNECT, compressedEncoding, params); |
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.
connect
should always use the redirect host.
@@ -487,17 +489,17 @@ void setMaxPayloadSizeInBytes(int payloadSizeInBytes) { | |||
|
|||
private Object invokeRunId(String method, String encoding, Object runId, JSONStreamAware params) throws Exception { | |||
String uri = MessageFormat.format(agentRunIdUriPattern, method, runId.toString()); | |||
return invoke(method, encoding, uri, params); | |||
return invoke(redirectHost, method, encoding, uri, params); |
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.
Everything that takes a run token should use the redirect host.
@tspring LMK if you want me to merge this or you will. Thanks! |
assertEquals("value", result.get("other")); | ||
|
||
// This will assert that preconnect was called with the original host, not the redirect host. | ||
target.connect(startupOptions); |
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 unclear to me how this would do any assertions around preconnect. Does this test actually check what this comment says it is checking? If so, how does it do that?
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.
These tests use the DataSenderImpl
with a customized HttpClientWrapper
. HttpClientWrapper
is the interface that masks almost all the Apache HTTP client code. On line 80, this test applies the ConnectCycleNoSecuritySuccessClientWrapper
wrapper. When a preconnect
URL comes through that wrapper, it verifies that the host is no-collector.example.com
and sends a redirect host of new_host.example.com
.
Without the code change, this code would fail because the second preconnect would use the host new_host.example.com
.
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.
Ok, thanks for clarifying...because that's pretty complicated for testing. At least it is tested. Thanks!
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.
Yeah - probably should have done it with mockito.
At least two language agents always go back to their original configured host on preconnect. The Java agent will make the second round of
preconnect
on the redirect host.This is currently causing issues because calling preconnect on the gov-collector-NNN hosts redirects you back to the collector-NNN shards. This is wrong and will cause
LicenseException
if they are prevented from allowing anything into the default backend.This fixes that problem by always calling
preconnect
on the configured host (e.g.,gov-collector.newrelic.com
) and then updating the redirect host from there.Auto app naming will create multiple instances of
DataSenderImpl
, so those won't conflict. This was tested by me on staging through aForceRestartException
.Example of bad behavior:
Note that yes, this is actually a collector problem, which we are pursuing.
This is after the change. Note that preconnect goes to
gov-collector.newrelic.com
and after the redirect, we're still pointing togov-collector-007
.