Skip to content

Commit c6f1565

Browse files
committed
blop
1 parent 54d227b commit c6f1565

7 files changed

Lines changed: 42 additions & 46 deletions

File tree

quickwit/quickwit-cli/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ release-feature-set = [
102102
"quickwit-indexing/pulsar",
103103
"quickwit-indexing/sqs",
104104
"quickwit-indexing/vrl",
105+
"quickwit-serve/lambda-auto-deploy",
105106
"quickwit-storage/azure",
106107
"quickwit-storage/gcs",
107108
"quickwit-metastore/postgres",
@@ -116,6 +117,7 @@ release-feature-vendored-set = [
116117
"quickwit-indexing/sqs",
117118
"quickwit-indexing/vrl",
118119
"quickwit-indexing/vendored-kafka",
120+
"quickwit-serve/lambda-auto-deploy",
119121
"quickwit-storage/azure",
120122
"quickwit-storage/gcs",
121123
"quickwit-metastore/postgres",
@@ -129,6 +131,7 @@ release-macos-feature-vendored-set = [
129131
"quickwit-indexing/sqs",
130132
"quickwit-indexing/vrl",
131133
"quickwit-indexing/vendored-kafka-macos",
134+
"quickwit-serve/lambda-auto-deploy",
132135
"quickwit-storage/azure",
133136
"quickwit-storage/gcs",
134137
"quickwit-metastore/postgres",

quickwit/quickwit-config/src/node_config/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,6 @@ pub struct LambdaConfig {
317317
/// AWS Lambda function name or ARN.
318318
#[serde(default = "LambdaConfig::default_function_name")]
319319
pub function_name: String,
320-
/// Optional function qualifier (alias or version).
321-
#[serde(default)]
322-
pub function_qualifier: Option<String>,
323320
/// Maximum number of splits per Lambda invocation.
324321
#[serde(default = "LambdaConfig::default_max_splits_per_invocation")]
325322
pub max_splits_per_invocation: usize,
@@ -358,7 +355,6 @@ impl Default for LambdaConfig {
358355
fn default() -> Self {
359356
Self {
360357
function_name: Self::default_function_name(),
361-
function_qualifier: None,
362358
max_splits_per_invocation: Self::default_max_splits_per_invocation(),
363359
auto_deploy: None,
364360
}

quickwit/quickwit-lambda/src/deployer.rs

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,45 +17,35 @@
1717
//! This module provides functionality to automatically deploy or update
1818
//! the Lambda function used for leaf search operations.
1919
20-
#[cfg(feature = "auto-deploy")]
2120
use std::collections::HashMap;
2221

2322
use aws_sdk_lambda::Client as LambdaClient;
24-
#[cfg(feature = "auto-deploy")]
2523
use aws_sdk_lambda::error::SdkError;
26-
#[cfg(feature = "auto-deploy")]
2724
use aws_sdk_lambda::operation::create_function::CreateFunctionError;
28-
#[cfg(feature = "auto-deploy")]
2925
use aws_sdk_lambda::operation::get_function::GetFunctionOutput;
30-
#[cfg(feature = "auto-deploy")]
3126
use aws_sdk_lambda::primitives::Blob;
32-
#[cfg(feature = "auto-deploy")]
3327
use aws_sdk_lambda::types::{Architecture, Environment, FunctionCode, Runtime};
34-
#[cfg(feature = "auto-deploy")]
28+
use quickwit_config::LambdaDeployConfig;
3529
use tracing::{debug, info, warn};
3630

3731
use crate::config::LambdaDeployConfig;
3832
use crate::error::{LambdaError, LambdaResult};
3933

4034
/// Embedded Lambda binary (arm64, compressed).
4135
/// This is included at compile time when the `auto-deploy` feature is enabled.
42-
#[cfg(feature = "auto-deploy")]
4336
const LAMBDA_BINARY: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/lambda_bootstrap.zip"));
4437

4538
/// Version tag key used to track deployed Quickwit version.
46-
#[cfg(feature = "auto-deploy")]
4739
const VERSION_TAG_KEY: &str = "quickwit_version";
4840

4941
/// Description prefix for auto-deployed Lambda functions.
50-
#[cfg(feature = "auto-deploy")]
5142
const FUNCTION_DESCRIPTION: &str = "Quickwit Lambda leaf search handler";
5243

5344
/// Lambda function deployer.
5445
///
5546
/// Handles creating and updating Lambda functions for the auto-deploy feature.
5647
/// Safe for concurrent calls from multiple Quickwit nodes - CreateFunction is idempotent.
5748
pub struct LambdaDeployer {
58-
#[allow(dead_code)]
5949
client: LambdaClient,
6050
}
6151

@@ -68,7 +58,6 @@ impl LambdaDeployer {
6858
}
6959

7060
/// Create a new Lambda deployer with a custom client.
71-
#[allow(dead_code)]
7261
pub fn with_client(client: LambdaClient) -> Self {
7362
Self { client }
7463
}
@@ -77,7 +66,6 @@ impl LambdaDeployer {
7766
///
7867
/// Safe for concurrent calls from multiple Quickwit nodes - CreateFunction is idempotent.
7968
/// Returns the function ARN.
80-
#[cfg(feature = "auto-deploy")]
8169
pub async fn deploy(
8270
&self,
8371
function_name: &str,
@@ -114,24 +102,13 @@ impl LambdaDeployer {
114102
}
115103
}
116104

117-
/// Deploy is a no-op when auto-deploy feature is not enabled.
118-
#[cfg(not(feature = "auto-deploy"))]
119-
pub async fn deploy(
120-
&self,
121-
_function_name: &str,
122-
_deploy_config: &LambdaDeployConfig,
123-
) -> LambdaResult<String> {
124-
Err(LambdaError::Configuration(
125-
"auto-deploy feature is not enabled at compile time".into(),
126-
))
127-
}
105+
128106

129107
/// Create the Lambda function.
130108
///
131109
/// Note: CreateFunction is idempotent - if the function already exists, AWS returns
132110
/// ResourceConflictException. Multiple Quickwit nodes starting simultaneously is safe;
133111
/// one will succeed and others will fall back to update_function.
134-
#[cfg(feature = "auto-deploy")]
135112
async fn create_function(
136113
&self,
137114
name: &str,
@@ -199,7 +176,6 @@ impl LambdaDeployer {
199176
///
200177
/// Compares the deployed version tag with the current Quickwit version
201178
/// and updates if they differ.
202-
#[cfg(feature = "auto-deploy")]
203179
async fn update_function_if_needed(
204180
&self,
205181
name: &str,
@@ -278,7 +254,6 @@ impl LambdaDeployer {
278254
}
279255

280256
/// Wait for function update to complete.
281-
#[cfg(feature = "auto-deploy")]
282257
async fn wait_for_update_complete(&self, name: &str) -> LambdaResult<()> {
283258
// Poll until the function state is Active and LastUpdateStatus is Successful
284259
for _ in 0..60 {
@@ -319,7 +294,6 @@ impl LambdaDeployer {
319294
}
320295

321296
/// Check if the function needs to be updated based on version tag.
322-
#[cfg(feature = "auto-deploy")]
323297
fn needs_update(&self, existing: &GetFunctionOutput) -> bool {
324298
let current_version = env!("CARGO_PKG_VERSION");
325299

@@ -370,7 +344,6 @@ impl LambdaDeployer {
370344
}
371345

372346
/// Build environment variables for the Lambda function.
373-
#[cfg(feature = "auto-deploy")]
374347
fn build_environment(&self) -> Environment {
375348
let mut env_vars = HashMap::new();
376349
// Set reasonable defaults for logging
@@ -381,7 +354,6 @@ impl LambdaDeployer {
381354
}
382355

383356
/// Build tags for the Lambda function.
384-
#[cfg(feature = "auto-deploy")]
385357
fn build_tags(&self) -> HashMap<String, String> {
386358
let mut tags = HashMap::new();
387359
tags.insert(
@@ -393,7 +365,17 @@ impl LambdaDeployer {
393365
}
394366
}
395367

396-
#[cfg(all(test, feature = "auto-deploy"))]
368+
pub async fn deploy(
369+
function_name: &str,
370+
deploy_config: &LambdaDeployConfig,
371+
) -> LambdaResult<String> {
372+
let lambda_deployer = LambdaDeployer::new().await?;
373+
let lambda_arn = lambda_deployer.deploy(function_name, deploy_config).await?;
374+
info!("successfully deployed lambda function `{}`", lambda_arn);
375+
Ok(lambda_arn)
376+
}
377+
378+
#[cfg(test)]
397379
mod tests {
398380
use super::*;
399381

quickwit/quickwit-lambda/src/invoker.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use crate::handler::{LeafSearchPayload, LeafSearchResponsePayload};
3030
pub struct AwsLambdaInvoker {
3131
client: LambdaClient,
3232
function_name: String,
33-
qualifier: Option<String>,
3433
}
3534

3635
impl AwsLambdaInvoker {
@@ -42,20 +41,17 @@ impl AwsLambdaInvoker {
4241
Ok(Self {
4342
client,
4443
function_name: config.function_name.clone(),
45-
qualifier: config.function_qualifier.clone(),
4644
})
4745
}
4846

4947
/// Create a new AWS Lambda invoker with a custom client.
5048
pub fn with_client(
5149
client: LambdaClient,
5250
function_name: String,
53-
qualifier: Option<String>,
5451
) -> Self {
5552
Self {
5653
client,
5754
function_name,
58-
qualifier,
5955
}
6056
}
6157

quickwit/quickwit-lambda/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,28 @@ mod invoker;
2828

2929
pub use config::{LambdaConfig, LambdaSearcherConfig};
3030
pub use context::LambdaSearcherContext;
31+
32+
#[cfg(feature = "auto-deploy")]
33+
mod deployer;
34+
#[cfg(feature = "auto-deploy")]
3135
pub use deployer::LambdaDeployer;
36+
37+
#[cfg(feature = "auto-deploy")]
38+
mod deployer;
39+
#[cfg(feature = "auto-deploy")]
40+
pub use deployer::deploy;
41+
3242
pub use error::{LambdaError, LambdaResult};
3343
pub use handler::{LeafSearchPayload, LeafSearchResponsePayload, handle_leaf_search};
3444
pub use invoker::AwsLambdaInvoker;
45+
46+
/// Deploy is a no-op when auto-deploy feature is not enabled.
47+
#[cfg(not(feature = "auto-deploy"))]
48+
pub async fn deploy(
49+
_function_name: &str,
50+
_deploy_config: &quickwit_config::LambdaDeployConfig,
51+
) -> LambdaResult<String> {
52+
Err(LambdaError::Configuration(
53+
"auto-deploy feature is not enabled at compile time".into(),
54+
))
55+
}

quickwit/quickwit-serve/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ pprof = [
110110
jemalloc-profiled = [
111111
"quickwit-common/jemalloc-profiled"
112112
]
113+
lambda-auto-deploy = [
114+
"quickwit-lambda/auto-deploy"
115+
]
113116
testsuite = []
114117
sqs-for-tests = [
115118
"quickwit-indexing/sqs",

quickwit/quickwit-serve/src/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,13 +1027,8 @@ async fn setup_searcher(
10271027
// Auto-deploy Lambda function if configured
10281028
if let Some(deploy_config) = &lambda_config.auto_deploy {
10291029
info!("auto-deploying Lambda function");
1030-
let deployer = LambdaDeployer::new()
1031-
.await
1032-
.context("failed to create Lambda deployer")?;
1033-
deployer
1034-
.deploy(&lambda_config.function_name, deploy_config)
1035-
.await
1036-
.context("failed to deploy Lambda function")?;
1030+
quickwit_lambda::deploy(&lambda_config.function_name, deploy_config)
1031+
.context("failed to deploy lambda function")?;
10371032
}
10381033

10391034
let invoker = AwsLambdaInvoker::new(lambda_config)

0 commit comments

Comments
 (0)