Skip to content

Commit

Permalink
🎉 Set max_sync_timeout in days by env vars (airbytehq#5297)
Browse files Browse the repository at this point in the history
* Set max_sync_timeout in days by env vars

* update name var to MAX_SYNC_TIMEOUT_DAYS
  • Loading branch information
vladimir-remar authored Aug 23, 2021
1 parent 088a138 commit fe8f7fa
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,5 @@ RESOURCE_MEMORY_LIMIT=
MAX_RETRIES_PER_ATTEMPT=3
MAX_SYNC_JOB_ATTEMPTS=3

# Time in days to reach a timeout to cancel the synchronization
MAX_SYNC_TIMEOUT_DAYS=3
1 change: 1 addition & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ API_URL=/api/v1/
INTERNAL_API_HOST=airbyte-server:8001
MAX_RETRIES_PER_ATTEMPT=3
MAX_SYNC_JOB_ATTEMPTS=3
MAX_SYNC_TIMEOUT_DAYS=3
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public interface Configs {

int getMaxSyncJobAttempts();

int getMaxSyncTimeoutDays();

String getWebappUrl();

String getWorkspaceDockerMount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class EnvConfigs implements Configs {
public static final String WEBAPP_URL = "WEBAPP_URL";
public static final String MAX_RETRIES_PER_ATTEMPT = "MAX_RETRIES_PER_ATTEMPT";
public static final String MAX_SYNC_JOB_ATTEMPTS = "MAX_SYNC_JOB_ATTEMPTS";
public static final String MAX_SYNC_TIMEOUT_DAYS = "MAX_SYNC_TIMEOUT_DAYS";
private static final String MINIMUM_WORKSPACE_RETENTION_DAYS = "MINIMUM_WORKSPACE_RETENTION_DAYS";
private static final String MAXIMUM_WORKSPACE_RETENTION_DAYS = "MAXIMUM_WORKSPACE_RETENTION_DAYS";
private static final String MAXIMUM_WORKSPACE_SIZE_MB = "MAXIMUM_WORKSPACE_SIZE_MB";
Expand Down Expand Up @@ -156,6 +157,11 @@ public int getMaxSyncJobAttempts() {
return Integer.parseInt(getEnvOrDefault(MAX_SYNC_JOB_ATTEMPTS, "3"));
}

@Override
public int getMaxSyncTimeoutDays() {
return Integer.parseInt(getEnvOrDefault(MAX_SYNC_TIMEOUT_DAYS, "3"));
}

@Override
public String getConfigDatabaseUser() {
// Default to reuse the job database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ class WorkflowImpl implements SyncWorkflow {

private static final Logger LOGGER = LoggerFactory.getLogger(WorkflowImpl.class);

private static final int MAX_SYNC_TIMEOUT_DAYS = new EnvConfigs().getMaxSyncTimeoutDays();

private static final ActivityOptions options = ActivityOptions.newBuilder()
.setScheduleToCloseTimeout(Duration.ofDays(3))
.setScheduleToCloseTimeout(Duration.ofDays(MAX_SYNC_TIMEOUT_DAYS))
.setCancellationType(ActivityCancellationType.WAIT_CANCELLATION_COMPLETED)
.setRetryOptions(TemporalUtils.NO_RETRY)
.build();
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ services:
- RESOURCE_MEMORY_LIMIT=${RESOURCE_MEMORY_LIMIT}
- MAX_RETRIES_PER_ATTEMPT=${MAX_RETRIES_PER_ATTEMPT}
- MAX_SYNC_JOB_ATTEMPTS=${MAX_SYNC_JOB_ATTEMPTS}
- MAX_SYNC_TIMEOUT_DAYS=${MAX_SYNC_TIMEOUT_DAYS}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- workspace:${WORKSPACE_ROOT}
Expand Down

0 comments on commit fe8f7fa

Please sign in to comment.