-
Notifications
You must be signed in to change notification settings - Fork 950
feat: KEP-2655: Add data cache system #2755
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ jobs: | |
| runtimes | ||
| scripts | ||
| test | ||
| cache | ||
| requireScope: false | ||
| ignoreLabels: | | ||
| do-not-merge/work-in-progress | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| FROM rust:1.85-bullseye AS builder | ||
|
|
||
| WORKDIR /workspace | ||
|
|
||
| ENV RUST_LOG=info | ||
|
|
||
| # Install system dependencies | ||
| RUN apt-get update && \ | ||
| apt-get -y install libssl-dev openssl zlib1g zlib1g-dev libpq-dev cmake protobuf-compiler netcat curl && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Install cargo-chef for better caching | ||
| RUN rustup update && cargo install cargo-chef --version 0.1.62 | ||
|
|
||
| # Copy manifests for dependency caching | ||
| COPY pkg/data_cache/Cargo.toml pkg/data_cache/Cargo.lock ./ | ||
|
|
||
| # Cache dependencies | ||
| RUN cargo fetch | ||
|
|
||
| # Copy source code | ||
| COPY pkg/data_cache/ . | ||
|
|
||
| # Run tests | ||
| RUN cargo test --tests | ||
|
akshaychitneni marked this conversation as resolved.
|
||
|
|
||
| # Build binaries in release mode | ||
| RUN cargo build --release --bin head --bin worker | ||
|
|
||
| # Stage 2: Create a minimal runtime image | ||
| FROM debian:bookworm-slim AS runtime | ||
|
|
||
| # Install runtime dependencies | ||
| RUN apt-get update && \ | ||
| apt-get -y install ca-certificates && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Copy binaries from builder stage | ||
| COPY --from=builder /workspace/target/release/head /usr/local/bin/head | ||
| COPY --from=builder /workspace/target/release/worker /usr/local/bin/worker | ||
|
|
||
| # Create non-root user | ||
| RUN groupadd -r cache_user && useradd -r -g cache_user cache_user | ||
|
|
||
| # Change ownership and switch to non-root user | ||
| RUN chown -R cache_user:cache_user /usr/local/bin/ | ||
| USER cache_user | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Check for required arguments | ||
| if [ $# -lt 5 ]; then | ||
| echo "Usage: $0 <iam-role-arn> <metadata-loc> <table-name> <schema-name> <aws-profile> [environment]" | ||
| exit 1 | ||
| fi | ||
|
|
||
| IAM_ROLE_ARN="$1" | ||
| METADATA_LOC="$2" | ||
| TABLE_NAME="$3" | ||
| SCHEMA_NAME="$4" | ||
| AWS_PROFILE="$5" | ||
| ENVIRONMENT="${6:-LOCAL}" | ||
|
|
||
| echo "Using IAM Role: $IAM_ROLE_ARN" | ||
| echo "Metadata Location: $METADATA_LOC" | ||
| echo "Table Name: $TABLE_NAME" | ||
| echo "Schema Name: $SCHEMA_NAME" | ||
| echo "Environment: $ENVIRONMENT" | ||
| echo "AWS Profile: $AWS_PROFILE" | ||
|
|
||
| role_output=$(aws sts assume-role --role-arn "$IAM_ROLE_ARN" --role-session-name "RoleSession1" --profile "$AWS_PROFILE") | ||
|
|
||
| # Parse the JSON output using jq | ||
| export AWS_ACCESS_KEY_ID=$(echo $role_output | jq -r '.Credentials.AccessKeyId') | ||
| export AWS_SECRET_ACCESS_KEY=$(echo $role_output | jq -r '.Credentials.SecretAccessKey') | ||
| export AWS_SESSION_TOKEN=$(echo $role_output | jq -r '.Credentials.SessionToken') | ||
| export AWS_REGION=us-west-2 | ||
| export AWS_EC2_METADATA_DISABLED=true | ||
|
|
||
| # Set required environment variables for testing | ||
| export METADATA_LOC="$METADATA_LOC" | ||
| export TABLE_NAME="$TABLE_NAME" | ||
| export SCHEMA_NAME="$SCHEMA_NAME" | ||
| export RUNTIME_ENV="$ENVIRONMENT" | ||
|
|
||
| # Function to cleanup processes on exit | ||
| cleanup() { | ||
| echo "" | ||
| echo "Stopping services..." | ||
| kill -9 $WORKER1_PID $WORKER2_PID $HEAD_PID 2>/dev/null || true | ||
| wait $WORKER1_PID $WORKER2_PID $HEAD_PID 2>/dev/null || true | ||
| rm -rf /tmp/test_metadata | ||
| exit 0 | ||
| } | ||
|
|
||
| # Set up signal handlers for graceful shutdown | ||
| trap cleanup SIGINT SIGTERM | ||
|
|
||
| # Function to check if a service is ready | ||
| check_service_ready() { | ||
| local host=$1 | ||
| local port=$2 | ||
| local service_name=$3 | ||
|
|
||
| echo "Waiting for $service_name to be ready on $host:$port..." | ||
| while ! nc -z "$host" "$port" 2>/dev/null; do | ||
| echo " $service_name not ready yet, waiting 2 seconds..." | ||
| sleep 2 | ||
| done | ||
| echo " $service_name is ready!" | ||
| } | ||
|
|
||
| echo "Starting worker node 1..." | ||
| cargo run --bin worker -- 0.0.0.0 50052 > worker1.log 2>&1 & | ||
| WORKER1_PID=$! | ||
|
|
||
| echo "Starting worker node 2..." | ||
| cargo run --bin worker -- 0.0.0.0 50053 > worker2.log 2>&1 & | ||
| WORKER2_PID=$! | ||
|
|
||
| # Wait for both workers to be ready | ||
| check_service_ready localhost 50052 "worker1" | ||
| check_service_ready localhost 50053 "worker2" | ||
|
|
||
| echo "Both workers are ready, starting head node..." | ||
| cargo run --bin head -- 0.0.0.0 50051 > head.log 2>&1 & | ||
| HEAD_PID=$! | ||
|
|
||
| check_service_ready localhost 50051 "head" | ||
|
|
||
| echo "All services are running. Press Ctrl+C to stop all services." | ||
| wait | ||
|
|
||
| #echo "Running client test..." | ||
| #cd src/client && cargo run 2>&1 | ||
| #CLIENT_EXIT_CODE=$? |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.