Skip to content

chore(gateway): Add logs RateLimiter for Gateway#1472

Open
sergeymatov wants to merge 1 commit into
masterfrom
smatov/rate-limiter-enablement
Open

chore(gateway): Add logs RateLimiter for Gateway#1472
sergeymatov wants to merge 1 commit into
masterfrom
smatov/rate-limiter-enablement

Conversation

@sergeymatov

@sergeymatov sergeymatov commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

A part of "BURST:REPLENISHMENTS_PER_SECOND" defines rate limiter config for Token/Bucket throttler in the Gatewy.

Overview

Adds log rate limiting support to the Gateway API, enabling token-bucket-style throttling of log messages through a new GatewayLogRateLimit configuration type.

Changes

Core Implementation

  • Introduces GatewayLogRateLimit type with Burst (uint32) and ReplenishPerSecond (uint32) fields in api/gateway/v1alpha1/gateway_types.go
  • Adds optional rateLimit field to GatewayLogs struct
  • Extends (*Gateway).Validate method to validate rate limit configuration, rejecting configurations where either burst or replenishPerSecond is zero

Testing

  • Adds three new test cases to TestGatewayValidate covering:
    • Valid rate limit configuration (Burst: 50, ReplenishPerSecond: 5)
    • Invalid configurations with zero burst or zero replenish rate

Generated Code

  • Autogenerated deepcopy implementations for GatewayLogRateLimit in zz_generated.deepcopy.go
  • Extended GatewayLogs.DeepCopyInto to handle the new RateLimit field

API and Schema

  • Updated OpenAPI v3 schema in config/crd/bases/gateway.githedgehog.com_gateways.yaml for Gateway CRD
  • Updated OpenAPI v3 schema in config/crd/bases/gwint.githedgehog.com_gatewayagents.yaml for GatewayAgent CRD
  • Updated API documentation in docs/api.md with GatewayLogRateLimit type definition and usage

Scope

+97 lines across 6 files, implementing the foundational configuration for log rate limiting in the Gateway.

A part of "BURST:REPLENISHMENTS_PER_SECOND" defines rate
limiter config for Token/Bucket throttler in the Gatewy.

Signed-off-by: Sergey Matov <sergey.matov@githedgehog.com>
@sergeymatov sergeymatov requested review from a team as code owners June 9, 2026 13:47
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e07e4107-a87b-4874-a935-fade2cd54905

📥 Commits

Reviewing files that changed from the base of the PR and between 5c52939 and 5b49651.

📒 Files selected for processing (6)
  • api/gateway/v1alpha1/gateway_types.go
  • api/gateway/v1alpha1/gateway_types_test.go
  • api/gateway/v1alpha1/zz_generated.deepcopy.go
  • config/crd/bases/gateway.githedgehog.com_gateways.yaml
  • config/crd/bases/gwint.githedgehog.com_gatewayagents.yaml
  • docs/api.md

📝 Walkthrough

Walkthrough

This PR adds optional token-bucket rate limiting for gateway logs. A new GatewayLogRateLimit type defines burst and replenishPerSecond parameters, integrated into GatewayLogs as an optional field. Validation ensures both parameters are non-zero when configured. CRD schemas, deepcopy support, and API documentation are updated accordingly.

Changes

Gateway Log Rate Limiting

Layer / File(s) Summary
Type definition and validation logic
api/gateway/v1alpha1/gateway_types.go, api/gateway/v1alpha1/gateway_types_test.go
GatewayLogRateLimit struct is defined with Burst and ReplenishPerSecond uint32 fields, added as optional RateLimit field to GatewayLogs, and Gateway.Validate enforces both parameters are non-zero when set. Three test cases validate the behavior: one passing case and two failing cases where either parameter is zero.
Generated deepcopy methods
api/gateway/v1alpha1/zz_generated.deepcopy.go
Auto-generated DeepCopyInto and DeepCopy methods for GatewayLogRateLimit, and GatewayLogs.DeepCopyInto extended to allocate and deep-copy the non-nil RateLimit field.
CRD schema updates
config/crd/bases/gateway.githedgehog.com_gateways.yaml, config/crd/bases/gwint.githedgehog.com_gatewayagents.yaml
Both Gateway and GatewayAgent CRD schemas are extended with optional spec.logs.rateLimit object defining burst and replenishPerSecond integer fields for token-bucket rate limiting configuration.
API documentation
docs/api.md
New GatewayLogRateLimit type is documented with token-bucket parameters and behavior, and GatewayLogs.rateLimit field is added with reference to the new type.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A token bucket hops along,
Limiting logs, keeping flows strong,
Burst and replenish in perfect time,
Rate limiting configured, a system sublime!
Gateway logs now throttle with grace,
No flood shall ever clog this place! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a logs rate limiter feature to the Gateway API type and configuration.
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.

✏️ 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 smatov/rate-limiter-enablement

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

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

🚀 Temp artifacts published: v0-5b496519d 🚀

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