Skip to content

Commit

Permalink
chore: delete remaining worker v1 config code (#13989)
Browse files Browse the repository at this point in the history
  • Loading branch information
tryangul committed Sep 17, 2024
1 parent 342f72e commit 559dc25
Show file tree
Hide file tree
Showing 45 changed files with 65 additions and 1,488 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class SegmentTrackingClient(
// deployment
put(AIRBYTE_VERSION_KEY, deployment.getDeploymentVersion())
put("deployment_mode", deployment.getDeploymentMode())
put("deployment_env", deployment.getDeploymentEnvironment())
put("deployment_id", deployment.getDeploymentId().toString())

// workspace (includes info that in the future we would store in an organization)
Expand Down Expand Up @@ -386,8 +385,6 @@ class Deployment(private val deploymentMetadata: DeploymentMetadataRead) {

fun getDeploymentId(): UUID = deploymentMetadata.id

fun getDeploymentEnvironment(): String = deploymentMetadata.environment

fun getDeploymentVersion(): String = deploymentMetadata.version
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import io.airbyte.config.Configs
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 io.micronaut.core.util.StringUtils
import jakarta.inject.Named
import jakarta.inject.Singleton
Expand All @@ -24,11 +23,9 @@ class AnalyticsTrackingBeanFactory {
fun deploymentSupplier(
airbyteVersion: AirbyteVersion,
deploymentMode: Configs.DeploymentMode,
environment: Environment,
): Supplier<DeploymentMetadataRead> =
Supplier {
DeploymentMetadataRead(
environment = getDeploymentEnvironment(environment),
id = BLANK_UUID,
mode = deploymentMode.name,
version = airbyteVersion.serialize(),
Expand Down Expand Up @@ -68,11 +65,4 @@ class AnalyticsTrackingBeanFactory {
creatorFunction: Function<String, T>,
@Suppress("SameParameterValue") defaultValue: T,
): T = if (StringUtils.isNotEmpty(value)) creatorFunction.apply(value.uppercase()) else defaultValue

private fun getDeploymentEnvironment(environment: Environment): String =
if (environment.activeNames.contains(Environment.KUBERNETES)) {
Configs.WorkerEnvironment.KUBERNETES.name
} else {
Configs.WorkerEnvironment.DOCKER.name
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ class DeploymentFetcherTest {
deploymentMetadata =
DeploymentMetadataRead(
id = deploymentId,
environment = Configs.WorkerEnvironment.KUBERNETES.name,
mode =
Configs.DeploymentMode.OSS.name,
mode = Configs.DeploymentMode.OSS.name,
version = airbyteVersion.serialize(),
)
deploymentFetcher = DeploymentFetcher { deploymentMetadata }
Expand All @@ -35,7 +33,6 @@ class DeploymentFetcherTest {
fun testRetrievingDeploymentMetadata() {
val deployment = deploymentFetcher.get()
assertEquals(deploymentMetadata.id, deployment.getDeploymentId())
assertEquals(deploymentMetadata.environment, deployment.getDeploymentEnvironment())
assertEquals(deploymentMetadata.mode, deployment.getDeploymentMode())
assertEquals(deploymentMetadata.version, deployment.getDeploymentVersion())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.segment.analytics.messages.TrackMessage
import io.airbyte.api.client.model.generated.DeploymentMetadataRead
import io.airbyte.commons.version.AirbyteVersion
import io.airbyte.config.Configs
import io.airbyte.config.Configs.WorkerEnvironment
import io.micronaut.http.HttpHeaders
import io.micronaut.http.HttpRequest
import io.micronaut.http.context.ServerRequestContext
Expand All @@ -30,7 +29,6 @@ class SegmentTrackingClientTest {
private val deploymentMetadata: DeploymentMetadataRead =
DeploymentMetadataRead(
id = deploymentId,
environment = WorkerEnvironment.KUBERNETES.name,
mode = Configs.DeploymentMode.OSS.name,
version = airbyteVersion.serialize(),
)
Expand Down Expand Up @@ -78,7 +76,6 @@ class SegmentTrackingClientTest {
mapOf(
"anonymized" to identity.anonymousDataCollection!!,
SegmentTrackingClient.AIRBYTE_VERSION_KEY to airbyteVersion.serialize(),
"deployment_env" to deploymentMetadata.environment,
"deployment_mode" to deploymentMetadata.mode,
"deployment_id" to deploymentMetadata.id.toString(),
EMAIL_KEY to identity.email!!,
Expand Down Expand Up @@ -111,7 +108,6 @@ class SegmentTrackingClientTest {
"airbyte_role" to "role",
SegmentTrackingClient.AIRBYTE_VERSION_KEY to airbyteVersion.serialize(),
"anonymized" to identity.anonymousDataCollection!!,
"deployment_env" to deploymentMetadata.environment,
"deployment_mode" to deploymentMetadata.mode,
"deployment_id" to deploymentMetadata.id.toString(),
EMAIL_KEY to identity.email!!,
Expand Down Expand Up @@ -146,7 +142,6 @@ class SegmentTrackingClientTest {
"airbyte_role" to "role",
SegmentTrackingClient.AIRBYTE_VERSION_KEY to airbyteVersion.serialize(),
"anonymized" to identity.anonymousDataCollection!!,
"deployment_env" to deploymentMetadata.environment,
"deployment_mode" to deploymentMetadata.mode,
"deployment_id" to deploymentMetadata.id.toString(),
EMAIL_KEY to identity.email!!,
Expand Down
3 changes: 0 additions & 3 deletions airbyte-api/server-api/src/main/openapi/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13019,13 +13019,10 @@ components:
DeploymentMetadataRead:
type: object
required:
- environment
- id
- mode
- version
properties:
environment:
type: string
id:
type: string
format: uuid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import io.airbyte.api.model.generated.DeploymentMetadataRead;
import io.airbyte.commons.version.AirbyteVersion;
import io.airbyte.config.Configs;
import io.micronaut.context.env.Environment;
import jakarta.inject.Named;
import jakarta.inject.Singleton;
import java.util.UUID;
Expand All @@ -22,31 +21,22 @@ public class DeploymentMetadataHandler {
private final AirbyteVersion airbyteVersion;
private final Configs.DeploymentMode deploymentMode;
private final DSLContext dslContext;
private final Environment environment;

public DeploymentMetadataHandler(
final AirbyteVersion airbyteVersion,
final Configs.DeploymentMode deploymentMode,
@Named("unwrappedConfig") final DSLContext dslContext,
final Environment environment) {
@Named("unwrappedConfig") final DSLContext dslContext) {
this.airbyteVersion = airbyteVersion;
this.deploymentMode = deploymentMode;
this.dslContext = dslContext;
this.environment = environment;
}

public DeploymentMetadataRead getDeploymentMetadata() {
final Result<org.jooq.Record> result = dslContext.fetch(DEPLOYMENT_ID_QUERY);
final String deploymentId = result.getValue(0, "value").toString();
return new DeploymentMetadataRead().id(UUID.fromString(deploymentId))
.mode(deploymentMode.name())
.environment(getEnvironment())
.version(airbyteVersion.serialize());
}

private String getEnvironment() {
return environment.getActiveNames().contains(Environment.KUBERNETES) ? Configs.WorkerEnvironment.KUBERNETES.name()
: Configs.WorkerEnvironment.DOCKER.name();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,16 @@ void testRetrievingDeploymentMetadata(final String activeEnvironment) {
final DSLContext dslContext = mock(DSLContext.class);
final Environment environment = mock(Environment.class);
final Result<org.jooq.Record> result = mock(Result.class);
final String expectedEnvironment =
Environment.KUBERNETES.equals(activeEnvironment) ? Configs.WorkerEnvironment.KUBERNETES.name() : Configs.WorkerEnvironment.DOCKER.name();

when(result.getValue(anyInt(), anyString())).thenReturn(deploymentId);
when(dslContext.fetch(anyString())).thenReturn(result);
when(environment.getActiveNames()).thenReturn(Set.of(activeEnvironment));

final DeploymentMetadataHandler handler = new DeploymentMetadataHandler(airbyteVersion, deploymentMode, dslContext, environment);
final DeploymentMetadataHandler handler = new DeploymentMetadataHandler(airbyteVersion, deploymentMode, dslContext);

final DeploymentMetadataRead deploymentMetadataRead = handler.getDeploymentMetadata();

assertEquals(deploymentId, deploymentMetadataRead.getId());
assertEquals(expectedEnvironment, deploymentMetadataRead.getEnvironment());
assertEquals(deploymentMode.name(), deploymentMetadataRead.getMode());
assertEquals(version, deploymentMetadataRead.getVersion());
}
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 559dc25

Please sign in to comment.