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

Migrate airbyte-bootloader to Micronaut #21073

Merged
merged 25 commits into from
Jan 12, 2023

Conversation

jdpgrailsdev
Copy link
Contributor

@jdpgrailsdev jdpgrailsdev commented Jan 5, 2023

What

How

  • Convert airbyte-bootloader to a Micronaut application
  • Move configuration to Micronaut property source
  • Convert existing classes to singletons/use dependency injection
  • Add missing secret persistence type to airbyte-workers

Recommended reading order

  1. Application.java
  2. Bootloader.java
  3. application.yml
  4. build.gradle
  5. ProtocolVersionChecker.java
  6. ApplyDefinitionsHelper.java
  7. RemoteDefinitionsProvider.java
  8. PostLoadExecutor.java
  9. DefaultPostLoadExecutor.java
  10. SecretPersistence.java
  11. LocalTestingSecretPersistence.java
  12. SecretMigrator.java
  13. docker-compose.yml
  14. .env/.env.dev

Tests

  • All unit tests pass
  • Updated unit tests pass
  • Application builds locally
  • Application runs locally
  • Application runs successfully as part of a local Docker deployment
  • Tested creating and running a sync locally using database bootstraped by airbyte-bootloader

N.B.: This is a preview PR. I still need to integrate this into airbyte-cloud to verify everything works. Once I have done that, this PR will be moved from a draft to ready for review. However, I don't expect it to change very much, so feel free to do a first pass review.

@octavia-squidington-iv octavia-squidington-iv added area/platform issues related to the platform area/worker Related to worker kubernetes labels Jan 5, 2023
@jdpgrailsdev jdpgrailsdev force-pushed the jonathan/airbyte-bootloader-micronaut branch from 207aaf9 to 9b05e22 Compare January 5, 2023 18:18
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 5, 2023 18:21 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 5, 2023 18:21 — with GitHub Actions Inactive
Copy link
Contributor

@gosusnp gosusnp left a comment

Choose a reason for hiding this comment

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

Exciting to see a bootloader on micronaut, we're getting there!

I don't know if you tested the integration with cloud, but looking at some changes on the bootloader constructor, we may run into some issues.

.env Outdated
@@ -39,6 +39,10 @@ BASIC_AUTH_PASSWORD=password
BASIC_AUTH_PROXY_TIMEOUT=600

### DATABASE ###
# Airbyte Bootloader environment variables
BOOTLOADER_MIGRATION_BASELINE_VERSION=0.29.0.001
RUN_DATABASE_MIGRATION_ON_STARTUP=true
Copy link
Contributor

Choose a reason for hiding this comment

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

Any cases where we do not want to run migrations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gosusnp Don't know. This env var exists for some reason, so I suspect it was added for a particular case. We can obviously remove this in the future if we deem that it is not needed.

implementation libs.temporal.sdk
implementation libs.flyway.core
testAnnotationProcessor platform(libs.micronaut.bom)
testAnnotationProcessor libs.bundles.micronaut.test.annotation.processor
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, what happened to libs.flyway.core?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It got moved up in this block to ensure that we get the correct version.

airbyte-bootloader/src/main/resources/application.yml Outdated Show resolved Hide resolved
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 5, 2023 19:49 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 5, 2023 19:49 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 5, 2023 19:55 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 5, 2023 19:55 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 5, 2023 20:40 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 5, 2023 20:40 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev force-pushed the jonathan/airbyte-bootloader-micronaut branch from 87a9106 to 947d82b Compare January 5, 2023 20:59
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 5, 2023 21:01 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 5, 2023 21:02 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 5, 2023 21:22 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 5, 2023 21:22 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 6, 2023 15:40 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 6, 2023 15:41 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 6, 2023 16:19 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 6, 2023 16:19 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 6, 2023 17:20 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 6, 2023 17:20 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 6, 2023 19:20 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 11, 2023 16:17 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 11, 2023 16:17 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 11, 2023 16:21 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 11, 2023 16:21 — with GitHub Actions Inactive
@jdpgrailsdev
Copy link
Contributor Author

@davinchia The PR has been updated with the changes that we discussed earlier:

  • All application.yaml files have been updated to disable early fail in Hikaricp
  • The SecretPersistence interface and LocalTestingSecretPersistence class have been updated to decouple initialization from the constructor to make it compatible with dependency injection. The execution of the initialization logic is now performed by the SecretMigrator from the Bootloader.

@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 11, 2023 17:31 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev temporarily deployed to more-secrets January 11, 2023 17:31 — with GitHub Actions Inactive
@jdpgrailsdev jdpgrailsdev marked this pull request as ready for review January 11, 2023 17:41
@jdpgrailsdev jdpgrailsdev requested a review from a team as a code owner January 11, 2023 17:41
connection-test-query: SELECT 1
connection-timeout: 30000
idle-timeout: 600000
initialization-fail-timeout: -1 # Disable fail fast checking to avoid issues due to other pods not being started in time
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for the comment

@@ -18,6 +18,15 @@
@SuppressWarnings("PMD.MissingOverride")
public interface SecretPersistence extends ReadOnlySecretPersistence {

/**
* Performs any initialization prior to utilization of the persistence object. This exists to make
Copy link
Contributor

Choose a reason for hiding this comment

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

+1


implementation 'commons-cli:commons-cli:1.4'
Copy link
Contributor

Choose a reason for hiding this comment

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

huh, didn't realise this wasn't already in a deps.toml.

}

// TODO will be called automatically by the dependency injection framework on object creation
@PostConstruct
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, what does this do?

Copy link
Contributor Author

@jdpgrailsdev jdpgrailsdev Jan 11, 2023

Choose a reason for hiding this comment

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

@davinchia This tells the DI framework to run this method after all required singletons used by this singleton are created. It's basically a hook to run some additional init logic. See https://docs.oracle.com/javaee/7/api/javax/annotation/PostConstruct.html for more details.

@@ -33,6 +34,8 @@ public class SecretPersistenceBeanFactory {
pattern = "(?i)^(?!google_secret_manager).*")
@Requires(property = "airbyte.secret.persistence",
pattern = "(?i)^(?!vault).*")
@Requires(property = "airbyte.secret.persistence",
pattern = "(?i)^(?!aws_secret_manager).*")
Copy link
Contributor

Choose a reason for hiding this comment

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

oh my first time seeing this, what does the pattern do 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.

If the value does NOT equal the string (case insensitive).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davinchia I should add that once this is merged, I plan on doing a second pass to clean this up/consolidate this so that we don't have this in multiple places.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good. just from a reader pov, it's not immediately clear why we need the inverse match here.

@@ -24,14 +24,10 @@ services:
container_name: airbyte-bootloader
environment:
- AIRBYTE_VERSION=${VERSION}
- CONFIG_DATABASE_PASSWORD=${CONFIG_DATABASE_PASSWORD:-}
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we removing these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are no longer used. We reference the DATABASE_X env vars only. We could reintroduce the separate ones if necessary.

Copy link
Contributor

@davinchia davinchia Jan 11, 2023

Choose a reason for hiding this comment

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

ah. if these are no longer used, we should also remove them from the EnvConfigs file.

although, maybe a good idea to wait on that since we haven't yet figured out how we want to track all configuration information globally. i.e. a master list of configuration that our micronaut application yamls accept.

Copy link
Contributor

Choose a reason for hiding this comment

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

no need to action now. thinking out loud with you

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davinchia Agreed. Once everything is converted to Micronaut, there will be a pass to remove EnvConfigs entirely and clean up the environment variables.

Copy link
Contributor

Choose a reason for hiding this comment

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

and I hope consolidate into one master list for reference :)


Exceptions.toRuntime(() -> {
@Override
public void initialize() throws SQLException {
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand your previous comment on the test set up now

setCurrentProtocolRangeRange(V0_0_0, V2_0_0);
setTargetProtocolRangeRange(V0_0_0, V2_0_0);
final ProtocolVersionChecker protocolVersionChecker =
Copy link
Contributor

Choose a reason for hiding this comment

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

I appreciate you cleaning up the tests as you go

Copy link
Contributor

@davinchia davinchia left a comment

Choose a reason for hiding this comment

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

Nice work!

I appreciate the detailed write up, the comments and the minor clean ups here and there.

@jdpgrailsdev jdpgrailsdev merged commit 7676af5 into master Jan 12, 2023
@jdpgrailsdev jdpgrailsdev deleted the jonathan/airbyte-bootloader-micronaut branch January 12, 2023 14:47
jbfbell pushed a commit that referenced this pull request Jan 13, 2023
* Migrate airbyte-bootloader to Micronaut

* PR feedback

* More PR feedback

* Rename variable for clarity

* Add properties to support cloud

* Formatting

* Use default values for env vars

* Re-organization to support cloud overrides

* Disable conditional logging

* More singleton cleanup

* test: try CI without fluentbit

* Revert "test: try CI without fluentbit"

This reverts commit 8fa0f74.

* test: enable SSH on EC2 runner

* Revert "test: enable SSH on EC2 runner"

This reverts commit e4867aa.

* Avoid early database connection on startup

* Fix compile issues from refactor

* Formatting

Co-authored-by: perangel <perangel@gmail.com>
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
6 participants