Skip to content

feat/k8s cronjob#73

Open
IsaacTai13 wants to merge 6 commits intomainfrom
feat/k8s-cronjob
Open

feat/k8s cronjob#73
IsaacTai13 wants to merge 6 commits intomainfrom
feat/k8s-cronjob

Conversation

@IsaacTai13
Copy link
Copy Markdown

@IsaacTai13 IsaacTai13 commented May 6, 2026

Summary by CodeRabbit

Release Notes

  • New Features
    • Added batch-based message publishing with configurable batch size flag.
    • Introduced latency analysis tools to compute message propagation statistics including percentiles (p50, p90, p95, p99) and identify top outliers.
    • Added Kubernetes deployment support via CronJob scheduling and Docker image build automation.
    • Introduced test orchestration scripts for both local and Kubernetes environments.

Adds a background goroutine to continuously consume messages from the gRPC receive stream. This prevents flow control buffers from filling up on the server side, ensuring that pushed traces or responses do not eventually block the publisher's Send operations.
- Add Dockerfile with multi-stage build to compile Go binaries for Linux
- Create entrypoint.sh driven by environment variables with graceful shutdown
- cronjob.yaml template using ConfigMap to inject node IPs dynamically
- Use TARGETOS and TARGETARCH args in Dockerfile to compile Go binaries dynamically
- Add --platform=$BUILDPLATFORM to the Go builder stage for faster cross-compilation
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Walkthrough

This pull request introduces infrastructure for automated P2P load testing with latency analysis capabilities. It adds batch-based publishing support to the gRPC multi-publish tool with a drain goroutine to manage stream backpressure. New latency analysis scripts compute per-message propagation latencies from trace files with statistical summaries. Shell scripts orchestrate subscriber-publisher workflows locally and via Kubernetes CronJob scheduling, including pre-test cleanup, post-test analysis, and result archiving. A Kubernetes manifest defines the scheduled load test environment with configurable parameters.

Sequence Diagram(s)

sequenceDiagram
    participant Orchestrator as Test Orchestrator<br/>(run_test.sh/<br/>entrypoint.sh)
    participant Sub as Subscriber<br/>(p2p-multi-subscribe)
    participant Pub as Publisher<br/>(p2p-multi-publish)
    participant TraceFile as Trace File<br/>(output)
    participant Analyzer as Latency Analyzer<br/>(analyze_latency.py)
    participant Summary as Summary Report

    rect rgba(100, 149, 237, 0.5)
    Note over Orchestrator,Summary: Load Test Execution Loop
    Orchestrator->>Sub: Start subscriber<br/>(background)
    Sub->>TraceFile: Write DELIVER_MESSAGE<br/>events
    Orchestrator->>Pub: Run publisher<br/>(foreground)
    Pub->>Sub: Send messages
    Orchestrator->>Sub: Stop subscriber<br/>(after completion)
    end

    rect rgba(144, 238, 144, 0.5)
    Note over Orchestrator,Summary: Analysis Phase
    Orchestrator->>Analyzer: Invoke with trace file
    Analyzer->>TraceFile: Read DELIVER_MESSAGE<br/>events
    Analyzer->>Analyzer: Group by message ID<br/>Calculate latencies
    Analyzer->>Summary: Output statistics<br/>(mean, p50, p90,<br/>p95, p99, max)<br/>& top 5 outliers
    Orchestrator->>Summary: Append to results
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

🚥 Pre-merge checks | ✅ 5 | ❌ 5

❌ Failed checks (5 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title does not follow the required format. It lacks the colon separator and proper structure: type(domain/pkg): description. Reformat the title to match the required pattern. Example: 'feat(k8s-cronjob): add kubernetes cronjob for load testing' (must be under 72 characters).
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Go Build And Test Rationale ⚠️ Warning Go code changes lack test coverage. New batch feature and drain goroutine introduce risky concurrent logic without tests. The --batch flag is unvalidated, risking panic. Add --batch >= 1 validation and unit tests for batch publishing logic, drain goroutine behavior, sleep timing with batching, and error cases.
Concurrency Safety ⚠️ Warning Drain goroutine (lines 137-144) leaks without context cancellation. No lifecycle management; goroutine continues running indefinitely after sendMessages() returns, violating Go concurrency patterns. Add context awareness to drain goroutine: wrap stream.Recv() in select with ctx.Done() case. Fix: select { case <-ctx.Done(): return; default: }; _, err := stream.Recv(). Also validate batch >= 1 to prevent division-by-zero at line 182.
Security Considerations ⚠️ Warning Path traversal vulnerability: --msg-size parameter unsanitized in analyze_latency.py, directly interpolated into filesystem paths via os.path.join(), allowing directory traversal via '..' sequences. Validate msg_size/DATASIZE with regex or basename() to reject path traversal sequences ('..' and '/') before constructing file paths in both Python scripts.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Public Api Changes ✅ Passed No breaking changes to exported types/functions. New CLI scripts and refactoring of main.go with no exported function signature modifications detected.
Rust Best Practices ✅ Passed Custom check for Rust best practices is not applicable. This PR contains no Rust code—only Go, Python, shell scripts, and YAML configuration files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/k8s-cronjob

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant