-
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
feat: return whether configuration was updated as part of api response #21466
Conversation
Airbyte Code Coverage
|
I'm not quite sure what to do with this coverage comment 😅 I don't think my changes made it go down this much. |
final TemporalResponse<U> temporalResponse = executor.get(); | ||
final Optional<U> jobOutput = temporalResponse.getOutput(); | ||
final TemporalResponse<ConnectorJobOutput> temporalResponse = executor.get(); | ||
final Optional<ConnectorJobOutput> jobOutput = temporalResponse.getOutput(); |
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.
Removed some generics since they weren't necessary (each job returns a ConnectorJobOutput) and were making it harder to work with
@SuppressWarnings(UNCHECKED) | ||
@Test | ||
void testExecuteMappedOutput() { | ||
final UUID sourceDefinitionId = UUID.randomUUID(); | ||
final Supplier<TemporalResponse<Integer>> function = mock(Supplier.class); | ||
final Function<Integer, String> mapperFunction = Object::toString; | ||
when(function.get()).thenReturn(new TemporalResponse<>(42, createMetadata(true))); | ||
|
||
final ConnectorJobReportingContext jobContext = new ConnectorJobReportingContext(UUID.randomUUID(), SOURCE_DOCKER_IMAGE); | ||
final SynchronousResponse<String> response = schedulerClient | ||
.execute(ConfigType.DISCOVER_SCHEMA, jobContext, sourceDefinitionId, function, mapperFunction, WORKSPACE_ID); | ||
|
||
assertNotNull(response); | ||
assertEquals("42", response.getOutput()); | ||
assertEquals(ConfigType.DISCOVER_SCHEMA, response.getMetadata().getConfigType()); | ||
assertTrue(response.getMetadata().getConfigId().isPresent()); | ||
assertEquals(sourceDefinitionId, response.getMetadata().getConfigId().get()); | ||
assertTrue(response.getMetadata().isSucceeded()); | ||
assertEquals(LOG_PATH, response.getMetadata().getLogPath()); | ||
} | ||
|
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.
this test was doing the same thing as the one above (testExecuteJobSuccess) - the only difference was the one above's mapperFunction returned the same parameter it was given.
final Supplier<TemporalResponse<ConnectorJobOutput>> function = mock(Supplier.class); | ||
final Function<ConnectorJobOutput, UUID> mapperFunction = ConnectorJobOutput::getDiscoverCatalogId; |
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.
Changes required due to removing the generics - test now actually have to pass a ConnectorJobOutput
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.
Nice!
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.
Nice!
@@ -4200,6 +4200,9 @@ components: | |||
format: int64 | |||
succeeded: | |||
type: boolean | |||
connectorConfigurationUpdated: |
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 connectorConfigurationUpdated
and didUpdateConfiguration
both be the same name? Perhaps didUpdateConnectorConfiguration
works in both cases?
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.
I wanted to use didUpdateConnectorConfiguration
, but PMD or some other check yelled at me because it wanted the get method on SynchronousJobMetadata to start with is
:(
I can change the ConnectorJobOutput to be connectorConfigurationUpdated though
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.
Updated in 37b734d
public static Boolean getDidControlMessageChangeConfig(final JsonNode initialConfigJson, final AirbyteControlConnectorConfigMessage configMessage) { | ||
final Config newConfig = configMessage.getConfig(); | ||
final JsonNode newConfigJson = Jsons.jsonNode(newConfig); | ||
return !initialConfigJson.equals(newConfigJson); |
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.
This is OK, but calling out that this would would fail if the config JSON was re-ordered by the connector. However, the connector shouldn't just re-order it's config without a good reason...
Actually, jackson.equals()
should be positionally independant!
@pedroslopez just a note - the intention of the code coverage comment is just to prompt you to consider whether you've sufficiently tested your changes here, and provide some signal. As far as why it doesn't know that those files do have test coverage - the workers themselves live in |
What
Returns a new
connectorConfigurationUpdated
boolean as part of the job metadata in synchronous job responses.This will allow us to give the user the appropriate feedback / fetch the updated config on the frontend when jobs like
check
emit an updated configuration.I opted to do this on the worker side and send the output rather than comparing configs on the api handler since it actually turned out to be simpler than dealing with hydrating the config with secrets and other things that came up with that approach. Since the worker knows what was the initial config, doing the comparison on that side is pretty straightforward.
We only really need this for
check
at the moment, but since any jobs that use configs can update configs (e.g. discover), this was added across all synchronous jobs. This also made it easier to pass this info along regardless of success/failure statues.close #20913
Example response for a check that updated config:
...and for one that didn't:
How
connectorConfigurationUpdated
as part of theConnectorJobOutput
connectorConfigurationUpdated
would be false)connectorConfigurationUpdated
as part of theSynchronousJobMetadata
connectorConfigUpdated
to theSynchronousJobRead
api schema (and pass value rom above)