Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
0b03851
Init
Bill-hbrhbr Aug 27, 2026
dbc1986
Change search to query; Add msgpack tests
Bill-hbrhbr Aug 27, 2026
d8f992e
Merge branch 'main' into query-coordinator-tdl
Bill-hbrhbr Aug 27, 2026
4b2acb6
Create and submitter skeleton
Bill-hbrhbr Aug 27, 2026
d13c6e6
docs(clp-tdl-package): Clarify package task scope
Bill-hbrhbr Aug 27, 2026
0ba6fe5
docs(clp-tdl-package): Clarify package task scope
Bill-hbrhbr Aug 27, 2026
1198719
Merge branch 'main' into query-coordinator-tdl
Bill-hbrhbr Aug 28, 2026
6298f54
polish
Bill-hbrhbr Aug 28, 2026
ff5bc49
Update components/clp-rust-utils/src/task_io/query.rs
Bill-hbrhbr Aug 29, 2026
37396cd
Update components/clp-rust-utils/src/task_io/query.rs
Bill-hbrhbr Aug 29, 2026
da02988
Change to milliseconds
Bill-hbrhbr Aug 30, 2026
bf2ebc0
Update components/clp-tdl-package/src/task/query/mod.rs
Bill-hbrhbr Aug 30, 2026
ba425f5
Merge branch 'main' into query-coordinator-tdl
Bill-hbrhbr Aug 30, 2026
2ce8882
refactor(clp-tdl-package): Move `clp_binary_path` and `s3_credential_…
LinZhihao-723 Aug 31, 2026
3b3b9c4
Merge branch 'main' into tdl-task-utils-mod
LinZhihao-723 Aug 31, 2026
0296f0c
Remove task redundant description
Bill-hbrhbr Aug 31, 2026
3f36b5a
Merge branch 'main' into tdl-task-utils-mod
LinZhihao-723 Aug 31, 2026
2096e9b
Add query job ID type
Bill-hbrhbr Aug 31, 2026
cb87c6e
Make query task dataset optional
Bill-hbrhbr Aug 31, 2026
f8a68a6
Require non-empty query task strings
Bill-hbrhbr Aug 31, 2026
d5c0450
Use shared default for query result limit
Bill-hbrhbr Aug 31, 2026
ca2ebe2
Lint fix remove unused
Bill-hbrhbr Aug 31, 2026
9429396
Remove unused query task output
Bill-hbrhbr Aug 31, 2026
323acfc
Rename task
Bill-hbrhbr Aug 31, 2026
8f509ef
Add query task output handle
Bill-hbrhbr Aug 31, 2026
b67cb70
Fix todo uppercase
Bill-hbrhbr Aug 31, 2026
61fd27e
Merge branch 'main' into query-coordinator-tdl
Bill-hbrhbr Aug 31, 2026
3bee52b
Document Python mirror for query result limit default
Bill-hbrhbr Aug 31, 2026
c39b086
Name query task output handle parameter after its type
Bill-hbrhbr Sep 1, 2026
3cee914
Fix symbol ordering
Bill-hbrhbr Sep 1, 2026
789f671
Use clp-s default query result limit
Bill-hbrhbr Sep 1, 2026
184d940
Apply batched suggestions from code review
Bill-hbrhbr Sep 1, 2026
c479fad
Propagate rename
Bill-hbrhbr Sep 1, 2026
cfa0a97
lint fix
Bill-hbrhbr Sep 1, 2026
c592252
Merge branch 'main' into query-coordinator/crate
Bill-hbrhbr Sep 2, 2026
e5937b7
Merge branch 'query-coordinator-tdl' into query-coordinator/crate
Bill-hbrhbr Sep 2, 2026
89ca7b5
Fix inconsistencies
Bill-hbrhbr Sep 2, 2026
4e063fb
Add missing output handle arg
Bill-hbrhbr Sep 2, 2026
f5860de
Add query job lifecycle handling
Bill-hbrhbr Sep 2, 2026
842c93c
Address review comments
Bill-hbrhbr Sep 2, 2026
2e689fe
Add trailing comma
Bill-hbrhbr Sep 2, 2026
b2fed1f
Apply batched suggestions from code review
Bill-hbrhbr Sep 2, 2026
e5f0501
Apply suggestion from @LinZhihao-723
Bill-hbrhbr Sep 2, 2026
e0566a7
docs(query-coordinator): Fix deferred API documentation
Bill-hbrhbr Sep 2, 2026
218f792
Merge newest submitter
Bill-hbrhbr Sep 2, 2026
a714f6a
Fix according to guidelines
Bill-hbrhbr Sep 2, 2026
012c8b2
Lint fix
Bill-hbrhbr Sep 2, 2026
f15fa49
Task utils mod
Bill-hbrhbr Sep 3, 2026
4891cf8
fix(query-coordinator): Return errors from staging paths
Bill-hbrhbr Sep 3, 2026
4a45d04
Change back to todo
Bill-hbrhbr Sep 3, 2026
ce692e8
Merge branch 'main' into query-coordinator/crate
Bill-hbrhbr Sep 3, 2026
8e90645
Merge branch 'query-coordinator/crate' into query-coordinator/job-handle
Bill-hbrhbr Sep 3, 2026
61414eb
lint fix
Bill-hbrhbr Sep 3, 2026
5e84b4f
Lint fix
Bill-hbrhbr Sep 3, 2026
bd8d4b4
Add a submit task and fix unused variable
Bill-hbrhbr Sep 3, 2026
401f988
Remove redundant QueryPlan and rename SpiderOption
Bill-hbrhbr Sep 8, 2026
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
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ members = [
"components/clp-rust-utils",
"components/clp-tdl-package",
"components/compression-coordinator",
"components/log-ingestor"
"components/log-ingestor",
"components/query-coordinator",
]
resolver = "3"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,18 @@ def main(argv):
`id` INT NOT NULL AUTO_INCREMENT,
`type` INT NOT NULL,
`status` INT NOT NULL DEFAULT '{QueryJobStatus.PENDING}',
`status_msg` VARCHAR(512) NOT NULL DEFAULT '',
`creation_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`num_tasks` INT NOT NULL DEFAULT '0',
`num_tasks_completed` INT NOT NULL DEFAULT '0',
`start_time` DATETIME(3) NULL DEFAULT NULL,
`duration` FLOAT NULL DEFAULT NULL,
`job_config` MEDIUMBLOB NOT NULL,
`spider_id` BIGINT UNSIGNED NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `CREATION_TIME` (`creation_time`) USING BTREE,
INDEX `JOB_STATUS` (`status`) USING BTREE
INDEX `JOB_STATUS` (`status`) USING BTREE,
INDEX `JOB_SPIDER_ID` (`spider_id`) USING BTREE
) ROW_FORMAT=DYNAMIC
"""
)
Expand Down
5 changes: 5 additions & 0 deletions components/clp-rust-utils/src/job_config/search.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
use non_empty_string::NonEmptyString;
use num_enum::IntoPrimitive;
use num_enum::TryFromPrimitive;
use serde::Deserialize;
use serde::Serialize;

pub const QUERY_JOBS_TABLE_NAME: &str = "query_jobs";

pub type ArchiveId = NonEmptyString;

pub type QueryJobId = i32;

/// Mirror of `job_orchestration.scheduler.job_config.AggregationConfig`. Must be kept in sync.
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(default)]
Expand Down
1 change: 1 addition & 0 deletions components/clp-rust-utils/src/task_io.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod compression;
pub mod query;
31 changes: 31 additions & 0 deletions components/clp-rust-utils/src/task_io/query.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//! Protocol types exchanged with the Spider (Huntsman) tasks that run CLP query jobs.

use std::num::NonZeroU32;

use non_empty_string::NonEmptyString;
use serde::Deserialize;
use serde::Serialize;

/// `clp-s` options for a query job.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct ClpSQueryOption {
/// The query string passed positionally to `clp-s`.
pub query_string: NonEmptyString,

/// The per-archive result limit. When absent, the task omits `--max-num-results` and uses the
/// `clp-s` default.
pub max_num_results: Option<NonZeroU32>,

/// Inclusive `--tge` bound in Unix epoch milliseconds.
pub begin_timestamp_millisecs: Option<i64>,

/// Inclusive `--tle` bound in Unix epoch milliseconds.
pub end_timestamp_millisecs: Option<i64>,

/// Whether `clp-s` performs a case-insensitive search.
pub ignore_case: bool,
}

/// The output handler that `clp-s` writes a query task's results to.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum OutputHandle {}
8 changes: 6 additions & 2 deletions components/clp-tdl-package/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Spider TDL task package `clp`: the CLP compression tasks the Spider task executor loads.
//! Spider TDL package `clp`, providing CLP compression and query tasks for Spider task executors.

pub mod common;
mod task;
Expand Down Expand Up @@ -28,5 +28,9 @@ fn package_init() -> Result<(), TdlError> {
spider_tdl::register_tdl_package! {
package_name: "clp",
init: package_init,
tasks: [task::compression::s3_compress_task, task::compression::commit_task],
tasks: [
task::compression::s3_compress_task,
task::compression::commit_task,
task::query::clp_s_search_task,
],
}
106 changes: 2 additions & 104 deletions components/clp-tdl-package/src/task/compression/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ use std::process::Command;
use std::process::Stdio;

use anyhow::Context;
use aws_config::BehaviorVersion;
use aws_sdk_s3::config::ProvideCredentials;
use clp_rust_utils::aws::AWS_DEFAULT_REGION;
use clp_rust_utils::clp_config::AwsAuthentication;
use clp_rust_utils::clp_config::S3Config;
use clp_rust_utils::clp_config::package::config::ArchiveOutput;
use clp_rust_utils::clp_config::package::config::ArchiveOutputStorage;
Expand All @@ -30,6 +27,8 @@ use non_empty_string::NonEmptyString;

use crate::common::clp_home;
use crate::common::runtime;
use crate::task::utils::clp_binary_path;
use crate::task::utils::s3_credential_env;

/// Compresses the given S3 objects into archives, uploads them to S3, and returns their metadata
/// for the commit task.
Expand Down Expand Up @@ -345,74 +344,6 @@ fn build_s3_logs_list(input_source: &S3InputSource) -> anyhow::Result<String> {
Ok(list)
}

/// Resolves the AWS credential env vars clp-s needs to access the S3 objects.
///
/// # Returns
///
/// The env-var name-value pairs with the following environment variables set:
///
/// * `AWS_ACCESS_KEY_ID`
/// * `AWS_SECRET_ACCESS_KEY`
/// * `AWS_SESSION_TOKEN` (if any)
///
/// # Errors
///
/// Returns an error if:
///
/// * The default AWS SDK credential provider chain has no provider.
/// * Forwards [`ProvideCredentials::provide_credentials`]'s return values on failure.
fn s3_credential_env(
runtime: &tokio::runtime::Handle,
region: &str,
auth: &AwsAuthentication,
) -> anyhow::Result<Vec<(&'static str, String)>> {
/// The env var holding the AWS access key ID.
const AWS_ACCESS_KEY_ID_ENV_VAR: &str = "AWS_ACCESS_KEY_ID";

/// The env var holding the AWS secret access key.
const AWS_SECRET_ACCESS_KEY_ENV_VAR: &str = "AWS_SECRET_ACCESS_KEY";

/// The env var holding the AWS session token.
const AWS_SESSION_TOKEN_ENV_VAR: &str = "AWS_SESSION_TOKEN";

let (access_key_id, secret_access_key, session_token) = match auth {
AwsAuthentication::Credentials { credentials } => (
credentials.access_key_id.clone(),
credentials.secret_access_key.clone(),
credentials.session_token.clone(),
),
AwsAuthentication::Default => {
let sdk_config = runtime.block_on(
aws_config::defaults(BehaviorVersion::latest())
.region(aws_sdk_s3::config::Region::new(region.to_string()))
.load(),
);
let provider = sdk_config
.credentials_provider()
.context("default AWS SDK credential provider is unavailable")?;
let credentials = runtime
.block_on(provider.provide_credentials())
.context("failed to resolve credentials from the default AWS SDK provider chain")?;
(
credentials.access_key_id().to_string(),
credentials.secret_access_key().to_string(),
credentials
.session_token()
.map(std::string::ToString::to_string),
)
}
};

let mut env = vec![
(AWS_ACCESS_KEY_ID_ENV_VAR, access_key_id),
(AWS_SECRET_ACCESS_KEY_ENV_VAR, secret_access_key),
];
if let Some(session_token) = session_token {
env.push((AWS_SESSION_TOKEN_ENV_VAR, session_token));
}
Ok(env)
}

/// Parses a single clp-s `--print-archive-stats` stdout line into an [`ArchiveMetadata`].
///
/// NOTE: clp-s emits a superset of [`ArchiveMetadata`]'s fields per line; unknown fields are
Expand Down Expand Up @@ -585,15 +516,6 @@ fn build_log_converter_args(output_dir: &Path, inputs_from_path: &Path) -> Vec<O
]
}

/// Resolves the path of a CLP binary under `clp_home`, joining `bin/{binary}`.
///
/// # Returns
///
/// The path to the named binary under the CLP installation.
fn clp_binary_path(clp_home: &Path, binary: &str) -> PathBuf {
clp_home.join("bin").join(binary)
}

/// Resolves the S3 config the archives are uploaded to from `config`.
///
/// # Returns
Expand Down Expand Up @@ -905,7 +827,6 @@ mod tests {
use std::path::PathBuf;

use clp_rust_utils::clp_config::AwsAuthentication;
use clp_rust_utils::clp_config::AwsCredentials;
use clp_rust_utils::clp_config::S3Config;
use clp_rust_utils::clp_config::package::config::ArchiveOutput;
use clp_rust_utils::clp_config::package::config::ArchiveOutputStorage;
Expand All @@ -923,7 +844,6 @@ mod tests {
use super::build_s3_logs_list;
use super::create_archive_s3_key;
use super::parse_archive_stats;
use super::s3_credential_env;

#[test]
fn build_s3_logs_list_default_endpoint() -> anyhow::Result<()> {
Expand All @@ -947,28 +867,6 @@ mod tests {
Ok(())
}

#[test]
fn s3_credential_env_credentials() {
let runtime = tokio::runtime::Runtime::new().expect("failed to create Tokio runtime");
let auth = AwsAuthentication::Credentials {
credentials: AwsCredentials {
access_key_id: "the-access-key".to_string(),
secret_access_key: "the-secret-key".to_string(),
session_token: Some("the-session-token".to_string()),
},
};

assert_eq!(
s3_credential_env(runtime.handle(), "us-east-1", &auth)
.expect("failed to resolve credentials"),
vec![
("AWS_ACCESS_KEY_ID", "the-access-key".to_string()),
("AWS_SECRET_ACCESS_KEY", "the-secret-key".to_string()),
("AWS_SESSION_TOKEN", "the-session-token".to_string()),
]
);
}

#[test]
fn parse_archive_stats_ignores_extra_keys() {
let line = concat!(
Expand Down
2 changes: 2 additions & 0 deletions components/clp-tdl-package/src/task/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! The task implementations this package registers with Spider.

pub mod compression;
pub mod query;
pub mod utils;
21 changes: 21 additions & 0 deletions components/clp-tdl-package/src/task/query/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! The query-task signatures registered with Spider.

use clp_rust_utils::job_config::ArchiveId;
use clp_rust_utils::job_config::QueryJobId;
use clp_rust_utils::task_io::query::ClpSQueryOption;
use clp_rust_utils::task_io::query::OutputHandle;
use non_empty_string::NonEmptyString;
use spider_tdl::TaskContext;
use spider_tdl::task;

#[task(name = "query::clp_s_search")]
pub(crate) fn clp_s_search_task(
_ctx: TaskContext,
_query_job_id: QueryJobId,
_clp_s_query_option: ClpSQueryOption,
_dataset: Option<NonEmptyString>,
_archive_id: ArchiveId,
_output_handle: OutputHandle,
) -> Result<(), spider_tdl::TdlError> {
todo!("clp-s search task is not implemented")
}
Loading
Loading