Skip to content

Conversation

@endigma
Copy link
Member

@endigma endigma commented Oct 31, 2025

Summary by CodeRabbit

  • New Features
    • Configuration files in .gz and .zst formats are now streamed and automatically decompressed when retrieved.
  • Improvements
    • Unified configuration retrieval with clearer error messages and more reliable resource cleanup.
    • Enhanced streaming read flow and robust error wrapping for fetch/decompress/read failures.
  • Documentation
    • Config schema updated to note automatic decompression for .gz and .zst paths.

  • Adds support for gzip and zstd compressed router configurations in S3
  • Compressed configs are detected by the extension .gz or .zst, these are the defaults when using CLI tools to compress.
  • When a mismatch occurs, e.g. uncompressed data named config.json.gz, a reasonably helpful error is emitted

Checklist

  • I have discussed my proposed changes in an issue and have received approval to proceed.
  • I have followed the coding standards of the project.
  • Tests or benchmarks have been added or updated.
  • Documentation has been updated on https://github.com/wundergraph/cosmo-docs.
  • I have read the Contributors Guide.

@coderabbitai
Copy link

coderabbitai bot commented Oct 31, 2025

Walkthrough

Removed the version parameter from S3 config retrieval methods, centralized object retrieval into getConfigFile(ctx, modifiedSince), added streaming decompression for .gz and .zst S3 objects, unified read path returning bytes, and added deferred Close calls and enhanced error wrapping.

Changes

Cohort / File(s) Summary
S3 client and router config changes
router/pkg/routerconfig/s3/client.go
Removed version parameter from getConfigFile and RouterConfig signatures; consolidated object retrieval into getConfigFile(ctx, modifiedSince); introduced streaming decompression for .gz (gzip) and .zst (zstd) by wrapping the MinIO reader; deferred Close for MinIO and decompressor readers; unified read-to-bytes via a config reader; added contextual error wrapping for GetObject, decompressor creation, and read failures; preserved not-modified/not-found semantics.
Schema description update
router/pkg/config/config.schema.json
Extended execution_config.fallback_storage.object_path.description to state that files ending with .zst or .gz will be decompressed before reading.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check all callers of RouterConfig and getConfigFile for signature changes and correct handling of the ignored version parameter.
  • Verify decompressor selection by path suffix and ensure all Close defers execute on error paths.
  • Review wrapped errors to confirm original error contexts are preserved and messages are clear.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(router): add support for compressed config files' clearly and specifically describes the main change—adding compression support for router config files in S3.
✨ Finishing touches
  • 📝 Generate docstrings

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

@github-actions
Copy link

github-actions bot commented Oct 31, 2025

Router-nonroot image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-ed80ad15cc3b7d395c2d397588338f6ffa2d558a-nonroot

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f865487 and 6f94eca.

📒 Files selected for processing (1)
  • router/pkg/routerconfig/s3/client.go (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-26T17:19:28.178Z
Learnt from: SkArchon
Repo: wundergraph/cosmo PR: 2167
File: router/internal/expr/retry_context.go:3-10
Timestamp: 2025-08-26T17:19:28.178Z
Learning: In the Cosmo router codebase, prefer using netErr.Timeout() checks over explicit context.DeadlineExceeded checks for timeout detection in retry logic, as Go's networking stack typically wraps context deadline exceeded errors in proper net.Error implementations.

Applied to files:

  • router/pkg/routerconfig/s3/client.go
🧬 Code graph analysis (1)
router/pkg/routerconfig/s3/client.go (1)
router/pkg/routerconfig/client.go (2)
  • Client (16-20)
  • Response (11-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: build-router
  • GitHub Check: build_test
  • GitHub Check: integration_test (./events)
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: image_scan
  • GitHub Check: image_scan (nonroot)
  • GitHub Check: build_push_image
  • GitHub Check: build_push_image (nonroot)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)

@endigma
Copy link
Member Author

endigma commented Oct 31, 2025

Compression methods speeds and ratios

Original size: 16711107 bytes (15.94 MB), large JSON execution config used in production

Speeds measured on an M4 Pro, averaged over 10 runs

Compression Results

Algorithm Compressed Size Savings Decompress Time
gzip (default) 3.03 MB 81.01% 38.145904ms
gzip (best speed) 4.02 MB 74.80% 47.63915ms
gzip (best compression) 3.01 MB 81.10% 37.868591ms
zstd (default) 1.89 MB 88.16% 9.431262ms
zstd (best speed) 2.57 MB 83.87% 12.939183ms
zstd (best compression) 1.21 MB 92.38% 7.1832ms

Ranked by Compression Savings

Rank Algorithm Savings
1 zstd (best compression) 92.38%
2 zstd (default) 88.16%
3 zstd (best speed) 83.87%
4 gzip (best compression) 81.10%
5 gzip (default) 81.01%
6 gzip (best speed) 74.80%

Ranked by Decompression Time

Rank Algorithm Decompress Time
1 zstd (best compression) 7.1832ms
2 zstd (default) 9.431262ms
3 zstd (best speed) 12.939183ms
4 gzip (best compression) 37.868591ms
5 gzip (default) 38.145904ms
6 gzip (best speed) 47.63915ms

Summary

Using zstd in best compression settings is recommended. gzip in default settings is a good fallback where zstd is not available.

Copy link
Contributor

@StarpTech StarpTech left a comment

Choose a reason for hiding this comment

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

LGTM

@endigma endigma force-pushed the jesse/eng-8425-router-execution-config-compression branch from 4b356d1 to cb674f7 Compare November 10, 2025 10:14
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
router/pkg/routerconfig/s3/client.go (1)

100-122: Consider extracting extension constants for maintainability.

The hardcoded extensions ".gz" and ".zst" could be extracted as package-level constants if you anticipate adding more compression formats or referencing these values elsewhere. However, the current inline approach is perfectly clear and maintainable for two extensions.

Example (if desired):

const (
    extGzip = ".gz"
    extZstd = ".zst"
)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b356d1 and cb674f7.

📒 Files selected for processing (2)
  • router/pkg/config/config.schema.json (1 hunks)
  • router/pkg/routerconfig/s3/client.go (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • router/pkg/config/config.schema.json
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-26T17:19:28.178Z
Learnt from: SkArchon
Repo: wundergraph/cosmo PR: 2167
File: router/internal/expr/retry_context.go:3-10
Timestamp: 2025-08-26T17:19:28.178Z
Learning: In the Cosmo router codebase, prefer using netErr.Timeout() checks over explicit context.DeadlineExceeded checks for timeout detection in retry logic, as Go's networking stack typically wraps context deadline exceeded errors in proper net.Error implementations.

Applied to files:

  • router/pkg/routerconfig/s3/client.go
🧬 Code graph analysis (1)
router/pkg/routerconfig/s3/client.go (1)
router/pkg/routerconfig/client.go (2)
  • Client (16-20)
  • Response (11-14)
🔇 Additional comments (3)
router/pkg/routerconfig/s3/client.go (3)

75-130: Excellent resource management and decompression implementation!

The streaming decompression logic is well-structured:

  • Correct defer order: Decompressors close before minioReader via LIFO, ensuring proper cleanup.
  • Case-insensitive extension matching: strings.ToLower at line 100 correctly addresses the previous review feedback.
  • Graceful fallback: Unknown extensions fall through to uncompressed handling.
  • Consistent error wrapping: All errors include helpful context.

The defer placement at lines 96, 107, and 117 ensures cleanup even on early returns, and the order guarantees decompressors close before the underlying reader closes.


132-151: Correct interface implementation with version parameter removal.

The method correctly implements the routerconfig.Client interface by accepting but ignoring the prevVersion parameter (line 132). For S3-based config retrieval, using modifiedSince for conditional fetching makes sense, and version tracking is unnecessary.

The error handling at lines 138-143 properly translates MinIO-specific errors to the appropriate sentinel errors expected by the config poller.


13-14: No issues found—klauspost/compress libraries are standard-compliant.

The klauspost/compress packages are implemented as drop-in replacements that produce and read standard gzip and zstd streams. The imports at lines 13-14 are appropriate and will maintain interoperability with standard compression tools.

@endigma endigma merged commit b1a136b into main Nov 10, 2025
37 of 38 checks passed
@endigma endigma deleted the jesse/eng-8425-router-execution-config-compression branch November 10, 2025 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants