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

Add ipAddress to RequestAttempt & include port in serialization #1692

Merged
merged 1 commit into from Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -454,7 +454,8 @@ private void proxyRequestToOrigin() {
zuulRequest, channelCtx.channel().eventLoop(), attemptNum, passport, chosenServer, chosenHostAddr);

storeAndLogOriginRequestInfo();
currentRequestAttempt = origin.newRequestAttempt(chosenServer.get(), context, attemptNum);
currentRequestAttempt =
origin.newRequestAttempt(chosenServer.get(), chosenHostAddr.get(), context, attemptNum);
requestAttempts.add(currentRequestAttempt);
passport.add(PassportState.ORIGIN_CONN_ACQUIRE_START);

Expand Down
Expand Up @@ -31,6 +31,7 @@
import io.netty.handler.timeout.ReadTimeoutException;

import javax.net.ssl.SSLHandshakeException;
import java.net.InetAddress;

/**
* User: michaels@netflix.com
Expand All @@ -51,6 +52,7 @@ public class RequestAttempt {
private String instanceId;
private String host;
private int port;
private String ipAddress;
private String vip;
private String region;
private String availabilityZone;
Expand All @@ -61,6 +63,7 @@ public class RequestAttempt {
public RequestAttempt(
int attemptNumber,
InstanceInfo server,
InetAddress serverAddr,
String targetVip,
String chosenWarmupLB,
int status,
Expand Down Expand Up @@ -99,6 +102,10 @@ public RequestAttempt(
}
}

if (serverAddr != null) {
ipAddress = serverAddr.getHostAddress();
}

this.status = status;
this.error = error;
this.exceptionType = exceptionType;
Expand All @@ -108,7 +115,11 @@ public RequestAttempt(
}

public RequestAttempt(
final DiscoveryResult server, final IClientConfig clientConfig, int attemptNumber, int readTimeout) {
final DiscoveryResult server,
InetAddress serverAddr,
final IClientConfig clientConfig,
int attemptNumber,
int readTimeout) {
this.status = -1;
this.attempt = attemptNumber;
this.readTimeout = readTimeout;
Expand Down Expand Up @@ -141,6 +152,10 @@ public RequestAttempt(
}
}

if (serverAddr != null) {
ipAddress = serverAddr.getHostAddress();
}

if (clientConfig != null) {
this.connectTimeout = clientConfig.get(IClientConfigKey.Keys.ConnectTimeout);
}
Expand Down Expand Up @@ -200,6 +215,10 @@ public int getPort() {
return port;
}

public String getIpAddress() {
return ipAddress;
}

public String getRegion() {
return region;
}
Expand Down Expand Up @@ -256,6 +275,10 @@ public void setPort(int port) {
this.port = port;
}

public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}

public void setVip(String vip) {
this.vip = vip;
}
Expand Down Expand Up @@ -338,6 +361,11 @@ public ObjectNode toJsonNode() {
putNullableAttribute(root, "asg", asg);
putNullableAttribute(root, "instanceId", instanceId);
putNullableAttribute(root, "vip", vip);
putNullableAttribute(root, "ipAddress", ipAddress);

if (port > 0) {
root.put("port", port);
}

if (status < 1) {
root.put("readTimeout", readTimeout);
Expand Down
Expand Up @@ -130,8 +130,10 @@ public int getMaxRetriesForRequest(SessionContext context) {
}

@Override
public RequestAttempt newRequestAttempt(DiscoveryResult server, SessionContext zuulCtx, int attemptNum) {
return new RequestAttempt(server, config, attemptNum, config.get(CommonClientConfigKey.ReadTimeout));
public RequestAttempt newRequestAttempt(
DiscoveryResult server, InetAddress serverAddr, SessionContext zuulCtx, int attemptNum) {
return new RequestAttempt(
server, serverAddr, config, attemptNum, config.get(CommonClientConfigKey.ReadTimeout));
}

@Override
Expand Down
Expand Up @@ -70,7 +70,8 @@ void onRequestExecutionFailed(

void recordFinalResponse(final HttpResponseMessage resp);

RequestAttempt newRequestAttempt(final DiscoveryResult server, final SessionContext zuulCtx, int attemptNum);
RequestAttempt newRequestAttempt(
final DiscoveryResult server, final InetAddress serverAddr, final SessionContext zuulCtx, int attemptNum);

String getIpAddrFromServer(DiscoveryResult server);

Expand Down