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

process config control messages during check and discover #20894

Merged
merged 78 commits into from
Jan 6, 2023

Conversation

pedroslopez
Copy link
Contributor

@pedroslopez pedroslopez commented Dec 28, 2022

What

Process config control messages in check and discover calls to support connectors with short-lived/single-use refresh tokens.

closes #20145

How

  • Call ConnectorConfigUpdater introduced in feat(Platform): update actor configuration when receiving control messages from connectors during sync #19811 from DefaultCheckConnectionWorker / DefaultDiscoverCatalogWorker to update the connector config if a config control message has been found.

    • For discover, use the existing sourceId from the input.
    • For check, add actorType and actorId to the input so we can call updateSource/updateDestination accordingly.
  • In order to support refreshing tokens during check_connection_for_update, sourceId and destinationId are now being passed through. (see caviat in "User Impact" section)

image

🚨 User Impact / Known Issues 🚨

Whenever a connector emits a config control message during check or discover, the airbyte platform will now persist the updated configuration.

Configuration updates via UI

There's an interesting side effect here that can happen when users are updating configuration via the UI. Before saving the new configuration, we perform a check on the configuration. If the check fails, we do not persist the user's changes. After this PR, if the connector issues a token refresh during that preliminary check, we will persist the new configuration. This means that a failed check may now cause your config to be updated with invalid values.

The following diagram illustrates the happy path of CHECK succeeding:

image

The above scenario works as expected and the updated config + new tokens emitted during CHECK are saved. Note that we are assuming that the connector updated secret fields here that have not been modified by the user in the form. Non-secret field values would be overwritten by the user's provided values in the later update call (see #20913)

Here's what happens in the case of CHECK failing or throwing an error:

image

Because we want to save the new token values even on a failed check (since old tokens are invalidated), this creates a side effect of updating the configuration with the values that led to the failed check. This means that if you had a working connector before but started making some changes to the configuration that rendered it invalid, now your connector isn't properly configured. Before this PR, changes leading to a failed check would just not be persisted and your previously working configuration would still be saved. However, if we didn't do this then every failed check would need a manual re-authentication.

Connector creation with eager token refreshes

When first setting up a connector, the check call happens before the connector has been saved in the database. This means that we can't update the configuration at this phase. If the connector performs a token refresh and invalidates the old tokens, we have no way of saving these currently. See https://github.com/airbytehq/airbyte-internal-issues/issues/1260 for more details.

@pedroslopez pedroslopez temporarily deployed to more-secrets January 6, 2023 16:14 — with GitHub Actions Inactive
@pedroslopez pedroslopez temporarily deployed to more-secrets January 6, 2023 16:14 — with GitHub Actions Inactive
Base automatically changed from pedroslopez/config-control-msg to master January 6, 2023 17:17
@pedroslopez pedroslopez requested a review from a team as a code owner January 6, 2023 17:17
@pedroslopez pedroslopez temporarily deployed to more-secrets January 6, 2023 18:10 — with GitHub Actions Inactive
@pedroslopez pedroslopez temporarily deployed to more-secrets January 6, 2023 18:10 — with GitHub Actions Inactive
@pedroslopez pedroslopez closed this Jan 6, 2023
@pedroslopez pedroslopez force-pushed the pedroslopez/synchronous-job-control-msg branch from 60987e2 to b526aac Compare January 6, 2023 18:34
@octavia-squidington-iv octavia-squidington-iv removed area/worker Related to worker area/documentation Improvements or additions to documentation area/api Related to the api area/server area/platform issues related to the platform labels Jan 6, 2023
@pedroslopez pedroslopez reopened this Jan 6, 2023
@octavia-squidington-iv octavia-squidington-iv added area/api Related to the api area/documentation Improvements or additions to documentation area/platform issues related to the platform area/server area/worker Related to worker labels Jan 6, 2023
@pedroslopez pedroslopez temporarily deployed to more-secrets January 6, 2023 18:46 — with GitHub Actions Inactive
@pedroslopez pedroslopez temporarily deployed to more-secrets January 6, 2023 18:46 — with GitHub Actions Inactive
@pedroslopez pedroslopez merged commit 01e256f into master Jan 6, 2023
@pedroslopez pedroslopez deleted the pedroslopez/synchronous-job-control-msg branch January 6, 2023 19:24
jbfbell pushed a commit that referenced this pull request Jan 13, 2023
* track latest config message

* pass new config as part of outputs

* persist new config

* persist config as the messages come through, dont set output

* clean up old implementation

* accept control messages for destinations

* get api client from micronaut

* mask instance-wide oauth params when updating configs

* defaultreplicationworker tests

* formatting

* tests for source/destination handlers

* rm todo

* refactor test a bit to fix pmd

* fix pmd

* fix test

* add PersistConfigHelperTest

* update message tracker comment

* fix pmd

* format

* move ApiClientBeanFactory to commons-worker, use in container-orchestrator

* pull out config updating to separate methods

* add jitter

* rename PersistConfigHelper -> UpdateConnectorConfigHelper, docs

* fix exception type

* fmt

* move message type check into runnable

* formatting

* pass api client env vars to container orchestrator

* pass micronaut envs to container orchestrator

* print stacktrace for debugging

* different api host for container orchestrator

* fix default env var

* format

* fix errors after merge

* set source and destination actor id as part of the sync input

* fix: get destination definition

* fix null ptr

* remove "actor" from naming

* fix missing change from rename

* revert ContainerOrchestratorConfigBeanFactory changes

* inject sourceapi/destinationapi directly rather than airbyteapiclient

* UpdateConnectorConfigHelper -> ConnectorConfigUpdater

* rm log

* fix test

* dont fail on config update error

* process control messages for discover jobs

* process control messages for CHECK

* persist config updates on check_connection_for_update

* get last config message rather than first

* fix pmd

* fix failing tests

* add tests

* source id not required for check connection (create case)

* suppress pmd warning for BusyWait literal

* source id not required for checkc onnection (create case) (p2)

* pass id, not full config to runnables/accept control message

* add new config required for api client

* add test file

* remove debugging logs

* rename method (getLast -> getMostRecent)

* rm version check (re-added this in by mistake on merge)

* fix test compatibility

* simplify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Related to the api area/documentation Improvements or additions to documentation 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.

Update configuration from control messages in synchronous commands
4 participants