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 timeout server configurations to action execution #5935

Merged
merged 10 commits into from
Sep 19, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public APIClient() {

// todo: read connection configurations related to the http client of actions from the server configuration.
// Initialize the http client. Set connection time out to 2s and read time out to 5s.
int readTimeout = 5000;
int connectionRequestTimeout = 2000;
int connectionTimeout = 2000;
int readTimeout = ActionExecutorConfig.getInstance().getHttpReadTimeout();
int connectionRequestTimeout = ActionExecutorConfig.getInstance().getHttpConnectionRequestTimeout();
int connectionTimeout = ActionExecutorConfig.getInstance().getHttpConnectionTimeout();

RequestConfig config = RequestConfig.custom()
.setConnectTimeout(connectionTimeout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public class ActionExecutorConfig {
"Actions.ActionRequest.ExcludedHeaders.Header";
private static final String EXCLUDED_PARAMS_IN_ACTION_REQUEST_PROPERTY =
"Actions.ActionRequest.ExcludedParameters.Parameter";
private static final String HTTP_READ_TIMEOUT_PROPERTY = "Actions.HTTPConnections.HTTPReadTimeout";
private static final String HTTP_CONNECTION_REQUEST_TIMEOUT_PROPERTY =
"Actions.HTTPConnections.HTTPConnectionRequestTimeout";
private static final String HTTP_CONNECTION_TIMEOUT_PROPERTY = "Actions.HTTPConnections.HTTPConnectionTimeout";
private static final int DEFAULT_HTTP_READ_TIMEOUT = 5000;
private static final int DEFAULT_HTTP_CONNECTION_REQUEST_TIMEOUT = 2000;
private static final int DEFAULT_HTTP_CONNECTION_TIMEOUT = 2000;
osandamaleesha marked this conversation as resolved.
Show resolved Hide resolved

private ActionExecutorConfig() {

Expand Down Expand Up @@ -73,6 +80,35 @@ public boolean isExecutionForActionTypeEnabled(ActionType actionType) {
}
}

public int getHttpReadTimeout() {

return parseTimeoutConfig(HTTP_READ_TIMEOUT_PROPERTY, DEFAULT_HTTP_READ_TIMEOUT);
}

public int getHttpConnectionRequestTimeout() {

return parseTimeoutConfig(HTTP_CONNECTION_REQUEST_TIMEOUT_PROPERTY, DEFAULT_HTTP_CONNECTION_REQUEST_TIMEOUT);
}

public int getHttpConnectionTimeout() {

return parseTimeoutConfig(HTTP_CONNECTION_TIMEOUT_PROPERTY, DEFAULT_HTTP_CONNECTION_TIMEOUT);
}
osandamaleesha marked this conversation as resolved.
Show resolved Hide resolved

private int parseTimeoutConfig(String timeoutTypeName, int defaultTimeout) {

int timeoutPropertyValue = defaultTimeout;
String timeoutValue = (String) IdentityConfigParser.getInstance().getConfiguration().get(timeoutTypeName);
if (StringUtils.isNotBlank(timeoutValue)) {
try {
timeoutPropertyValue = Integer.parseInt(timeoutValue);
} catch (Exception e) {
osandamaleesha marked this conversation as resolved.
Show resolved Hide resolved
LOG.warn("Error occurred while parsing the '" + timeoutTypeName + "' property value in identity.xml.", e);
}
}
return timeoutPropertyValue;
}
osandamaleesha marked this conversation as resolved.
Show resolved Hide resolved

private boolean isActionTypeEnabled(String actionTypePropertyName) {

boolean isActionTypeEnabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2020,6 +2020,11 @@
</OutboundProvisioning>

<Actions>
<HTTPConnections>
<HTTPConnectionTimeout>{{actions.http_connections.connection_timeout}}</HTTPConnectionTimeout>
<HTTPReadTimeout>{{actions.http_connections.read_timeout}}</HTTPReadTimeout>
<HTTPConnectionRequestTimeout>{{actions.http_connections.request_timeout}}</HTTPConnectionRequestTimeout>
</HTTPConnections>
<MaximumActionsPerActionType>{{actions.maximum_actions_per_action_type}}</MaximumActionsPerActionType>
<ActionRequest>
<ExcludedHeaders>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,9 @@

"on_demand_config.on_initial_use.enable_sms_otp_password_recovery_if_connector_enabled": false,

"actions.http_connections.read_timeout": 5000,
osandamaleesha marked this conversation as resolved.
Show resolved Hide resolved
"actions.http_connections.request_timeout": 2000,
"actions.http_connections.connection_timeout": 2000,
"actions.maximum_actions_per_action_type": 1,
"actions.action_request.excluded_headers": [
"authorization",
Expand Down
Loading