commit
b72c60320c
|
|
@ -102,6 +102,7 @@ machine.ws_agent.max_start_time_ms=60000
|
|||
machine.ws_agent.ping_delay_ms=2000
|
||||
machine.ws_agent.ping_conn_timeout_ms=2000
|
||||
machine.ws_agent.ping_timed_out_error_msg=Timeout reached. The Che server has been unable to verify that your workspace's agent has successfully booted. Either the workspace is unreachable, the agent had an error during startup, or your workspace is starting slowly. You can configure machine.ws_agent.max_start_time_ms in Che properties to increase the timeout.
|
||||
machine.ws_agent.agent_api.path=/ide/ext/
|
||||
|
||||
# Hosts listed here will be added to /etc/hosts of each workspace machine.
|
||||
# Add an entry here if you write a ws-agent extension that needs to communicate outside the machine
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import javax.ws.rs.HttpMethod;
|
|||
import javax.ws.rs.core.UriBuilder;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* Starts ws agent in the machine and waits until ws agent sends notification about its start
|
||||
|
|
@ -59,11 +58,11 @@ public class WsAgentLauncherImpl implements WsAgentLauncher {
|
|||
public WsAgentLauncherImpl(Provider<MachineManager> machineManagerProvider,
|
||||
HttpJsonRequestFactory httpJsonRequestFactory,
|
||||
@Named(WS_AGENT_PROCESS_START_COMMAND) String wsAgentStartCommandLine,
|
||||
@Named("api.endpoint") URI apiEndpoint,
|
||||
@Named("machine.ws_agent.max_start_time_ms") long wsAgentMaxStartTimeMs,
|
||||
@Named("machine.ws_agent.ping_delay_ms") long wsAgentPingDelayMs,
|
||||
@Named("machine.ws_agent.ping_conn_timeout_ms") int wsAgentPingConnectionTimeoutMs,
|
||||
@Named("machine.ws_agent.ping_timed_out_error_msg") String pingTimedOutErrorMessage) {
|
||||
@Named("machine.ws_agent.ping_timed_out_error_msg") String pingTimedOutErrorMessage,
|
||||
@Named("machine.ws_agent.agent_api.path") String wsAgentApiPath) {
|
||||
this.machineManagerProvider = machineManagerProvider;
|
||||
this.httpJsonRequestFactory = httpJsonRequestFactory;
|
||||
this.wsAgentStartCommandLine = wsAgentStartCommandLine;
|
||||
|
|
@ -71,8 +70,8 @@ public class WsAgentLauncherImpl implements WsAgentLauncher {
|
|||
this.wsAgentPingDelayMs = wsAgentPingDelayMs;
|
||||
this.wsAgentPingConnectionTimeoutMs = wsAgentPingConnectionTimeoutMs;
|
||||
this.pingTimedOutErrorMessage = pingTimedOutErrorMessage;
|
||||
// everest respond 404 to path to rest without trailing slash
|
||||
this.wsAgentPingPath = apiEndpoint.getPath().endsWith("/") ? apiEndpoint.getPath() : apiEndpoint.getPath() + "/";
|
||||
// everrest respond 404 to path to rest without trailing slash
|
||||
this.wsAgentPingPath = wsAgentApiPath;
|
||||
}
|
||||
|
||||
public static String getWsAgentProcessOutputChannel(String workspaceId) {
|
||||
|
|
@ -117,7 +116,7 @@ public class WsAgentLauncherImpl implements WsAgentLauncher {
|
|||
.build()
|
||||
.toString();
|
||||
return httpJsonRequestFactory.fromUrl(wsAgentPingUrl)
|
||||
.setMethod(HttpMethod.OPTIONS)
|
||||
.setMethod(HttpMethod.GET)
|
||||
.setTimeout(wsAgentPingConnectionTimeoutMs);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import javax.ws.rs.HttpMethod;
|
|||
import javax.ws.rs.core.UriBuilder;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
|
|
@ -51,7 +50,7 @@ public class WsAgentLauncherImplTest {
|
|||
private static final String WS_ID = "wsId";
|
||||
private static final String MACHINE_ID = "machineId";
|
||||
private static final String WS_AGENT_START_CMD_LINE = "cmdLine";
|
||||
private static final String API_ENDPOINT_PATH = "/some/path/";
|
||||
private static final String WS_AGENT_API_ENDPOINT_PATH = "/some/path/";
|
||||
private static final String WS_AGENT_PORT = Integer.toString(WsAgentLauncherImpl.WS_AGENT_PORT);
|
||||
private static final long WS_AGENT_MAX_START_TIME_MS = 1000;
|
||||
private static final long WS_AGENT_PING_DELAY_MS = 1;
|
||||
|
|
@ -82,11 +81,11 @@ public class WsAgentLauncherImplTest {
|
|||
wsAgentLauncher = new WsAgentLauncherImpl(() -> machineManager,
|
||||
requestFactory,
|
||||
WS_AGENT_START_CMD_LINE,
|
||||
new URI("http://localhost:8080" + API_ENDPOINT_PATH),
|
||||
WS_AGENT_MAX_START_TIME_MS,
|
||||
WS_AGENT_PING_DELAY_MS,
|
||||
WS_AGENT_PING_CONN_TIMEOUT_MS,
|
||||
WS_AGENT_TIMED_OUT_MESSAGE);
|
||||
WS_AGENT_TIMED_OUT_MESSAGE,
|
||||
WS_AGENT_API_ENDPOINT_PATH);
|
||||
pingRequest = mock(HttpJsonRequest.class, new SelfReturningAnswer());
|
||||
when(machineManager.getDevMachine(WS_ID)).thenReturn(machine);
|
||||
when(machine.getId()).thenReturn(MACHINE_ID);
|
||||
|
|
@ -114,10 +113,10 @@ public class WsAgentLauncherImplTest {
|
|||
wsAgentLauncher.startWsAgent(WS_ID);
|
||||
|
||||
verify(requestFactory).fromUrl(UriBuilder.fromUri(WS_AGENT_SERVER_URL)
|
||||
.replacePath(API_ENDPOINT_PATH)
|
||||
.replacePath(WS_AGENT_API_ENDPOINT_PATH)
|
||||
.build()
|
||||
.toString());
|
||||
verify(pingRequest).setMethod(HttpMethod.OPTIONS);
|
||||
verify(pingRequest).setMethod(HttpMethod.GET);
|
||||
verify(pingRequest).setTimeout(WS_AGENT_PING_CONN_TIMEOUT_MS);
|
||||
verify(pingRequest).request();
|
||||
verify(pingResponse).getResponseCode();
|
||||
|
|
@ -133,10 +132,10 @@ public class WsAgentLauncherImplTest {
|
|||
wsAgentLauncher.startWsAgent(WS_ID);
|
||||
|
||||
verify(requestFactory).fromUrl(UriBuilder.fromUri(WS_AGENT_SERVER_URL)
|
||||
.replacePath(API_ENDPOINT_PATH)
|
||||
.replacePath(WS_AGENT_API_ENDPOINT_PATH)
|
||||
.build()
|
||||
.toString());
|
||||
verify(pingRequest).setMethod(HttpMethod.OPTIONS);
|
||||
verify(pingRequest).setMethod(HttpMethod.GET);
|
||||
verify(pingRequest).setTimeout(WS_AGENT_PING_CONN_TIMEOUT_MS);
|
||||
verify(pingRequest, times(4)).request();
|
||||
verify(pingResponse).getResponseCode();
|
||||
|
|
@ -151,10 +150,10 @@ public class WsAgentLauncherImplTest {
|
|||
wsAgentLauncher.startWsAgent(WS_ID);
|
||||
|
||||
verify(requestFactory).fromUrl(UriBuilder.fromUri(WS_AGENT_SERVER_URL)
|
||||
.replacePath(API_ENDPOINT_PATH)
|
||||
.replacePath(WS_AGENT_API_ENDPOINT_PATH)
|
||||
.build()
|
||||
.toString());
|
||||
verify(pingRequest).setMethod(HttpMethod.OPTIONS);
|
||||
verify(pingRequest).setMethod(HttpMethod.GET);
|
||||
verify(pingRequest).setTimeout(WS_AGENT_PING_CONN_TIMEOUT_MS);
|
||||
verify(pingRequest, times(3)).request();
|
||||
verify(pingResponse, times(3)).getResponseCode();
|
||||
|
|
@ -225,23 +224,4 @@ public class WsAgentLauncherImplTest {
|
|||
|
||||
wsAgentLauncher.startWsAgent(WS_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldAddTrailingSlashToPingPath() throws Exception {
|
||||
String pingUrlWithoutTrailingSlash = WS_AGENT_SERVER_URL.substring(0, WS_AGENT_SERVER_URL.length() - 1);
|
||||
ServerImpl server = new ServerImpl(SERVER);
|
||||
server.setUrl(pingUrlWithoutTrailingSlash);
|
||||
doReturn(Collections.<String, Server>singletonMap(WS_AGENT_PORT, server)).when(machineRuntime).getServers();
|
||||
|
||||
wsAgentLauncher.startWsAgent(WS_ID);
|
||||
|
||||
verify(requestFactory).fromUrl(UriBuilder.fromUri(pingUrlWithoutTrailingSlash + "/")
|
||||
.replacePath(API_ENDPOINT_PATH)
|
||||
.build()
|
||||
.toString());
|
||||
verify(pingRequest).setMethod(HttpMethod.OPTIONS);
|
||||
verify(pingRequest).setTimeout(WS_AGENT_PING_CONN_TIMEOUT_MS);
|
||||
verify(pingRequest).request();
|
||||
verify(pingResponse).getResponseCode();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue