Skip to content

Commit

Permalink
fix: disable automatic cloud environment deduction (#14965)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpgrailsdev committed Jan 9, 2025
1 parent 0c2bb4f commit 1b4fc7b
Show file tree
Hide file tree
Showing 34 changed files with 57 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ public class Application {

public static void main(final String[] args) {
try {
final ApplicationContext applicationContext = Micronaut.run(Application.class, args);
final ApplicationContext applicationContext = Micronaut.build(args)
.deduceCloudEnvironment(false)
.deduceEnvironment(false)
.mainClass(Application.class)
.start();
final Bootloader bootloader = applicationContext.getBean(Bootloader.class);
bootloader.load();
System.exit(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.micronaut.context.annotation.Factory;
import io.micronaut.context.annotation.Requires;
import io.micronaut.context.annotation.Value;
import io.micronaut.context.env.Environment;
import jakarta.inject.Singleton;

/**
Expand All @@ -37,7 +35,6 @@ public MetricClient metricClient() {
}

@Singleton
@Requires(env = Environment.KUBERNETES)
public KubernetesClient kubernetesClient() {
return new KubernetesClientBuilder().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import io.github.oshai.kotlinlogging.KotlinLogging
import io.micronaut.context.annotation.ConfigurationProperties
import io.micronaut.context.annotation.Property
import io.micronaut.context.annotation.Requires
import io.micronaut.context.env.Environment
import jakarta.inject.Singleton
import org.apache.commons.lang3.RandomStringUtils
import java.util.Base64
Expand All @@ -17,7 +16,6 @@ private val logger = KotlinLogging.logger {}
const val SECRET_LENGTH = 32

@Singleton
@Requires(env = [Environment.KUBERNETES])
@Requires(property = "airbyte.auth.kubernetes-secret.creation-enabled", value = "true")
class AuthKubernetesSecretInitializer(
@Property(name = "airbyte.auth.kubernetes-secret.name") private val secretName: String,
Expand Down
2 changes: 0 additions & 2 deletions airbyte-bootloader/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ micronaut:
caches:
platform-compatibility-provider:
expire-after-write: 15s
env:
cloud-deduction: true
server:
port: 9002
metrics:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private const val PROVIDED_CLIENT_ID_VALUE = "myClientId"
private const val PROVIDED_CLIENT_SECRET_VALUE = "myClientSecret"
private const val PROVIDED_JWT_SIGNATURE_VALUE = "myJwtSignature"

@MicronautTest(environments = [Environment.KUBERNETES, Environment.TEST])
@MicronautTest(environments = [Environment.TEST])
@Property(name = "airbyte.auth.kubernetes-secret.creation-enabled", value = "true")
@Property(name = "airbyte.auth.kubernetes-secret.name", value = SECRET_NAME)
class AuthKubernetesSecretInitializerTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class DeploymentMetadataHandlerTest {

@ParameterizedTest
@ValueSource(strings = {Environment.KUBERNETES, Environment.TEST})
@ValueSource(strings = {Environment.TEST})
void testRetrievingDeploymentMetadata(final String activeEnvironment) {
final UUID deploymentId = UUID.randomUUID();
final String version = "0.1.2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class MicronautConnectorBuilderServerRunner {

public static void main(final String[] args) {
Micronaut.build(args)
.deduceCloudEnvironment(false)
.deduceEnvironment(false)
.mainClass(MicronautConnectorBuilderServerRunner.class)
.start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ micronaut:
analytics-tracking-identity:
charset: "UTF-8"
expire-after-access: 10m
env:
cloud-deduction: true
metrics:
enabled: ${MICROMETER_METRICS_ENABLED:false}
export:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ micronaut:
- io.airbyte.connector.rollout.client
inject:
visibility: all # Enable verbose logging for bean injection
env:
cloud-deduction: true
metrics:
enabled: ${MICROMETER_METRICS_ENABLED:false}
export:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@

package io.airbyte.connector.rollout.worker

import io.micronaut.runtime.Micronaut
import io.micronaut.runtime.Micronaut.build

object ConnectorRolloutWorkerApplication {
@JvmStatic
fun main(args: Array<String>) {
val context = Micronaut.run(ConnectorRolloutWorkerApplication::class.java)
val context =
build(*args)
.deduceCloudEnvironment(false)
.deduceEnvironment(false)
.mainClass(ConnectorRolloutWorkerApplication::class.java)
.start()
val rolloutWorker = context.getBean(ConnectorRolloutWorker::class.java)
rolloutWorker.startWorker()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ micronaut:
- io.airbyte.connector.rollout.worker
inject:
visibility: all # Enable verbose logging for bean injection
env:
cloud-deduction: true
server:
port: 8016
netty:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
package io.airbyte.connectorSidecar

import io.github.oshai.kotlinlogging.KotlinLogging
import io.micronaut.context.ApplicationContext
import io.micronaut.runtime.Micronaut.build

private val logger = KotlinLogging.logger {}

fun main() {
logger.info { "Sidecar start" }

ApplicationContext.builder()
build()
.deduceCloudEnvironment(false)
.deduceEnvironment(false)
.start()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ 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)) {
try (final var ctx = Micronaut.build(args)
.deduceCloudEnvironment(false)
.deduceEnvironment(false)
.mainClass(Application.class)
.start()) {
exitCode = ctx.getBean(Application.class).run();
} catch (final Throwable t) {
log.error("could not run {}", t.getMessage(), t);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
micronaut:
caches:
# used by the analytics tracking client to cache calls to resolve the deployment and identity (workspace) for
# track events
# We overwrite the expiry in orchestrator to avoid making the workspace API call again and again for state stats metrics
analytics-tracking-deployments:
expire-after-access: 24h
analytics-tracking-identity:
expire-after-access: 24h
security:
enabled: true
filter:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ micronaut:
analytics-tracking-identity:
charset: "UTF-8"
expire-after-access: 10m
env:
cloud-deduction: true
server:
port: 9000 # If this value is modified, update the SERVER_PORT constant in OrchestratorConstants.kt
executors:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class MicronautCronRunner {

public static void main(final String[] args) {
Micronaut.build(args)
.deduceCloudEnvironment(false)
.deduceEnvironment(false)
.mainClass(MicronautCronRunner.class)
.start();
}
Expand Down
2 changes: 0 additions & 2 deletions airbyte-cron/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ micronaut:
expire-after-write: 15s
platform-compatibility-provider:
expire-after-write: 15s
env:
cloud-deduction: true
metrics:
enabled: ${MICROMETER_METRICS_ENABLED:false}
export:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.airbyte.featureflag.server

import io.micronaut.runtime.Micronaut.run
import io.micronaut.runtime.Micronaut.build

fun main(args: Array<String>) {
run(*args)
build(*args).deduceCloudEnvironment(false).deduceEnvironment(false).start()
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public class Application {

public static void main(final String[] args) {
try {
final ApplicationContext applicationContext = Micronaut.run(Application.class, args);
final ApplicationContext applicationContext =
Micronaut.build(args).deduceCloudEnvironment(false).deduceEnvironment(false).mainClass(Application.class).start();
final KeycloakSetup keycloakSetup = applicationContext.getBean(KeycloakSetup.class);
keycloakSetup.run();
System.exit(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Application {

public static void main(final String[] args) {
MetricClientFactory.initialize(MetricEmittingApps.METRICS_REPORTER);
Micronaut.run(Application.class, args);
Micronaut.build(args).deduceCloudEnvironment(false).deduceEnvironment(false).mainClass(Application.class).start();
}

}
2 changes: 0 additions & 2 deletions airbyte-metrics/reporter/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
micronaut:
application:
name: airbyte-metrics-reporter
env:
cloud-deduction: true
security:
intercept-url-map:
- pattern: /**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
public class Application {

public static void main(final String[] args) {
Micronaut.run(Application.class, args);
Micronaut.build(args)
.deduceCloudEnvironment(false)
.deduceEnvironment(false)
.mainClass(Application.class)
.start();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.micronaut.context.annotation.Factory;
import io.micronaut.context.annotation.Property;
import io.micronaut.context.annotation.Requires;
import io.micronaut.context.annotation.Value;
import io.micronaut.context.env.Environment;
import jakarta.inject.Named;
import jakarta.inject.Singleton;
import java.net.http.HttpClient;
Expand Down Expand Up @@ -239,7 +237,6 @@ public BuilderProjectUpdater builderProjectUpdater(final ConnectorBuilderService
}

@Singleton
@Requires(env = Environment.KUBERNETES)
public KubernetesClient kubernetesClient() {
return new KubernetesClientBuilder().build();
}
Expand Down
2 changes: 0 additions & 2 deletions airbyte-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ micronaut:
expire-after-access: 1h
user-info-endpoint-response:
expire-after-access: 1m
env:
cloud-deduction: true
executors:
# We set our max pool size for the config DB to 20 in 10-values.yml files at the time of writing this.
health:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
public class Application {

public static void main(final String[] args) {
Micronaut.run(Application.class, args);
Micronaut.build(args)
.deduceCloudEnvironment(false)
.deduceEnvironment(false)
.mainClass(Application.class)
.start();
}

}
2 changes: 0 additions & 2 deletions airbyte-workers/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
micronaut:
application:
name: airbyte-workers
env:
cloud-deduction: true
server:
netty:
aggregator:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
import io.micronaut.context.annotation.Bean;
import io.micronaut.context.annotation.Property;
import io.micronaut.context.annotation.Replaces;
import io.micronaut.context.env.Environment;
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;

@MicronautTest(environments = {EnvConstants.DATA_PLANE, Environment.KUBERNETES})
@MicronautTest(environments = {EnvConstants.DATA_PLANE})
@Property(name = "airbyte.internal-api.base-path",
value = "http://airbyte.test:1337")
@Property(name = "airbyte.version",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.airbyte.workload.server

import io.micronaut.runtime.Micronaut.run
import io.micronaut.runtime.Micronaut.build
import io.swagger.v3.oas.annotations.OpenAPIDefinition
import io.swagger.v3.oas.annotations.info.Info
import io.swagger.v3.oas.annotations.servers.Server
Expand All @@ -17,7 +17,7 @@ import io.swagger.v3.oas.annotations.servers.Server
class Application {
companion object {
@JvmStatic fun main(args: Array<String>) {
run(*args)
build(*args).deduceCloudEnvironment(false).deduceEnvironment(false).mainClass(Application::class.java).start()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
micronaut:
application:
name: airbyte-workload-api-server
env:
cloud-deduction: true
executors:
io:
type: fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package io.airbyte.initContainer

import io.github.oshai.kotlinlogging.KotlinLogging
import io.micronaut.context.ApplicationContext
import io.micronaut.runtime.Micronaut.build

private val logger = KotlinLogging.logger {}

Expand All @@ -16,7 +16,8 @@ fun main() {
* This was done to improve startup time by preventing searching through all the beans.
*/

ApplicationContext.builder()
build()
.deduceCloudEnvironment(false)
.deduceEnvironment(false)
.start()
// Explicitly call stop so that the application shuts down after InputFetcher runs
Expand Down
4 changes: 2 additions & 2 deletions airbyte-workload-launcher/src/main/kotlin/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

package io.airbyte.workload.launcher

import io.micronaut.runtime.Micronaut.run
import io.micronaut.runtime.Micronaut.build

fun main(args: Array<String>) {
run(*args)
build(*args).deduceCloudEnvironment(false).deduceEnvironment(false).start()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ micronaut:
application:
name: airbyte-workload-launcher
env:
cloud-deduction: true
additional-envs: ${MICRONAUT_ENVIRONMENTS:}
server:
port: 8016
Expand Down

0 comments on commit 1b4fc7b

Please sign in to comment.