Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prevent Coordinator from stopping V1 executors #544

Merged
merged 4 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions coordinator/src/block_streams_handler.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(test, allow(dead_code))]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the impl is mocked in test builds, the actual implementation warns dead_code, as it isn't used with the tests. This suppresses these errors for test builds, code that is not used in normal builds will still warn.


use anyhow::Context;
use block_streamer::block_streamer_client::BlockStreamerClient;
use block_streamer::{
Expand Down
2 changes: 2 additions & 0 deletions coordinator/src/executors_handler.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(test, allow(dead_code))]

use anyhow::Context;
use runner::runner_client::RunnerClient;
use runner::{ExecutorInfo, ListExecutorsRequest, StartExecutorRequest, StopExecutorRequest};
Expand Down
19 changes: 14 additions & 5 deletions coordinator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod registry;
mod utils;

const CONTROL_LOOP_THROTTLE_SECONDS: Duration = Duration::from_secs(1);
const V1_EXECUTOR_VERSION: u64 = 0;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
Expand Down Expand Up @@ -81,23 +82,31 @@ async fn filter_registry_by_allowlist(
let allowlist: AllowList =
serde_json::from_str(&raw_allowlist).context("Failed to parse allowlist")?;

tracing::debug!("Using allowlist: {:#?}", allowlist);

Ok(indexer_registry
let filtered_registry = indexer_registry
.into_iter()
.filter(|(account_id, _)| {
allowlist
.iter()
.any(|entry| entry.account_id == *account_id)
})
.collect())
.collect();

tracing::debug!("Using filtered registry: {:#?}", filtered_registry);

Ok(filtered_registry)
}

async fn synchronise_executors(
indexer_registry: &IndexerRegistry,
executors_handler: &ExecutorsHandler,
) -> anyhow::Result<()> {
let mut active_executors = executors_handler.list().await?;
let active_executors = executors_handler.list().await?;

// Ignore V1 executors
let mut active_executors: Vec<_> = active_executors
.into_iter()
.filter(|executor| executor.version != V1_EXECUTOR_VERSION)
.collect();

for (account_id, indexers) in indexer_registry.iter() {
for (function_name, indexer_config) in indexers.iter() {
Expand Down
2 changes: 2 additions & 0 deletions coordinator/src/redis.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(test, allow(dead_code))]

use std::fmt::Debug;

use anyhow::Context;
Expand Down
2 changes: 2 additions & 0 deletions coordinator/src/registry.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(test, allow(dead_code))]

use anyhow::Context;
use std::collections::HashMap;

Expand Down
2 changes: 1 addition & 1 deletion runner/src/server/runner-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function getRunnerService (executors: Map<string, StreamHandler>, StreamHandlerT
config = {
account_id: accountId,
function_name: functionName,
version: -1, // Ensure Coordinator V2 sees version mismatch
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As version is uint64 this ends up being a the largest possible 64 bit int.

version: 0, // Ensure Coordinator V2 sees version mismatch
code: '',
schema: '',
};
Expand Down
Loading