-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
🪟🎉 Connector form: Reload config if updated during connection check #21839
Conversation
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 tested this out locally following your instructions, and I noticed some weird behavior which I think is only happening because the test isn't matching prod behavior, but I wanted to double check my understanding:
- I tried editing the
Pokemon Name
on one of my existing connectors, and when I clickedTest and save
, theSource name
was updated with the current timestamp as expected, but thePokemon Name
was set back to the name that had been saved to the source before I changed it. - I believe this is expected from this test though, because we just modified the airbyte-server to return a response with the
connectorConfigurationUpdated
flag set to true, and only the connector name is changed in the response ofgetSource()
, so the new pokemon name was never actually saved. - In the production use case that this PR is handling, the
checkConnectionToSourceForUpdate()
call would actually update the source to have the new pokemon name, so the subsequentgetSource()
call would respond with that new name, and it therefore wouldn't go back to the old name.
If the above sounds correct to you, then I think the changes here look good.
I just had one question about a return
that you added, but I think it can be fixed without me needing to give it another look
return await testConnector(connectorCardValues); | ||
trackTestConnectorSuccess(selectedConnectorDefinition); |
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.
If we return
here on line 134, doesn't that mean we will never execute the next line to track the test success?
It feels like we should instead be saving the result of testConnector()
to a variable, then calling track, then returning that variable
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.
Good catch, no idea how I missed this. @timroes is there a reason not to fail the build on unreachable code?
Exactly, that's how I understood the flow. Just to make sure - @pedroslopez can you confirm that if |
Yep! With the caveat that it’s likely not the exact config object sent as part of the request, since this happens because the connector itself wanted to change some config values. |
What
Fixes #21041
This PR will make sure updates to the configuration of an existing source or destination during the connection check won't be lost due to a subsequent update dispatched by the UI.
How
The flag indicating that the config got updated during the check is already returned to the webapp (
jobInfo.connectorConfigurationUpdated
). Inairbyte-webapp/src/views/Connector/ConnectorCard/ConnectorCard.tsx
this response can be checked and if it's set, the actualupdate
call can be prevented as it has been done implicitly by the connection check.At this point the form should be reloaded with the new config. This is done by passing down a
reloadConfig
callback which is callingqueryClient.invalidateQueries
for the source/destination which will cause react-query to reload the config and pass down the new state.How to test
Unfortunately it's hard to cause a real update-on-check to happen - I tested by mocking the server like this (need to run
./gradlew airbyte-server:assemble
and restart the docker containers):checkConnectionToSourceForUpdate
automatically sets the flag to true for all connection checks. ThegetSource
endpoint adds the current time in ms to the name of the connection to make it obvious the form actually updated.https://www.loom.com/share/7d73b667dc4b40378f268ad8bf987f22