Skip to content

Commit

Permalink
fix: Ensure state is updated after starting data layer provisioning (#…
Browse files Browse the repository at this point in the history
…817)

- Need to write the state to move it out of "new" and in to "existing"
- Added some logs to `DataLayerService`
  • Loading branch information
morgsmccauley authored Jun 20, 2024
1 parent 10a65f2 commit d88a4dc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
13 changes: 13 additions & 0 deletions coordinator/src/synchroniser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ impl<'a> Synchroniser<'a> {
.start_provisioning_task(config)
.await?;

self.state_manager
.set_provisioning(config)
.await
.map_err(|err| {
tracing::warn!(?err, "Failed to set provisioning state");
err
})?;

Ok(())
}

Expand Down Expand Up @@ -594,6 +602,11 @@ mod test {

let mut state_manager = IndexerStateManager::default();
state_manager.expect_list().returning(|| Ok(vec![]));
state_manager
.expect_set_provisioning()
.with(eq(config.clone()))
.returning(|_| Ok(()))
.once();

let mut data_layer_handler = DataLayerHandler::default();
data_layer_handler
Expand Down
21 changes: 20 additions & 1 deletion runner/src/server/services/data-layer/data-layer-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { type ServerUnaryCall, type sendUnaryData, status, StatusBuilder } from

import Provisioner from '../../../provisioner';
import { ProvisioningConfig } from '../../../indexer-config/indexer-config';
import parentLogger from '../../../logger';

import { type CheckProvisioningTaskStatusRequest__Output } from '../../../generated/data_layer/CheckProvisioningTaskStatusRequest';
import { type DataLayerHandlers } from '../../../generated/data_layer/DataLayer';
Expand Down Expand Up @@ -72,6 +73,12 @@ export function createDataLayerService (

const provisioningConfig = new ProvisioningConfig(accountId, functionName, schema);

const logger = parentLogger.child({
service: 'DataLayerService',
accountId: provisioningConfig.accountId,
functionName: provisioningConfig.functionName,
});

const task = tasks[generateTaskId(accountId, functionName)];

if (task) {
Expand All @@ -91,7 +98,19 @@ export function createDataLayerService (
return;
}

tasks[generateTaskId(accountId, functionName)] = new ProvisioningTask(provisioner.provisionUserApi(provisioningConfig));
logger.info('Provisioning Data Layer');

tasks[generateTaskId(accountId, functionName)] = new ProvisioningTask(
provisioner
.provisionUserApi(provisioningConfig)
.then(() => {
logger.info('Successfully provisioned Data Layer');
})
.catch((err) => {
logger.error('Failed to provision Data Layer', err);
throw err;
})
);

callback(null, { status: ProvisioningStatus.PENDING });
}).catch((error) => {
Expand Down

0 comments on commit d88a4dc

Please sign in to comment.