Skip to content

Commit 8e67060

Browse files
remove nakedreturn check, handle orphan tenants
Signed-off-by: Kristof Gyuracz <[email protected]>
1 parent ccf519c commit 8e67060

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

.golangci.yml

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ linters:
3131
- ineffassign
3232
- lll
3333
- misspell
34-
- nakedret
3534
- prealloc
3635
- staticcheck
3736
- typecheck

internal/controller/telemetry/collector_controller.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -347,20 +347,19 @@ func (r *CollectorReconciler) SetupWithManager(mgr ctrl.Manager) error {
347347

348348
TenantLoop:
349349
for _, tenant := range tenants.Items {
350+
if tenant.Status.Collector == "" {
351+
logger.Error(errors.WithStack(err), fmt.Sprintf("tenant %s is orphan, skipping it, and its subscriptions when looking for changes", tenant.Name))
352+
}
350353
subscriptionsForTenant, subscriptionsToUpdate, err := r.getSubscriptionsForTenant(ctx, &tenant)
351354
if err != nil {
352355
logger.Error(errors.WithStack(err), "failed listing subscriptions for collector, notifying collector anyways")
353-
if tenant.Status.Collector != "" {
354-
requests = addCollectorRequest(requests, tenant.Status.Collector)
355-
}
356+
requests = addCollectorRequest(requests, tenant.Status.Collector)
356357
continue TenantLoop
357358
}
358359

359360
for _, s := range append(subscriptionsForTenant, subscriptionsToUpdate...) {
360361
if s.Name == subscription.Name {
361-
if tenant.Status.Collector != "" {
362-
requests = addCollectorRequest(requests, tenant.Status.Collector)
363-
}
362+
requests = addCollectorRequest(requests, tenant.Status.Collector)
364363
continue TenantLoop
365364
}
366365
}
@@ -369,9 +368,7 @@ func (r *CollectorReconciler) SetupWithManager(mgr ctrl.Manager) error {
369368

370369
for _, s := range subscriptionsToDisown {
371370
if s.Name == subscription.Name {
372-
if tenant.Status.Collector != "" {
373-
requests = addCollectorRequest(requests, tenant.Status.Collector)
374-
}
371+
requests = addCollectorRequest(requests, tenant.Status.Collector)
375372
continue TenantLoop
376373
}
377374
}

0 commit comments

Comments
 (0)