Skip to content

Commit 0dbfe27

Browse files
committed
fix lints etc
1 parent e4dfadb commit 0dbfe27

File tree

7 files changed

+28
-35
lines changed

7 files changed

+28
-35
lines changed

pkg/components/kube/store.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,13 @@ func (s *Store) cacheResourceMetadata(meta *informer.ObjectMeta) *CachedObjMeta
197197
func (s *Store) On(event *informer.Event) error {
198198
switch event.Type {
199199
case informer.EventType_CREATED:
200-
// go func() {
201-
// time.Sleep(10 * time.Second)
202200
s.addObjectMeta(event.Resource)
203-
s.Notify(event)
204-
// }()
205201
case informer.EventType_UPDATED:
206202
s.updateObjectMeta(event.Resource)
207-
s.Notify(event)
208203
case informer.EventType_DELETED:
209204
s.deleteObjectMeta(event.Resource)
210-
s.Notify(event)
211205
}
212-
//s.Notify(event)
206+
s.Notify(event)
213207
return nil
214208
}
215209

pkg/components/kube/store_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ func TestStore_MultiPID_SameContainerAndNamespace(t *testing.T) {
721721
setupPIDs: []uint32{2001, 2002, 2003, 2004},
722722
containerID: "container456",
723723
pidNS: 6000,
724-
operations: func(t *testing.T, store *Store, pids []uint32) {
724+
operations: func(t *testing.T, store *Store, _ []uint32) {
725725
// Delete middle PID
726726
store.DeleteProcess(2002)
727727

@@ -775,13 +775,13 @@ func TestStore_MultiPID_SameContainerAndNamespace(t *testing.T) {
775775
// Verify namespace map is empty or doesn't exist
776776
nsMap, exists := store.namespaces[7000]
777777
if exists {
778-
assert.Len(t, nsMap, 0, "Namespace map should be empty")
778+
assert.Empty(t, nsMap, "Namespace map should be empty")
779779
}
780780

781781
// Verify container map is empty or doesn't exist
782782
cidMap, exists := store.containerIDs["container789"]
783783
if exists {
784-
assert.Len(t, cidMap, 0, "Container map should be empty")
784+
assert.Empty(t, cidMap, "Container map should be empty")
785785
}
786786

787787
// Verify containerByPID has no entries for these PIDs
@@ -797,7 +797,7 @@ func TestStore_MultiPID_SameContainerAndNamespace(t *testing.T) {
797797
setupPIDs: []uint32{}, // Start empty
798798
containerID: "container999",
799799
pidNS: 8000,
800-
operations: func(t *testing.T, store *Store, pids []uint32) {
800+
operations: func(t *testing.T, store *Store, _ []uint32) {
801801
// Add PIDs one by one
802802
testPIDs := []uint32{4001, 4002, 4003, 4004, 4005}
803803

@@ -833,7 +833,7 @@ func TestStore_MultiPID_SameContainerAndNamespace(t *testing.T) {
833833
setupPIDs: []uint32{5001, 5002},
834834
containerID: "container111",
835835
pidNS: 9000,
836-
operations: func(t *testing.T, store *Store, pids []uint32) {
836+
operations: func(t *testing.T, store *Store, _ []uint32) {
837837
// Initial state: 2 PIDs
838838
store.access.RLock()
839839
nsMap, exists := store.namespaces[9000]
@@ -1018,13 +1018,13 @@ func TestStore_MultiPID_CrossContainerScenarios(t *testing.T) {
10181018
// Namespace 2000 should be empty or non-existent
10191019
nsMap2000, exists := store.namespaces[2000]
10201020
if exists {
1021-
assert.Len(t, nsMap2000, 0, "Namespace 2000 should be empty")
1021+
assert.Empty(t, nsMap2000, "Namespace 2000 should be empty")
10221022
}
10231023

10241024
// Container2 map should be empty or non-existent
10251025
cont2Map, exists := store.containerIDs["cont2"]
10261026
if exists {
1027-
assert.Len(t, cont2Map, 0, "Container2 map should be empty")
1027+
assert.Empty(t, cont2Map, "Container2 map should be empty")
10281028
}
10291029

10301030
// Other containers should be unaffected
@@ -1124,7 +1124,7 @@ func TestStore_MultiPID_ConcurrentAccess(t *testing.T) {
11241124
containerID := "concurrent-container"
11251125
pidNS := uint32(9999)
11261126

1127-
InfoForPID = func(pid uint32) (container.Info, error) {
1127+
InfoForPID = func(uint32) (container.Info, error) {
11281128
return container.Info{
11291129
ContainerID: containerID,
11301130
PIDNamespace: pidNS,
@@ -1175,7 +1175,7 @@ func TestStore_MultiPID_ConcurrentAccess(t *testing.T) {
11751175
cidMap, cidExists := store.containerIDs[containerID]
11761176
assert.Equal(t, cidExists, exists, "Both maps should have same existence state")
11771177
if cidExists {
1178-
assert.Equal(t, len(nsMap), len(cidMap), "Both maps should have same number of PIDs")
1178+
assert.Len(t, nsMap, len(cidMap), "Both maps should have same number of PIDs")
11791179

11801180
// Verify consistency between maps
11811181
for pid, nsInfo := range nsMap {

pkg/export/otel/metrics_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"github.com/stretchr/testify/assert"
2020
"github.com/stretchr/testify/require"
2121

22+
"go.opentelemetry.io/otel/attribute"
23+
2224
"go.opentelemetry.io/obi/pkg/app/request"
2325
"go.opentelemetry.io/obi/pkg/components/exec"
2426
"go.opentelemetry.io/obi/pkg/components/imetrics"
@@ -30,7 +32,6 @@ import (
3032
"go.opentelemetry.io/obi/pkg/export/otel/otelcfg"
3133
"go.opentelemetry.io/obi/pkg/pipe/msg"
3234
"go.opentelemetry.io/obi/test/collector"
33-
"go.opentelemetry.io/otel/attribute"
3435
)
3536

3637
var fakeMux = sync.Mutex{}

pkg/export/prom/prom_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ func TestHandleProcessEventCreated(t *testing.T) {
746746
}{
747747
{
748748
name: "new service - fresh start",
749-
setup: func(r *metricsReporter, m *mockEventMetrics) {
749+
setup: func(*metricsReporter, *mockEventMetrics) {
750750
// No setup needed for fresh start
751751
},
752752
event: exec.ProcessEvent{
@@ -791,7 +791,7 @@ func TestHandleProcessEventCreated(t *testing.T) {
791791
},
792792
{
793793
name: "same service UID with updated attributes",
794-
setup: func(r *metricsReporter, m *mockEventMetrics) {
794+
setup: func(r *metricsReporter, _ *mockEventMetrics) {
795795
// Pre-populate service map with existing service
796796
uid := svc.UID{
797797
Name: "test-service",
@@ -854,7 +854,7 @@ func TestHandleProcessEventCreated(t *testing.T) {
854854
},
855855
{
856856
name: "PID changing service (stale UID with existing attributes)",
857-
setup: func(r *metricsReporter, m *mockEventMetrics) {
857+
setup: func(r *metricsReporter, _ *mockEventMetrics) {
858858
// Setup: PID 1234 is already tracked with stale UID
859859
staleUID := svc.UID{
860860
Name: "old-service",
@@ -920,7 +920,7 @@ func TestHandleProcessEventCreated(t *testing.T) {
920920
},
921921
{
922922
name: "PID changing service (stale UID without existing attributes)",
923-
setup: func(r *metricsReporter, m *mockEventMetrics) {
923+
setup: func(r *metricsReporter, _ *mockEventMetrics) {
924924
// Setup: PID 1234 is already tracked with stale UID, but no service map entry
925925
staleUID := svc.UID{
926926
Name: "old-service",

pkg/transform/k8s.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ import (
2525
"go.opentelemetry.io/obi/pkg/pipe/swarm"
2626
)
2727

28-
var (
29-
containerInfoForPID = container.InfoForPID
30-
)
28+
var containerInfoForPID = container.InfoForPID
3129

3230
func klog() *slog.Logger {
3331
return slog.With("component", "transform.KubernetesDecorator")

pkg/transform/k8s_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,9 @@ func TestDecorationProcessEvents(t *testing.T) {
384384
// When we send 34 we first get naked PID info, the kubernetes metadata was delayed
385385
inputQueue.Send(exec.ProcessEvent{File: &exec.FileInfo{Pid: 34, Ns: 1034, Service: autoNameSvc}, Type: exec.ProcessEventCreated})
386386
deco := testutil.ReadChannel(t, outputCh, timeout)
387-
assert.Equal(t, "", deco.File.Service.UID.Namespace)
388-
assert.Equal(t, "", deco.File.Service.UID.Name)
389-
assert.Equal(t, "", deco.File.Service.UID.Instance)
387+
assert.Empty(t, deco.File.Service.UID.Namespace)
388+
assert.Empty(t, deco.File.Service.UID.Name)
389+
assert.Empty(t, deco.File.Service.UID.Instance)
390390
assert.Empty(t, deco.File.Service.Metadata)
391391

392392
// we now notify on new informer
@@ -403,7 +403,7 @@ func TestDecorationProcessEvents(t *testing.T) {
403403

404404
// After we got new information, there's no need to send the event again, it's
405405
// automatically going to generate a process event with the updated info
406-
//inputQueue.Send(exec.ProcessEvent{File: &exec.FileInfo{Pid: 34, Ns: 1034, Service: autoNameSvc}, Type: exec.ProcessEventCreated})
406+
// inputQueue.Send(exec.ProcessEvent{File: &exec.FileInfo{Pid: 34, Ns: 1034, Service: autoNameSvc}, Type: exec.ProcessEventCreated})
407407
deco = testutil.ReadChannel(t, outputCh, timeout)
408408
assert.Equal(t, "the-ns", deco.File.Service.UID.Namespace)
409409
assert.Equal(t, "rs", deco.File.Service.UID.Name)
@@ -438,18 +438,18 @@ func TestDecorationProcessEvents(t *testing.T) {
438438
for i := 0; i < 4; i++ {
439439
deco := testutil.ReadChannel(t, outputCh, timeout)
440440
assert.Equal(t, exec.ProcessEventCreated, deco.Type)
441-
assert.Equal(t, "", deco.File.Service.UID.Namespace)
442-
assert.Equal(t, "", deco.File.Service.UID.Name)
443-
assert.Equal(t, "", deco.File.Service.UID.Instance)
441+
assert.Empty(t, deco.File.Service.UID.Namespace)
442+
assert.Empty(t, deco.File.Service.UID.Name)
443+
assert.Empty(t, deco.File.Service.UID.Instance)
444444
assert.Empty(t, deco.File.Service.Metadata)
445445
}
446446

447447
for i := 0; i < 2; i++ {
448448
deco := testutil.ReadChannel(t, outputCh, timeout)
449449
assert.Equal(t, exec.ProcessEventTerminated, deco.Type)
450-
assert.Equal(t, "", deco.File.Service.UID.Namespace)
451-
assert.Equal(t, "", deco.File.Service.UID.Name)
452-
assert.Equal(t, "", deco.File.Service.UID.Instance)
450+
assert.Empty(t, deco.File.Service.UID.Namespace)
451+
assert.Empty(t, deco.File.Service.UID.Name)
452+
assert.Empty(t, deco.File.Service.UID.Instance)
453453
assert.Empty(t, deco.File.Service.Metadata)
454454
}
455455

pkg/transform/pid_container_tracker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ func TestPidContainerTracker_Info(t *testing.T) {
413413
}
414414
}
415415

416-
func TestPidContainerTracker_ConcurrentAccess(t *testing.T) {
416+
func TestPidContainerTracker_ConcurrentAccess(*testing.T) {
417417
tracker := &pidContainerTracker{
418418
missedPods: maps2.Map2[string, int32, *exec.ProcessEvent]{},
419419
missedPodPids: make(map[int32]string),

0 commit comments

Comments
 (0)