Skip to content

Commit e4226b8

Browse files
chore: merge billing service with cloud-cron (#16854)
1 parent 8bc4574 commit e4226b8

File tree

6 files changed

+2
-146
lines changed

6 files changed

+2
-146
lines changed

airbyte-api/server-api/src/main/openapi/config.yaml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -232,27 +232,6 @@ paths:
232232
$ref: "#/components/schemas/WorkspaceReadList"
233233
"404":
234234
$ref: "#/components/responses/NotFoundResponse"
235-
/v1/workspaces/list_active_workspaces_by_most_recently_running_jobs:
236-
post:
237-
summary: Lists workspaces with the most recently running jobs within the given time window
238-
tags:
239-
- workspace
240-
operationId: listActiveWorkspacesByMostRecentlyRunningJobs
241-
requestBody:
242-
content:
243-
application/json:
244-
schema:
245-
$ref: "#/components/schemas/TimeWindowRequestBody"
246-
required: false
247-
responses:
248-
"200":
249-
description: Successful operation
250-
content:
251-
application/json:
252-
schema:
253-
$ref: "#/components/schemas/WorkspaceIdList"
254-
"422":
255-
$ref: "#/components/responses/InvalidInputResponse"
256235
/v1/workspaces/get_available_dbt_jobs:
257236
post:
258237
tags:

airbyte-commons-server/src/main/java/io/airbyte/commons/server/handlers/WorkspacesHandler.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323
import io.airbyte.api.model.generated.NotificationsConfig;
2424
import io.airbyte.api.model.generated.SlugRequestBody;
2525
import io.airbyte.api.model.generated.SourceRead;
26-
import io.airbyte.api.model.generated.TimeWindowRequestBody;
2726
import io.airbyte.api.model.generated.WebhookNotificationConfig;
2827
import io.airbyte.api.model.generated.WorkspaceCreate;
2928
import io.airbyte.api.model.generated.WorkspaceCreateWithId;
3029
import io.airbyte.api.model.generated.WorkspaceGiveFeedback;
31-
import io.airbyte.api.model.generated.WorkspaceIdList;
3230
import io.airbyte.api.model.generated.WorkspaceIdRequestBody;
3331
import io.airbyte.api.model.generated.WorkspaceOrganizationInfoRead;
3432
import io.airbyte.api.model.generated.WorkspaceRead;
@@ -76,7 +74,6 @@
7674
import java.util.UUID;
7775
import java.util.function.Supplier;
7876
import java.util.stream.Collectors;
79-
import org.jetbrains.annotations.NotNull;
8077
import org.jooq.tools.StringUtils;
8178
import org.slf4j.Logger;
8279
import org.slf4j.LoggerFactory;
@@ -612,9 +609,4 @@ private WorkspaceRead persistStandardWorkspace(final StandardWorkspace workspace
612609
return WorkspaceConverter.domainToApiModel(workspace);
613610
}
614611

615-
public WorkspaceIdList listActiveWorkspacesByMostRecentlyRunningJobs(@NotNull TimeWindowRequestBody timeWindowRequestBody) throws IOException {
616-
final List<UUID> workspaceIds = workspaceService.listActiveWorkspacesByMostRecentlyRunningJobs(timeWindowRequestBody.getTimeWindowInHours());
617-
return new WorkspaceIdList().workspaceIds(workspaceIds);
618-
}
619-
620612
}

airbyte-commons-server/src/main/java/io/airbyte/commons/server/support/AuthNettyServerCustomizer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ public class AuthNettyServerCustomizer implements BeanCreatedEventListener<Regis
3232
private final Integer maxHeaderSize;
3333
private final Integer maxChunkSize;
3434

35+
@SuppressWarnings("LineLength")
3536
public AuthNettyServerCustomizer(final AuthorizationServerHandler authorizationServerHandler,
36-
@Value("${micronaut.server.netty.aggregator.max-content-length}") final Integer aggregatorMaxContentLength,
37+
@Value("${micronaut.server.netty.aggregator.max-content-length:52428800}") final Integer aggregatorMaxContentLength,
3738
@Value("${micronaut.server.netty.max-initial-line-length:4096}") final Integer maxInitialLineLength,
3839
@Value("${micronaut.server.netty.max-header-size:8192}") final Integer maxHeaderSize,
3940
@Value("${micronaut.server.netty.max-chunk-size:8192}") final Integer maxChunkSize) {

airbyte-data/src/main/java/io/airbyte/data/services/WorkspaceService.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package io.airbyte.data.services;
66

77
import io.airbyte.config.StandardWorkspace;
8-
import io.airbyte.config.WorkspaceServiceAccount;
98
import io.airbyte.data.ConfigNotFoundException;
109
import io.airbyte.data.services.shared.ResourcesQueryPaginated;
1110
import io.airbyte.data.services.shared.StandardSyncQuery;
@@ -52,12 +51,6 @@ StandardWorkspace getStandardWorkspaceNoSecrets(UUID workspaceId, boolean includ
5251

5352
int countDestinationsForWorkspace(UUID workspaceId) throws IOException;
5453

55-
WorkspaceServiceAccount getWorkspaceServiceAccountNoSecrets(UUID workspaceId) throws IOException, ConfigNotFoundException;
56-
57-
void writeWorkspaceServiceAccountNoSecrets(WorkspaceServiceAccount workspaceServiceAccount) throws IOException;
58-
59-
String getDataplaneGroupNameForWorkspace(UUID workspaceId) throws IOException;
60-
6154
boolean getWorkspaceHasAlphaOrBetaConnector(UUID workspaceId) throws IOException;
6255

6356
List<UUID> listWorkspaceActiveSyncIds(final StandardSyncQuery standardSyncQuery) throws IOException;

airbyte-data/src/main/java/io/airbyte/data/services/impls/jooq/WorkspaceServiceJooqImpl.java

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
import static io.airbyte.db.instance.configs.jooq.generated.Tables.ACTOR_DEFINITION_VERSION;
1010
import static io.airbyte.db.instance.configs.jooq.generated.Tables.ACTOR_DEFINITION_WORKSPACE_GRANT;
1111
import static io.airbyte.db.instance.configs.jooq.generated.Tables.CONNECTION;
12-
import static io.airbyte.db.instance.configs.jooq.generated.Tables.DATAPLANE_GROUP;
1312
import static io.airbyte.db.instance.configs.jooq.generated.Tables.WORKSPACE;
14-
import static io.airbyte.db.instance.configs.jooq.generated.Tables.WORKSPACE_SERVICE_ACCOUNT;
1513
import static io.airbyte.db.instance.jobs.jooq.generated.Tables.JOBS;
1614
import static org.jooq.impl.DSL.asterisk;
1715
import static org.jooq.impl.DSL.noCondition;
@@ -28,7 +26,6 @@
2826
import io.airbyte.config.SourceConnection;
2927
import io.airbyte.config.StandardSync;
3028
import io.airbyte.config.StandardWorkspace;
31-
import io.airbyte.config.WorkspaceServiceAccount;
3229
import io.airbyte.config.secrets.SecretsRepositoryReader;
3330
import io.airbyte.config.secrets.SecretsRepositoryWriter;
3431
import io.airbyte.config.secrets.persistence.RuntimeSecretPersistence;
@@ -53,14 +50,12 @@
5350
import java.io.IOException;
5451
import java.lang.invoke.MethodHandles;
5552
import java.time.OffsetDateTime;
56-
import java.util.Collections;
5753
import java.util.List;
5854
import java.util.Optional;
5955
import java.util.UUID;
6056
import java.util.stream.Collectors;
6157
import java.util.stream.Stream;
6258
import org.jooq.Condition;
63-
import org.jooq.DSLContext;
6459
import org.jooq.JSONB;
6560
import org.jooq.JoinType;
6661
import org.jooq.Record;
@@ -413,64 +408,6 @@ public int countDestinationsForWorkspace(final UUID workspaceId) throws IOExcept
413408
.andNot(ACTOR.TOMBSTONE)).fetchOne().into(int.class);
414409
}
415410

416-
/**
417-
* Get workspace service account without secrets.
418-
*
419-
* @param workspaceId workspace id
420-
* @return workspace service account
421-
* @throws ConfigNotFoundException if the config does not exist
422-
* @throws IOException if there is an issue while interacting with db.
423-
*/
424-
@Override
425-
public WorkspaceServiceAccount getWorkspaceServiceAccountNoSecrets(final UUID workspaceId) throws IOException, ConfigNotFoundException {
426-
// breaking the pattern of doing a list query, because we never want to list this resource without
427-
// scoping by workspace id.
428-
return database.query(ctx -> ctx.select(asterisk()).from(WORKSPACE_SERVICE_ACCOUNT)
429-
.where(WORKSPACE_SERVICE_ACCOUNT.WORKSPACE_ID.eq(workspaceId))
430-
.fetch())
431-
.map(DbConverter::buildWorkspaceServiceAccount)
432-
.stream()
433-
.findFirst()
434-
.orElseThrow(() -> new ConfigNotFoundException(ConfigNotFoundType.WORKSPACE_SERVICE_ACCOUNT, workspaceId));
435-
}
436-
437-
/**
438-
* Write workspace service account with no secrets.
439-
*
440-
* @param workspaceServiceAccount workspace service account
441-
* @throws IOException if there is an issue while interacting with db.
442-
*/
443-
@Override
444-
public void writeWorkspaceServiceAccountNoSecrets(final WorkspaceServiceAccount workspaceServiceAccount) throws IOException {
445-
database.transaction(ctx -> {
446-
writeWorkspaceServiceAccount(Collections.singletonList(workspaceServiceAccount), ctx);
447-
return null;
448-
});
449-
}
450-
451-
/**
452-
* Get dataplane group name for the workspace.
453-
*
454-
* @param workspaceId workspace id
455-
* @return dataplaneGroupName
456-
* @throws IOException exception while interacting with the db
457-
*/
458-
@Override
459-
public String getDataplaneGroupNameForWorkspace(final UUID workspaceId) throws IOException {
460-
final List<String> dataplaneGroupName = database.query(ctx -> ctx.select(DATAPLANE_GROUP.NAME)
461-
.from(WORKSPACE)
462-
.join(DATAPLANE_GROUP)
463-
.on(WORKSPACE.DATAPLANE_GROUP_ID.eq(DATAPLANE_GROUP.ID)))
464-
.where(WORKSPACE.ID.eq(workspaceId))
465-
.fetchInto(String.class);
466-
467-
if (dataplaneGroupName.isEmpty()) {
468-
throw new RuntimeException(String.format("Dataplane group name wasn't resolved for workspaceId %s",
469-
workspaceId));
470-
}
471-
return dataplaneGroupName.getFirst();
472-
}
473-
474411
/**
475412
* Specialized query for efficiently determining eligibility for the Free Connector Program. If a
476413
* workspace has at least one Alpha or Beta connector, users of that workspace will be prompted to
@@ -540,43 +477,6 @@ public List<StandardWorkspace> listStandardWorkspacesWithIds(final List<UUID> wo
540477
return listWorkspaceQuery(Optional.of(workspaceIds), includeTombstone).toList();
541478
}
542479

543-
/**
544-
* Write workspace service account.
545-
*
546-
* @param configs list of workspace service account
547-
* @param ctx database context
548-
*/
549-
private void writeWorkspaceServiceAccount(final List<WorkspaceServiceAccount> configs, final DSLContext ctx) {
550-
final OffsetDateTime timestamp = OffsetDateTime.now();
551-
configs.forEach((workspaceServiceAccount) -> {
552-
final boolean isExistingConfig = ctx.fetchExists(select()
553-
.from(WORKSPACE_SERVICE_ACCOUNT)
554-
.where(WORKSPACE_SERVICE_ACCOUNT.WORKSPACE_ID.eq(workspaceServiceAccount.getWorkspaceId())));
555-
556-
if (isExistingConfig) {
557-
ctx.update(WORKSPACE_SERVICE_ACCOUNT)
558-
.set(WORKSPACE_SERVICE_ACCOUNT.WORKSPACE_ID, workspaceServiceAccount.getWorkspaceId())
559-
.set(WORKSPACE_SERVICE_ACCOUNT.SERVICE_ACCOUNT_ID, workspaceServiceAccount.getServiceAccountId())
560-
.set(WORKSPACE_SERVICE_ACCOUNT.SERVICE_ACCOUNT_EMAIL, workspaceServiceAccount.getServiceAccountEmail())
561-
.set(WORKSPACE_SERVICE_ACCOUNT.JSON_CREDENTIAL, JSONB.valueOf(Jsons.serialize(workspaceServiceAccount.getJsonCredential())))
562-
.set(WORKSPACE_SERVICE_ACCOUNT.HMAC_KEY, JSONB.valueOf(Jsons.serialize(workspaceServiceAccount.getHmacKey())))
563-
.set(WORKSPACE_SERVICE_ACCOUNT.UPDATED_AT, timestamp)
564-
.where(WORKSPACE_SERVICE_ACCOUNT.WORKSPACE_ID.eq(workspaceServiceAccount.getWorkspaceId()))
565-
.execute();
566-
} else {
567-
ctx.insertInto(WORKSPACE_SERVICE_ACCOUNT)
568-
.set(WORKSPACE_SERVICE_ACCOUNT.WORKSPACE_ID, workspaceServiceAccount.getWorkspaceId())
569-
.set(WORKSPACE_SERVICE_ACCOUNT.SERVICE_ACCOUNT_ID, workspaceServiceAccount.getServiceAccountId())
570-
.set(WORKSPACE_SERVICE_ACCOUNT.SERVICE_ACCOUNT_EMAIL, workspaceServiceAccount.getServiceAccountEmail())
571-
.set(WORKSPACE_SERVICE_ACCOUNT.JSON_CREDENTIAL, JSONB.valueOf(Jsons.serialize(workspaceServiceAccount.getJsonCredential())))
572-
.set(WORKSPACE_SERVICE_ACCOUNT.HMAC_KEY, JSONB.valueOf(Jsons.serialize(workspaceServiceAccount.getHmacKey())))
573-
.set(WORKSPACE_SERVICE_ACCOUNT.CREATED_AT, timestamp)
574-
.set(WORKSPACE_SERVICE_ACCOUNT.UPDATED_AT, timestamp)
575-
.execute();
576-
}
577-
});
578-
}
579-
580480
/**
581481
* Returns source with a given id. Does not contain secrets. To hydrate with secrets see { @link
582482
* SourceService#getSourceConnectionWithSecrets(final UUID sourceId) }.

airbyte-server/src/main/kotlin/io/airbyte/server/apis/controllers/WorkspaceApiController.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ import io.airbyte.api.model.generated.PermissionCheckRead
1313
import io.airbyte.api.model.generated.PermissionCheckRequest
1414
import io.airbyte.api.model.generated.PermissionType
1515
import io.airbyte.api.model.generated.SlugRequestBody
16-
import io.airbyte.api.model.generated.TimeWindowRequestBody
1716
import io.airbyte.api.model.generated.WorkspaceCreate
1817
import io.airbyte.api.model.generated.WorkspaceCreateWithId
1918
import io.airbyte.api.model.generated.WorkspaceGetDbtJobsRequest
2019
import io.airbyte.api.model.generated.WorkspaceGetDbtJobsResponse
2120
import io.airbyte.api.model.generated.WorkspaceGiveFeedback
22-
import io.airbyte.api.model.generated.WorkspaceIdList
2321
import io.airbyte.api.model.generated.WorkspaceIdRequestBody
2422
import io.airbyte.api.model.generated.WorkspaceOrganizationInfoRead
2523
import io.airbyte.api.model.generated.WorkspaceRead
@@ -234,13 +232,6 @@ open class WorkspaceApiController(
234232
@Body request: ListWorkspacesByUserRequestBody,
235233
): WorkspaceReadList? = execute { workspacesHandler.listWorkspacesByUser(request) }
236234

237-
@Post("/list_workspaces_by_most_recently_running_jobs")
238-
@Secured(AuthRoleConstants.ADMIN)
239-
@ExecuteOn(AirbyteTaskExecutors.IO)
240-
override fun listActiveWorkspacesByMostRecentlyRunningJobs(
241-
@Body timeWindowRequestBody: TimeWindowRequestBody,
242-
): WorkspaceIdList = throw ApiNotImplementedInOssProblem()
243-
244235
@Post("/get_available_dbt_jobs")
245236
@Secured(AuthRoleConstants.WORKSPACE_EDITOR, AuthRoleConstants.ORGANIZATION_EDITOR)
246237
@ExecuteOn(AirbyteTaskExecutors.IO)

0 commit comments

Comments
 (0)