Skip to content

Commit

Permalink
add changelog and manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
pasha-codefresh committed Jan 16, 2024
1 parent 7c4c089 commit 21e6fed
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Event reporter v2.0.3
1. Implemented a fixed window rate limiter for the event reporter to prevent the application from overflowing the entire reporter queue. This enhancement ensures timely reporting without causing delays for other applications.
46 changes: 46 additions & 0 deletions event_reporter/reporter/rate_limiter_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package reporter

import (
"testing"
"time"
)

func TestRateLimiter(t *testing.T) {
t.Run("Limiter is turned off", func(t *testing.T) {
rl := NewRateLimiter(&RateLimiterOpts{
Enabled: false,
})
d, err := rl.Limit("foo")
if err != nil {
t.Errorf("Expected no error, got %v", err)
}
if d != 0 {
t.Errorf("Expected 0 duration, got %v", d)
}
})
t.Run("Limiter is turned on", func(t *testing.T) {
rl := NewRateLimiter(&RateLimiterOpts{
Enabled: true,
Rate: time.Second,
Capacity: 1,
})
d, err := rl.Limit("foo")
if err != nil {
t.Errorf("Expected no error, got %v", err)
}
if d != 0 {
t.Errorf("Expected 0 duration, got %v", d)
}
})
t.Run("Limiter is turned on but with 0 capacity", func(t *testing.T) {
rl := NewRateLimiter(&RateLimiterOpts{
Enabled: true,
Rate: time.Second,
Capacity: 0,
})
_, err := rl.Limit("foo")
if err == nil {
t.Errorf("Expected error, got nil")
}
})
}
18 changes: 18 additions & 0 deletions manifests/base/event-reporter/event-reporter-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ spec:
args:
- /usr/local/bin/event-reporter-server
env:
- name: RATE_LIMITER_ENABLED
valueFrom:
configMapKeyRef:
name: argocd-cmd-params-cm
key: event-reporter.rate-limiter.enabled
optional: true
- name: RATE_LIMITER_BUCKET_SIZE
valueFrom:
configMapKeyRef:
name: argocd-cmd-params-cm
key: event-reporter.rate-limiter.bucket-size
optional: true
- name: RATE_LIMITER_DURATION
valueFrom:
configMapKeyRef:
name: argocd-cmd-params-cm
key: event-reporter.rate-limiter.duration
optional: true
- name: EVENT_REPORTER_REPLICAS
value: "5"
- name: ARGOCD_TOKEN
Expand Down

0 comments on commit 21e6fed

Please sign in to comment.