-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
refresh before syncs when feature flag is on #19888
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
20f5474
refresh before syncs when feature flag is on
alovew 87b0b72
tests
alovew 998bd81
fix activity
alovew 291db74
add connection id
alovew 0093924
logging
alovew 5c35008
inject envvariablefeatureflags
alovew ca636b2
inject envvariable feature flags
alovew c6fd2df
remove logging
alovew 2370fdf
inject into activities instead of workflow
alovew 8302e23
remove from connection manager workflow
alovew c0f6bb1
remove in tests
alovew 8acca50
try catch
alovew b9a869b
auto detect schema version
alovew 6d99d6c
Catch errors
alovew 9b013fe
tests
alovew f09f87b
fix test
alovew 3fc3751
update tests
alovew 825e42a
fix test
alovew a35fc50
use sourceApi directly
alovew 6362a97
fix test
alovew ed7c615
formatting
alovew c3faa67
Move error handling into activities
alovew 6b70630
separate singleton for apiclient
alovew c98cd7b
add comments
alovew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,16 +17,21 @@ | |
import io.airbyte.config.NormalizationSummary; | ||
import io.airbyte.config.OperatorDbtInput; | ||
import io.airbyte.config.OperatorWebhookInput; | ||
import io.airbyte.config.StandardSync.Status; | ||
import io.airbyte.config.StandardSyncInput; | ||
import io.airbyte.config.StandardSyncOperation; | ||
import io.airbyte.config.StandardSyncOperation.OperatorType; | ||
import io.airbyte.config.StandardSyncOutput; | ||
import io.airbyte.config.StandardSyncSummary; | ||
import io.airbyte.config.StandardSyncSummary.ReplicationStatus; | ||
import io.airbyte.config.SyncStats; | ||
import io.airbyte.config.WebhookOperationSummary; | ||
import io.airbyte.metrics.lib.ApmTraceUtils; | ||
import io.airbyte.persistence.job.models.IntegrationLauncherConfig; | ||
import io.airbyte.persistence.job.models.JobRunConfig; | ||
import io.airbyte.protocol.models.ConfiguredAirbyteCatalog; | ||
import io.airbyte.workers.temporal.annotations.TemporalActivityStub; | ||
import io.airbyte.workers.temporal.scheduling.activities.ConfigFetchActivity; | ||
import io.temporal.workflow.Workflow; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
@@ -42,6 +47,8 @@ public class SyncWorkflowImpl implements SyncWorkflow { | |
private static final int CURRENT_VERSION = 2; | ||
private static final String NORMALIZATION_SUMMARY_CHECK_TAG = "normalization_summary_check"; | ||
private static final int NORMALIZATION_SUMMARY_CHECK_CURRENT_VERSION = 1; | ||
private static final String AUTO_DETECT_SCHEMA_TAG = "auto_detect_schema"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIt: make sure that we have an issue to disable that after it is deployed. |
||
private static final int AUTO_DETECT_SCHEMA_VERSION = 1; | ||
|
||
@TemporalActivityStub(activityOptionsBeanName = "longRunActivityOptions") | ||
private ReplicationActivity replicationActivity; | ||
|
@@ -55,6 +62,10 @@ public class SyncWorkflowImpl implements SyncWorkflow { | |
private NormalizationSummaryCheckActivity normalizationSummaryCheckActivity; | ||
@TemporalActivityStub(activityOptionsBeanName = "shortActivityOptions") | ||
private WebhookOperationActivity webhookOperationActivity; | ||
@TemporalActivityStub(activityOptionsBeanName = "shortActivityOptions") | ||
private RefreshSchemaActivity refreshSchemaActivity; | ||
@TemporalActivityStub(activityOptionsBeanName = "shortActivityOptions") | ||
private ConfigFetchActivity configFetchActivity; | ||
|
||
@Trace(operationName = WORKFLOW_TRACE_OPERATION_NAME) | ||
@Override | ||
|
@@ -72,6 +83,28 @@ public StandardSyncOutput run(final JobRunConfig jobRunConfig, | |
|
||
final int version = Workflow.getVersion(VERSION_LABEL, Workflow.DEFAULT_VERSION, CURRENT_VERSION); | ||
final String taskQueue = Workflow.getInfo().getTaskQueue(); | ||
|
||
final int autoDetectSchemaVersion = | ||
Workflow.getVersion(AUTO_DETECT_SCHEMA_TAG, Workflow.DEFAULT_VERSION, AUTO_DETECT_SCHEMA_VERSION); | ||
|
||
if (autoDetectSchemaVersion >= AUTO_DETECT_SCHEMA_VERSION) { | ||
final Optional<UUID> sourceId = configFetchActivity.getSourceId(connectionId); | ||
|
||
if (!sourceId.isEmpty() && refreshSchemaActivity.shouldRefreshSchema(sourceId.get())) { | ||
LOGGER.info("Refreshing source schema..."); | ||
refreshSchemaActivity.refreshSchema(sourceId.get(), connectionId); | ||
} | ||
|
||
final Optional<Status> status = configFetchActivity.getStatus(connectionId); | ||
if (!status.isEmpty() && Status.INACTIVE == status.get()) { | ||
LOGGER.info("Connection is disabled. Cancelling run."); | ||
final StandardSyncOutput output = | ||
new StandardSyncOutput() | ||
.withStandardSyncSummary(new StandardSyncSummary().withStatus(ReplicationStatus.CANCELLED).withTotalStats(new SyncStats())); | ||
return output; | ||
} | ||
} | ||
|
||
StandardSyncOutput syncOutput = | ||
replicationActivity.replicate(jobRunConfig, sourceLauncherConfig, destinationLauncherConfig, syncInput, taskQueue); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: Could be worth adding a comment explaining that we swallow the exception here to avoid blocking the replication if we fail to refresh.