forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert container-orchestrator to micronaut (airbytehq#19396)
* wip; add micronaut * add additional json deserializer methods * wip; converting to micronaut * misc cleanup * wip; broken * wip; still broken * wip * formatting * minor code cleanup; no actual changes * wip; still broken * removed commented out code; no longer broken * wip; clean-up micronaut code * cleanup; format * fix pmd issues * remove unused file * init ApplicationTest * edited link (airbytehq#19444) * move 'Example values' into intl (airbytehq#19446) * Revert "Update action.yml (airbytehq#19416)" (airbytehq#19450) This reverts commit 78fb528. * Notifications Workflow (airbytehq#18735) * notification workflow * Bmoric/remove unused code (airbytehq#19188) * Tmp * Move when the deletion is performed * Re-enable disable test * PR comments * Use cancel * rename * Fix test and version check position * remove unused temporal deletion code * Remove false todo * Rm repeated test * Rm unused import * Make sure that long running activity are not retried (airbytehq#19452) * Parse list of dicts in json_schema_helper.find_nodes() (airbytehq#19386) * Get test on nested list/dict passing - use index to query next object for list * Fix flakecheck * Test that get_node provides correct value * Improve test and test cases * Rewrite method for better comprehension * Add test for base-level key. Rewrite method for comprehension and handling this case * adding tests * fix test * formatting * remove unused dependencies * add missing test resource * format * add missing test resource (real) * format * add back protocol-models dep * format * pr feedback; log stacktrace Co-authored-by: Sophia Wiley <[email protected]> Co-authored-by: Lake Mossman <[email protected]> Co-authored-by: Topher Lubaway <[email protected]> Co-authored-by: Anne <[email protected]> Co-authored-by: Benoit Moriceau <[email protected]> Co-authored-by: Ella Rohm-Ensing <[email protected]>
- Loading branch information
1 parent
77112b0
commit 1cdfdbe
Showing
35 changed files
with
1,258 additions
and
628 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...e-container-orchestrator/src/main/java/io/airbyte/container_orchestrator/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.container_orchestrator; | ||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
import io.airbyte.commons.logging.LoggingHelper; | ||
import io.airbyte.commons.logging.MdcScope; | ||
import io.airbyte.container_orchestrator.orchestrator.JobOrchestrator; | ||
import io.airbyte.workers.process.AsyncKubePodStatus; | ||
import io.micronaut.runtime.Micronaut; | ||
import jakarta.inject.Named; | ||
import jakarta.inject.Singleton; | ||
import java.lang.invoke.MethodHandles; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Entrypoint for the application responsible for launching containers and handling all message | ||
* passing for replication, normalization, and dbt. Also, the current version relies on a heartbeat | ||
* from a Temporal worker. This will also be removed in the future so this can run fully async. | ||
* <p> | ||
* This application retrieves most of its configuration from copied files from the calling Temporal | ||
* worker. | ||
* <p> | ||
* This app uses default logging which is directly captured by the calling Temporal worker. In the | ||
* future this will need to independently interact with cloud storage. | ||
*/ | ||
@SuppressWarnings({"PMD.AvoidCatchingThrowable", "PMD.DoNotTerminateVM", "PMD.AvoidFieldNameMatchingTypeName"}) | ||
@Singleton | ||
public class Application { | ||
|
||
public static void main(final String[] args) { | ||
// To mimic previous behavior, assume an exit code of 1 unless Application.run returns otherwise. | ||
var exitCode = 1; | ||
try (final var ctx = Micronaut.run(Application.class, args)) { | ||
exitCode = ctx.getBean(Application.class).run(); | ||
} catch (final Throwable t) { | ||
log.error("could not run {}", t.getMessage(), t); | ||
} finally { | ||
// this mimics the pre-micronaut code, unsure if there is a better way in micronaut to ensure a | ||
// non-zero exit code | ||
System.exit(exitCode); | ||
} | ||
} | ||
|
||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); | ||
|
||
private final String application; | ||
private final JobOrchestrator<?> jobOrchestrator; | ||
private final AsyncStateManager asyncStateManager; | ||
|
||
public Application(@Named("application") final String application, | ||
final JobOrchestrator<?> jobOrchestrator, | ||
final AsyncStateManager asyncStateManager) { | ||
this.application = application; | ||
this.jobOrchestrator = jobOrchestrator; | ||
this.asyncStateManager = asyncStateManager; | ||
} | ||
|
||
/** | ||
* Configures logging/mdc scope, and creates all objects necessary to handle state updates. | ||
* <p> | ||
* Handles state updates (including writing failures) and running the job orchestrator. As much of | ||
* the initialization as possible should go in here, so it's logged properly and the state storage | ||
* is updated appropriately. | ||
*/ | ||
@VisibleForTesting | ||
int run() { | ||
// set mdc scope for the remaining execution | ||
try (final var mdcScope = new MdcScope.Builder() | ||
.setLogPrefix(application) | ||
.setPrefixColor(LoggingHelper.Color.CYAN_BACKGROUND) | ||
.build()) { | ||
|
||
asyncStateManager.write(AsyncKubePodStatus.INITIALIZING); | ||
asyncStateManager.write(AsyncKubePodStatus.RUNNING); | ||
asyncStateManager.write(AsyncKubePodStatus.SUCCEEDED, jobOrchestrator.runJob().orElse("")); | ||
} catch (final Throwable t) { | ||
log.error("Killing orchestrator because of an Exception", t); | ||
asyncStateManager.write(AsyncKubePodStatus.FAILED); | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.