Skip to content

Commit 908d602

Browse files
committed
make lint happy
1 parent 853c7f2 commit 908d602

File tree

3 files changed

+31
-44
lines changed

3 files changed

+31
-44
lines changed

maintnotifications/e2e/notification_injector.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func NewNotificationInjector() (NotificationInjector, error) {
5656
// Use proxy-based mock
5757
apiPort := 8100
5858
if portStr := os.Getenv("PROXY_API_PORT"); portStr != "" {
59-
fmt.Sscanf(portStr, "%d", &apiPort)
59+
_, _ = fmt.Sscanf(portStr, "%d", &apiPort)
6060
}
6161

6262
return NewProxyNotificationInjector(apiPort), nil
@@ -105,7 +105,7 @@ func (p *ProxyNotificationInjector) Start() error {
105105

106106
targetPort := 6379
107107
if portStr := os.Getenv("REDIS_TARGET_PORT"); portStr != "" {
108-
fmt.Sscanf(portStr, "%d", &targetPort)
108+
_, _ = fmt.Sscanf(portStr, "%d", &targetPort)
109109
}
110110

111111
// Parse cluster addresses
@@ -116,7 +116,7 @@ func (p *ProxyNotificationInjector) Start() error {
116116

117117
// Extract first port for initial node
118118
var initialPort int
119-
fmt.Sscanf(strings.Split(addrs[0], ":")[1], "%d", &initialPort)
119+
_, _ = fmt.Sscanf(strings.Split(addrs[0], ":")[1], "%d", &initialPort)
120120

121121
// Check if proxy is already running (e.g., in Docker)
122122
proxyAlreadyRunning := false
@@ -164,7 +164,7 @@ func (p *ProxyNotificationInjector) Start() error {
164164
if !proxyAlreadyRunning {
165165
for i := 1; i < len(addrs); i++ {
166166
var port int
167-
fmt.Sscanf(strings.Split(addrs[i], ":")[1], "%d", &port)
167+
_, _ = fmt.Sscanf(strings.Split(addrs[i], ":")[1], "%d", &port)
168168
if err := p.addNode(port, targetPort, targetHost); err != nil {
169169
return fmt.Errorf("failed to add node %d: %w", i, err)
170170
}
@@ -421,7 +421,7 @@ func NewFaultInjectorNotificationInjector(baseURL string) *FaultInjectorNotifica
421421

422422
bdbID := 1
423423
if bdbIDStr := os.Getenv("BDB_ID"); bdbIDStr != "" {
424-
fmt.Sscanf(bdbIDStr, "%d", &bdbID)
424+
_, _ = fmt.Sscanf(bdbIDStr, "%d", &bdbID)
425425
}
426426

427427
return &FaultInjectorNotificationInjector{
@@ -455,9 +455,9 @@ func (f *FaultInjectorNotificationInjector) InjectSMIGRATING(ctx context.Context
455455
var startSlot, endSlot int
456456
if len(slots) > 0 {
457457
if strings.Contains(slots[0], "-") {
458-
fmt.Sscanf(slots[0], "%d-%d", &startSlot, &endSlot)
458+
_, _ = fmt.Sscanf(slots[0], "%d-%d", &startSlot, &endSlot)
459459
} else {
460-
fmt.Sscanf(slots[0], "%d", &startSlot)
460+
_, _ = fmt.Sscanf(slots[0], "%d", &startSlot)
461461
endSlot = startSlot
462462
}
463463
}

maintnotifications/e2e/notiftracker.go

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -305,20 +305,6 @@ func setupClusterClientNotificationHook(client *redis.ClusterClient, hook maintn
305305
})
306306
}
307307

308-
// filterPushNotificationLogs filters the diagnostics log for push notification events
309-
func filterPushNotificationLogs(diagnosticsLog []DiagnosticsEvent) []DiagnosticsEvent {
310-
var pushNotificationLogs []DiagnosticsEvent
311-
312-
for _, log := range diagnosticsLog {
313-
switch log.Type {
314-
case "MOVING", "MIGRATING", "SMIGRATING", "MIGRATED", "SMIGRATED":
315-
pushNotificationLogs = append(pushNotificationLogs, log)
316-
}
317-
}
318-
319-
return pushNotificationLogs
320-
}
321-
322308
func (tnh *TrackingNotificationsHook) GetAnalysis() *DiagnosticsAnalysis {
323309
return NewDiagnosticsAnalysis(tnh.GetDiagnosticsLog())
324310
}
@@ -368,41 +354,42 @@ func NewDiagnosticsAnalysis(diagnosticsLog []DiagnosticsEvent) *DiagnosticsAnaly
368354
return da
369355
}
370356

371-
func (da *DiagnosticsAnalysis) Analyze() {
372-
for _, log := range da.diagnosticsLog {
373-
da.TotalNotifications++
357+
func (a *DiagnosticsAnalysis) Analyze() {
358+
for _, log := range a.diagnosticsLog {
359+
a.TotalNotifications++
374360
switch log.Type {
375361
case "MOVING":
376-
da.MovingCount++
362+
a.MovingCount++
377363
case "MIGRATING", "SMIGRATING":
378-
da.MigratingCount++
364+
a.MigratingCount++
379365
case "MIGRATED", "SMIGRATED":
380-
da.MigratedCount++
366+
a.MigratedCount++
381367
case "FAILING_OVER":
382-
da.FailingOverCount++
368+
a.FailingOverCount++
383369
case "FAILED_OVER":
384-
da.FailedOverCount++
370+
a.FailedOverCount++
385371
default:
386-
da.UnexpectedNotificationCount++
372+
a.UnexpectedNotificationCount++
387373
}
388374
if log.Error != nil {
389375
fmt.Printf("[ERROR] Notification processing error: %v\n", log.Error)
390376
fmt.Printf("[ERROR] Notification: %v\n", log.Details["notification"])
391377
fmt.Printf("[ERROR] Context: %v\n", log.Details["context"])
392-
da.NotificationProcessingErrors++
378+
a.NotificationProcessingErrors++
393379
}
394-
if log.Type == "MIGRATING" || log.Type == "SMIGRATING" || log.Type == "FAILING_OVER" {
395-
da.RelaxedTimeoutCount++
396-
} else if log.Type == "MIGRATED" || log.Type == "SMIGRATED" || log.Type == "FAILED_OVER" {
397-
da.UnrelaxedTimeoutCount++
380+
switch log.Type {
381+
case "MIGRATING", "SMIGRATING", "FAILING_OVER":
382+
a.RelaxedTimeoutCount++
383+
case "MIGRATED", "SMIGRATED", "FAILED_OVER":
384+
a.UnrelaxedTimeoutCount++
398385
}
399386
if log.ConnID != 0 {
400-
if v, ok := da.connIds[log.ConnID]; !ok || !v {
401-
da.connIds[log.ConnID] = true
402-
da.connLogs[log.ConnID] = make([]DiagnosticsEvent, 0)
403-
da.ConnectionCount++
387+
if v, ok := a.connIds[log.ConnID]; !ok || !v {
388+
a.connIds[log.ConnID] = true
389+
a.connLogs[log.ConnID] = make([]DiagnosticsEvent, 0)
390+
a.ConnectionCount++
404391
}
405-
da.connLogs[log.ConnID] = append(da.connLogs[log.ConnID], log)
392+
a.connLogs[log.ConnID] = append(a.connLogs[log.ConnID], log)
406393
}
407394

408395
}

maintnotifications/e2e/proxy_fault_injector_server.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func (s *ProxyFaultInjectorServer) Stop() error {
262262
if s.httpServer != nil {
263263
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
264264
defer cancel()
265-
s.httpServer.Shutdown(ctx)
265+
_ = s.httpServer.Shutdown(ctx)
266266
}
267267

268268
if s.proxyCmd != nil && s.proxyCmd.Process != nil {
@@ -332,7 +332,7 @@ func (s *ProxyFaultInjectorServer) handleListActions(w http.ResponseWriter, r *h
332332
}
333333

334334
w.Header().Set("Content-Type", "application/json")
335-
json.NewEncoder(w).Encode(actions)
335+
_ = json.NewEncoder(w).Encode(actions)
336336
}
337337

338338
func (s *ProxyFaultInjectorServer) handleTriggerAction(w http.ResponseWriter, r *http.Request) {
@@ -377,7 +377,7 @@ func (s *ProxyFaultInjectorServer) handleTriggerAction(w http.ResponseWriter, r
377377
}
378378

379379
w.Header().Set("Content-Type", "application/json")
380-
json.NewEncoder(w).Encode(resp)
380+
_ = json.NewEncoder(w).Encode(resp)
381381
}
382382

383383
func (s *ProxyFaultInjectorServer) handleActionStatus(w http.ResponseWriter, r *http.Request) {
@@ -411,7 +411,7 @@ func (s *ProxyFaultInjectorServer) handleActionStatus(w http.ResponseWriter, r *
411411
}
412412

413413
w.Header().Set("Content-Type", "application/json")
414-
json.NewEncoder(w).Encode(resp)
414+
_ = json.NewEncoder(w).Encode(resp)
415415
}
416416

417417
// executeAction executes an action and injects appropriate notifications

0 commit comments

Comments
 (0)