impr(WKBCH-23): Add rate limit supprt#78
Conversation
| Lifecycle: LifecycleFeatureConfig{ | ||
| Enabled: false, | ||
| }, | ||
| RateLimiting: RateLimitingFeatureConfig{ |
There was a problem hiding this comment.
Rate limiting requires Redis (via localCache), but the Redis service in docker-compose.yaml does not include a feature-rate-limiting profile. If a user enables only rate limiting (without utapi, CRR, etc.), Redis won't start and cloudserver will fail to connect. A feature-rate-limiting profile needs to be added to the Redis service, and getComposeProfiles in cmd/util.go needs a corresponding entry for RateLimiting.Enabled.
— Claude Code
Review by Claude Code |
| "limit": {{ .Features.RateLimiting.Account.RequestsPerSecond.Limit }}, | ||
| "burstCapacity": {{ .Features.RateLimiting.Account.RequestsPerSecond.BurstCapacity }} | ||
| } | ||
| }, |
There was a problem hiding this comment.
configCacheTTL is hardcoded to 30000 here instead of using the template variable. The bucket section correctly uses {{ .Features.RateLimiting.Bucket.ConfigCacheTTL }}, but the account section ignores the config value.
| }, | |
| "configCacheTTL": {{ .Features.RateLimiting.Account.ConfigCacheTTL }} |
— Claude Code
| {{- end }} | ||
| "configCacheTTL": 30000 | ||
| }, | ||
| "error": { |
There was a problem hiding this comment.
Same hardcoded configCacheTTL issue as in config-v9.json — should use {{ .Features.RateLimiting.Account.ConfigCacheTTL }} to respect user config.
| "error": { | |
| "configCacheTTL": {{ .Features.RateLimiting.Account.ConfigCacheTTL }} |
— Claude Code
| {{ if .Features.Utapi.Enabled }} | ||
| {{ if or .Features.Utapi.Enabled .Features.RateLimiting.Enabled }} | ||
| "localCache": { | ||
| "host": "localhost", |
There was a problem hiding this comment.
The templates now require Redis (localCache) when rate limiting is enabled, but the Redis service in docker-compose.yaml does not include a rate-limiting profile, and getComposeProfiles() in cmd/util.go has no entry for features.rate_limiting. If a user enables only rate limiting (no utapi, crr, notifications, migration, or lifecycle), Redis will not start and cloudserver will fail to connect.
You need to: (1) add a profile like feature-rate-limiting to the Redis service in docker-compose.yaml, and (2) add a corresponding block in getComposeProfiles() to activate it when cfg.Features.RateLimiting.Enabled is true.
— Claude Code
Review by Claude Code |
551d6a2 to
a3d5a32
Compare
| @@ -275,6 +299,19 @@ func DefaultEnvironmentConfig() EnvironmentConfig { | |||
| Lifecycle: LifecycleFeatureConfig{ | |||
| Enabled: false, | |||
| }, | |||
There was a problem hiding this comment.
Every other feature in DefaultEnvironmentConfig() explicitly sets Enabled: false (e.g., Utapi, Migration, Lifecycle). While Go's zero value handles this correctly, adding it here keeps the defaults self-documenting and consistent.
| }, | |
| RateLimiting: RateLimitingFeatureConfig{ | |
| Enabled: false, | |
| Bucket: RateLimitingDefaultLimits{ |
— Claude Code
|
a3d5a32 to
7e1c043
Compare
| volumes: | ||
| - ./config/vault/:/secrets | ||
| profiles: | ||
| - base |
There was a problem hiding this comment.
setup-cloudserver is in the base profile, so it runs for ALL environments — even those not using rate limiting. This forces every user to pull SCUBA_IMAGE and run the rate-limit service user creation script. It should use feature-rate-limiting profile, matching the pattern of setup-scuba in feature-scuba.
— Claude Code
Review by Claude Code |
7e1c043 to
54e45a3
Compare
| volumes: | ||
| - ./config/vault/:/secrets | ||
| profiles: | ||
| - feature-rate-limiting |
There was a problem hiding this comment.
cloudserver (in the base profile) has no depends_on for setup-rate-limiting-svc-user. When rate limiting is enabled, cloudserver could start and receive requests before the rate-limit service user is created in vault. If cloudserver needs the service user ARN to be resolvable at request time, rate-limiting would silently fail during that startup window.
Docker Compose profiles make conditional depends_on tricky — adding the dependency directly would break when the feature-rate-limiting profile is inactive. Worth documenting this startup ordering assumption, or having cloudserver retry/degrade gracefully if the service user doesn't exist yet.
— Claude Code
|
|
||
| echo "[setup] rate-limit service user credentials:" | ||
| echo "SERVICE_ACCESS_KEY=$SERVICE_ACCESS_KEY" | ||
| echo "SERVICE_SECRET_KEY=$SERVICE_SECRET_KEY" |
There was a problem hiding this comment.
Service credentials (access key and secret key) are echoed to stdout on lines 19-20, which will appear in container logs. This matches the existing pattern in templates/scuba/create-service-user.sh, but it's worth noting that anyone with access to container logs can read these internal service credentials.
— Claude Code
|
No description provided.