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

Disable all broken connections when source is refreshed #20208

Merged
merged 22 commits into from
Dec 9, 2022

Conversation

alovew
Copy link
Contributor

@alovew alovew commented Dec 7, 2022

When one connection's source is refreshed, we want to check each connection that uses that same source and disable them where necessary.

Changes are:

  • new ConfigRepository and ConnectionHandler methods to fetch all connections for a particular source id
  • updates in the SchedulerHandler to iterate through all connections for a particular source and check their diffs

@alovew alovew requested a review from a team as a code owner December 7, 2022 22:21
@octavia-squidington-iv octavia-squidington-iv added area/platform issues related to the platform area/server area/worker Related to worker labels Dec 7, 2022
@alovew alovew temporarily deployed to more-secrets December 7, 2022 22:23 — with GitHub Actions Inactive
@alovew alovew force-pushed the anne/pause-all-connections-with-source branch from e8cc8ce to fcb37b8 Compare December 7, 2022 23:28
@octavia-squidington-iv octavia-squidington-iv added the area/documentation Improvements or additions to documentation label Dec 7, 2022
@alovew alovew temporarily deployed to more-secrets December 7, 2022 23:30 — with GitHub Actions Inactive
@alovew alovew temporarily deployed to more-secrets December 7, 2022 23:30 — with GitHub Actions Inactive
@alovew alovew force-pushed the anne/pause-all-connections-with-source branch from fcb37b8 to 8432701 Compare December 8, 2022 21:08
@octavia-squidington-iv octavia-squidington-iv removed the area/documentation Improvements or additions to documentation label Dec 8, 2022
@alovew alovew temporarily deployed to more-secrets December 8, 2022 21:10 — with GitHub Actions Inactive
@alovew alovew temporarily deployed to more-secrets December 8, 2022 21:11 — with GitHub Actions Inactive
@alovew alovew temporarily deployed to more-secrets December 8, 2022 21:25 — with GitHub Actions Inactive
@alovew alovew temporarily deployed to more-secrets December 8, 2022 21:25 — with GitHub Actions Inactive
@@ -865,6 +865,20 @@ public List<StandardSync> listWorkspaceStandardSyncs(final UUID workspaceId, fin
return getStandardSyncsFromResult(connectionAndOperationIdsResult);
}

public List<StandardSync> listConnectionsBySource(final UUID sourceId, final boolean includeDeleted) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just put up a PR with a more complete version of this: https://github.com/airbytehq/airbyte/pull/20264/files#diff-2d29b293778e290157be96e22294c2df1fdfa7c72a48961d03396776446deeddR852
However, my PR might take longer to merge due to breaking UI changes.

connectionStatus = ConnectionStatus.INACTIVE;
} else {
connectionStatus = connectionRead.getStatus();
final ConnectionReadList connectionsForSource = connectionsHandler.listConnectionsForSource(discoverSchemaRequestBody.getSourceId(), false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would advocate for avoiding having handlers depend on other handlers. At the handler level, I am currently leaning towards using our DB abstraction directly until we introduce a better layer.
It might be worth checking with the team to agree on a direction moving forward here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh interesting, you mean use configPersistence directly instead of going through the connection handler? I may have misunderstood how we wanted to migrate this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and I don't think we agreed on a strategy here.

connectionStatus = connectionRead.getStatus();
}
updateObject.status(connectionStatus);
connectionsHandler.updateConnection(updateObject);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels very broad, from this function, I expect we only modify syncCatalog and the breaking change flag, but this function will actually override the whole object. Should we introduce a more scoped update here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a patch update even though the object is named ConnectionUpdate, so it is only modifying the breaking change field and status

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my point is that if we add other fields to the updateObject we could end up overriding fields by mistake.
I don't think it is a big issue currently, but this could lead to some surprises.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean adding other fields within this method here? we would only be updating other fields here if we explicitly stated them on the ConnectionUpdate object, but I think that would be expected

updateObject.status(connectionStatus);
connectionsHandler.updateConnection(updateObject);
if (connectionRead.getConnectionId().equals(discoverSchemaRequestBody.getConnectionId())) {
discoveredSchema.catalogDiff(diff).breakingChange(containsBreakingChange).connectionStatus(connectionStatus);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some description to the function to highlight that we are modifying the input?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just added a comment where we're calling the function - do you think that works?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it should be part of the documentation of this function.

@alovew alovew temporarily deployed to more-secrets December 8, 2022 23:40 — with GitHub Actions Inactive
@alovew alovew temporarily deployed to more-secrets December 8, 2022 23:40 — with GitHub Actions Inactive
updateObject.status(connectionStatus);
connectionsHandler.updateConnection(updateObject);
if (connectionRead.getConnectionId().equals(discoverSchemaRequestBody.getConnectionId())) {
discoveredSchema.catalogDiff(diff).breakingChange(containsBreakingChange).connectionStatus(connectionStatus);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it should be part of the documentation of this function.

@alovew alovew temporarily deployed to more-secrets December 9, 2022 00:43 — with GitHub Actions Inactive
@alovew alovew temporarily deployed to more-secrets December 9, 2022 00:44 — with GitHub Actions Inactive
@alovew alovew merged commit 0a8fc9e into master Dec 9, 2022
@alovew alovew deleted the anne/pause-all-connections-with-source branch December 9, 2022 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/platform issues related to the platform area/server area/worker Related to worker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants