Skip to content

Conversation

@FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Oct 29, 2025

Description

Fixed error case on test panic: in case a panic happens during a test, we will never receive a "fail" TestEvent line (as expected by our test2json lines parser).
In that case, force-add the test and set it to a failed one.

Example issue:

❌ pkg.sensors.tracing.TestKprobeResolveCurrent (total:0 failed:0 skipped:0) 1.774065037s 17m21.119654417s

https://github.com/cilium/tetragon/actions/runs/18845325147/job/53768769897, as you can see, CI is green even if there's a failing test. Also,

(total:0 failed:0 skipped:0)

Finally, while at it, throw together the patch to fix the failing test on 5.4-20251027.

Changelog

fix(pkg/btf): fix FindBTFStruct to return first found btf type in case of multiple matches

@FedeDP FedeDP force-pushed the fix/vmtests_fails branch 2 times, most recently from 343cca5 to 985c622 Compare October 29, 2025 13:14
@FedeDP FedeDP changed the title wip fix(cmd/tetragon-vmtests-run): fixed error case on test panic Oct 29, 2025
@FedeDP FedeDP force-pushed the fix/vmtests_fails branch from d5abdd7 to 5654bad Compare October 29, 2025 14:15
if nrTests == 0 && res.Error {
nrTests++
nrFailedTests++
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so tbh I don't understand at first glance how the whole thing is written, does it needs to be fixed in updateResultsSimple?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a test panic, there is no line in the JSON output whatsoever?

Copy link
Contributor Author

@FedeDP FedeDP Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are multiple Action: output lines, eg (taken from an old run of vmtests on this PR with some additional debug prints: https://github.com/cilium/tetragon/actions/runs/18905824358/job/53964670215)

pkg.sensors.tracing.TestKprobeResolveCurrent: {"Time":"2025-10-29T11:47:38.388342441Z","Action":"start"}
2025-10-29T11:47:44.1088571Z {"Time":"2025-10-29T11:47:38.388424214Z","Action":"output","Output":"level=info msg=\"BTF discovery: default kernel btf file found\" btf-file=/sys/kernel/btf/vmlinux\n"}
{"Time":"2025-10-29T11:47:38.3884434Z","Action":"run","Test":"TestKprobeResolveCurrent"}
{"Time":"2025-10-29T11:47:38.388447467Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"=== RUN   TestKprobeResolveCurrent\n"}
{"Time":"2025-10-29T11:47:38.388451555Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"level=info msg=\"Exit probe on acct_process\"\n"}
{"Time":"2025-10-29T11:47:38.388454952Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"level=info msg=\"Set execve_map entries 32768\" size=28M\n"}
{"Time":"2025-10-29T11:47:38.388458438Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:10.894Z level=INFO msg=\"BTF discovery: default kernel btf file found\" btf-file=/sys/kernel/btf/vmlinux\n"}
{"Time":"2025-10-29T11:47:38.388462145Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:10.899Z level=INFO msg=\"Creating new EventCache\" retries=15 delay=2s\n"}
{"Time":"2025-10-29T11:47:38.388466132Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:10.899Z level=INFO msg=\"Starting process manager\" enableK8s=false enableProcessCred=true enableProcessNs=true\n"}
{"Time":"2025-10-29T11:47:38.388471292Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:10.899Z level=INFO msg=\"Starting JSON exporter\"\n"}
{"Time":"2025-10-29T11:47:38.38847578Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:10.901Z level=INFO msg=\"Cgroup rate disabled (0/0s)\"\n"}
{"Time":"2025-10-29T11:47:38.388479948Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:10.907Z level=INFO msg=\"BTF file: using metadata file\" metadata=/sys/kernel/btf/vmlinux\n"}
{"Time":"2025-10-29T11:47:38.388485729Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:10.908Z level=INFO msg=\"Loading sensor\" name=__base__\n"}
{"Time":"2025-10-29T11:47:38.388489857Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:10.908Z level=INFO msg=\"Loading kernel version 5.4.300\"\n"}
{"Time":"2025-10-29T11:47:38.388498463Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:11.181Z level=ERROR msg=\"detect link pin\" error=\"perf event ioctl pin: not supported\"\n"}
{"Time":"2025-10-29T11:47:38.388502821Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:11.837Z level=INFO msg=\"Loaded sensor successfully\" sensor=__base__\n"}
{"Time":"2025-10-29T11:47:38.388506949Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:11.863Z level=INFO msg=\"Read ProcFS /proc appended 254/311 entries\"\n"}
{"Time":"2025-10-29T11:47:38.388511317Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:11.867Z level=INFO msg=\"Kernel does not support time namespaces\" error=\"namespace '/proc/1/ns/time' readlink /proc/1/ns/time: no such file or directory\"\n"}
{"Time":"2025-10-29T11:47:38.388518791Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:11.868Z level=INFO msg=\"Kernel does not support time_for_children namespaces\" error=\"namespace '/proc/1/ns/time_for_children' readlink /proc/1/ns/time_for_children: no such file or directory\"\n"}
{"Time":"2025-10-29T11:47:38.38852348Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:11.967Z level=INFO msg=\"Unloading sensor __base__\"\n"}
{"Time":"2025-10-29T11:47:38.388551081Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    filenames.go:49: keeping export file for TestKprobeResolveCurrent (/tmp/tetragon.gotest.TestKprobeResolveCurrent.33323489.json)\n"}
{"Time":"2025-10-29T11:47:38.388556651Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:12.022Z level=INFO msg=\"Sensor unloaded\" sensor=__base__ maps-error=[]\n"}
{"Time":"2025-10-29T11:47:38.388561491Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    base.go:198: cleanup: unloading base sensor\n"}
{"Time":"2025-10-29T11:47:38.388565438Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"level=info msg=\"Unloading sensor __base__\"\n"}
{"Time":"2025-10-29T11:47:38.388571599Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"--- FAIL: TestKprobeResolveCurrent (1.18s)\n"}
{"Time":"2025-10-29T11:47:38.388579404Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]\n"}
{"Time":"2025-10-29T11:47:38.388583822Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1242ec5]\n"}
{"Time":"2025-10-29T11:47:38.38858776Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\n"}
{"Time":"2025-10-29T11:47:38.388591316Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"goroutine 35 [running]:\n"}
{"Time":"2025-10-29T11:47:38.388594923Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"testing.tRunner.func1.2({0x214d320, 0x3c19b80})\n"}
{"Time":"2025-10-29T11:47:38.38859856Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/opt/hostedtoolcache/go/1.25.3/x64/src/testing/testing.go:1872 +0x237\n"}
{"Time":"2025-10-29T11:47:38.388602236Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"testing.tRunner.func1()\n"}
{"Time":"2025-10-29T11:47:38.388605873Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/opt/hostedtoolcache/go/1.25.3/x64/src/testing/testing.go:1875 +0x35b\n"}
{"Time":"2025-10-29T11:47:38.388609741Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"panic({0x214d320?, 0x3c19b80?})\n"}
{"Time":"2025-10-29T11:47:38.388613287Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/opt/hostedtoolcache/go/1.25.3/x64/src/runtime/panic.go:783 +0x132\n"}
{"Time":"2025-10-29T11:47:38.388617184Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/btf.ResolveBTFPath(0x28a1f00?, {0x28a1f00?, 0x0?}, {0xc000fec980, 0x1, 0x3c3bb40?}, 0x0)\n"}
{"Time":"2025-10-29T11:47:38.388621483Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/btf/btf.go:187 +0x1c5\n"}
{"Time":"2025-10-29T11:47:38.38862539Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/sensors/tracing.resolveBTFPath(...)\n"}
{"Time":"2025-10-29T11:47:38.388629227Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/sensors/tracing/generic.go:96\n"}
{"Time":"2025-10-29T11:47:38.388633445Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/sensors/tracing.resolveBTFType(0xc000d7f240, {0x28a1f00, 0x0})\n"}
{"Time":"2025-10-29T11:47:38.388637553Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/sensors/tracing/generic.go:44 +0x1fc\n"}
{"Time":"2025-10-29T11:47:38.38864175Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/sensors/tracing.resolveBTFArg({0xc0007b5920?, 0x0?}, 0xc000d7f240, 0xe6?)\n"}
{"Time":"2025-10-29T11:47:38.388645858Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/sensors/tracing/generic.go:92 +0x17a\n"}
{"Time":"2025-10-29T11:47:38.388650066Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/sensors/tracing.addKprobe.func2(0x1, 0xc000d7f240, 0x1)\n"}
{"Time":"2025-10-29T11:47:38.388654073Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/sensors/tracing/generickprobe.go:799 +0x16b\n"}
{"Time":"2025-10-29T11:47:38.388658171Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/sensors/tracing.addKprobe({0xc0007b5920, 0x1a}, 0x0, 0x1a?, 0xc000d7f600)\n"}
{"Time":"2025-10-29T11:47:38.38866295Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/sensors/tracing/generickprobe.go:874 +0xa3c\n"}
{"Time":"2025-10-29T11:47:38.38867356Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/sensors/tracing.createGenericKprobeSensor(0xc00014fd28, {0x24c81ff, 0xe}, 0xc0003e07d0, {0xc001d14008, 0x1, 0x1?})\n"}
{"Time":"2025-10-29T11:47:38.388678158Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/sensors/tracing/generickprobe.go:668 +0x8ea\n"}
{"Time":"2025-10-29T11:47:38.388682316Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/sensors/tracing.policyHandler.PolicyHandler({}, {0x28a1e40, 0xc00014fc20}, 0x0)\n"}
{"Time":"2025-10-29T11:47:38.388686384Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/sensors/tracing/policyhandler_linux.go:149 +0x3f4\n"}
{"Time":"2025-10-29T11:47:38.388690672Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/sensors.sensorsFromPolicyHandlers({0x28a1e40, 0xc00014fc20}, 0x0)\n"}
{"Time":"2025-10-29T11:47:38.38869487Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/sensors/handler.go:433 +0x109\n"}
{"Time":"2025-10-29T11:47:38.388698917Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/sensors.(*handler).addTracingPolicy(0xc000518580, 0xc001ebfb60)\n"}
{"Time":"2025-10-29T11:47:38.388703336Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/sensors/handler.go:146 +0x34f\n"}
{"Time":"2025-10-29T11:47:38.388707573Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/sensors.(*Manager).AddTracingPolicy(0xc00007ae08, {0x28b6698, 0xc0002c1b90}, {0x28a1e40, 0xc00014fc20})\n"}
{"Time":"2025-10-29T11:47:38.388717311Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/sensors/manager.go:134 +0x110\n"}
{"Time":"2025-10-29T11:47:38.388722191Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/observer/observertesthelper.loadObserver({0x28d6a50, 0xc00025ec40}, {0x28b6698, 0xc0002c1b90}, 0xc00053ce60, {0x28a1e40, 0xc00014fc20})\n"}
{"Time":"2025-10-29T11:47:38.388726579Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/observer/observertesthelper/observer_test_helper.go:433 +0x165\n"}
{"Time":"2025-10-29T11:47:38.388734474Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/observer/observertesthelper.getDefaultObserver({0x28d6a50, 0xc00025ec40}, {0x28b6698, 0xc0002c1b90}, 0xc00053ce60, {0xc000c3bd58, 0x2, 0x4})\n"}
{"Time":"2025-10-29T11:47:38.388739252Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/observer/observertesthelper/observer_test_helper.go:218 +0x25c\n"}
{"Time":"2025-10-29T11:47:38.388754802Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/observer/observertesthelper.GetDefaultObserverWithWatchers(...)\n"}
{"Time":"2025-10-29T11:47:38.388761925Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/observer/observertesthelper/observer_test_helper.go:257\n"}
{"Time":"2025-10-29T11:47:38.388766874Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/observer/observertesthelper.GetDefaultObserverWithFile({0x28d6a50, 0xc00025ec40}, {0x28b6698, 0xc0002c1b90}, {0x24e563e, 0x19}, {0xc0002385a0, 0x4e}, {0x0, 0x0, ...})\n"}
{"Time":"2025-10-29T11:47:38.388771493Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/observer/observertesthelper/observer_test_helper.go:272 +0x259\n"}
{"Time":"2025-10-29T11:47:38.388775681Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"github.com/cilium/tetragon/pkg/sensors/tracing.TestKprobeResolveCurrent(0xc00025ec40)\n"}
{"Time":"2025-10-29T11:47:38.388782714Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/home/runner/work/tetragon/tetragon/go/src/github.com/cilium/tetragon/pkg/sensors/tracing/kprobe_test.go:6992 +0x31a\n"}
{"Time":"2025-10-29T11:47:38.388787042Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"testing.tRunner(0xc00025ec40, 0x2617ed0)\n"}
{"Time":"2025-10-29T11:47:38.388793033Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/opt/hostedtoolcache/go/1.25.3/x64/src/testing/testing.go:1934 +0xea\n"}
{"Time":"2025-10-29T11:47:38.38879693Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"created by testing.(*T).Run in goroutine 1\n"}
{"Time":"2025-10-29T11:47:38.388801259Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/opt/hostedtoolcache/go/1.25.3/x64/src/testing/testing.go:1997 +0x465\n"}

but no "Action: fail" or "pass". Therefore we skip all of them and are not able to set the test as either passed or failed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok cool I see, could you put those explanations in the commit description (you can abbreviate the JSON if you want of course)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think we can merge like this don't bother to re update that but for next time that would have been cool to add the panic parts in the example logs. And please try to systematically wrap the commit description, except for output it can be okay, usually commit descriptions look like this for example https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f41345f47fb2 or 1bd8eae so that we can read it reasonably with git log.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis

	pkg.sensors.tracing.TestKprobeResolveCurrent: {"Time":"2025-10-29T11:47:38.388342441Z","Action":"start"}
	2025-10-29T11:47:44.1088571Z {"Time":"2025-10-29T11:47:38.388424214Z","Action":"output","Output":"level=info msg=\"BTF discovery: default kernel btf file found\" btf-file=/sys/kernel/btf/vmlinux\n"}
	{"Time":"2025-10-29T11:47:38.3884434Z","Action":"run","Test":"TestKprobeResolveCurrent"}
	{"Time":"2025-10-29T11:47:38.388447467Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"=== RUN   TestKprobeResolveCurrent\n"}
	{"Time":"2025-10-29T11:47:38.388571599Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"--- FAIL: TestKprobeResolveCurrent (1.18s)\n"}
	[...]
	{"Time":"2025-10-29T11:47:38.388579404Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]\n"}
	{"Time":"2025-10-29T11:47:38.388583822Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1242ec5]\n"}
	{"Time":"2025-10-29T11:47:38.38858776Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\n"}
	{"Time":"2025-10-29T11:47:38.388591316Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"goroutine 35 [running]:\n"}
	[...]
	{"Time":"2025-10-29T11:47:38.38879693Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"created by testing.(*T).Run in goroutine 1\n"}
	{"Time":"2025-10-29T11:47:38.388801259Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"\t/opt/hostedtoolcache/go/1.25.3/x64/src/testing/testing.go:1997 +0x465\n"}

nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

Anyway thanks for doing this :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestions, i'll make sure to implement them next times :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since i had to re-push, i implemented the requested changes.

@kkourt kkourt added the needs-backport/1.6 This PR needs backporting to v1.6 label Oct 29, 2025
@kkourt
Copy link
Contributor

kkourt commented Oct 29, 2025

I think we are going to need to backport this to 1.6. Not sure about previous versions though.

@FedeDP FedeDP marked this pull request as ready for review October 29, 2025 14:55
@FedeDP FedeDP requested a review from a team as a code owner October 29, 2025 14:55
@FedeDP FedeDP requested a review from tpapagian October 29, 2025 14:55
if hasCurrentTaskSource(arg) {
st, err := btf.FindBTFStruct("task_struct")
if err != nil && !errors.Is(err, ebtf.ErrMultipleMatches) {
if err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We manage ebtf.ErrMultipleMatches directly in FindBTFStruct. No need to manage it here too.

pkg/btf/btf.go Outdated
}

err = spec.TypeByName(name, &ty)
if err != nil && errors.Is(err, btf.ErrMultipleMatches) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of ErrMultipleMatches, we:

  • want to fetch all matches and return the first one
  • can be sure that all relevant checks made by spec.TypeByName passed fine, thus we can skip them here
  • we basically copy/paste part of spec.TypeByName to set ty to the first match

pkg/btf/btf.go Outdated
}
typPtr.Set(reflect.ValueOf(typ))
// reset err
err = nil
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reset the err so that we return a nil error since we were actually able to find a match (the first among N matches)

@FedeDP FedeDP force-pushed the fix/vmtests_fails branch from 5654bad to b29e145 Compare October 29, 2025 15:03
@mtardy mtardy added the release-note/ci This PR makes changes to the CI. label Oct 29, 2025
@FedeDP FedeDP force-pushed the fix/vmtests_fails branch from b29e145 to 322dd79 Compare October 29, 2025 16:50
Copy link
Contributor

@olsajiri olsajiri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh, thanks for find that! left one comment, otherwise looks good

@FedeDP FedeDP force-pushed the fix/vmtests_fails branch from 322dd79 to 54020fd Compare October 30, 2025 07:48
Copy link
Contributor

@kkourt kkourt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@olsajiri can you please merge when you are satisfied with the PR? Thanks!

pkg/btf/btf.go Outdated

err = spec.TypeByName(name, &ty)
if err != nil && errors.Is(err, btf.ErrMultipleMatches) {
logger.GetLogger().Warn("Multiple matches found in BTF spec; using first one", "struct", name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I thought I left a comment in here, but somehow I can't see it now..

could we put this in function, something like btf.FirstTypeByName ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :) i left the new helper unexposed for now, since we don't use it elsewhere.

@FedeDP FedeDP force-pushed the fix/vmtests_fails branch from 54020fd to 3bf3386 Compare October 30, 2025 12:52
pkg/btf/btf.go Outdated
if err != nil && errors.Is(err, btf.ErrMultipleMatches) {
logger.GetLogger().Warn("Multiple matches found in BTF spec; using first one", "struct", name)
// In case of multiple matches, fallback at using first available
err = firstTypeByName(spec, name, &ty)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we call it instead of spec.TypeByName ? IIUC like this we possibly do 2 searches

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg you are right!

In case a panic happens during a test, we will never receive a "fail"
`TestEvent` line.
In that case, force-add the test and set it to a failed one.

Example output json:

	{"Time":"2025-10-29T11:47:38.38852348Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:11.967Z level=INFO msg=\"Unloading sensor __base__\"\n"}
	{"Time":"2025-10-29T11:47:38.388551081Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    filenames.go:49: keeping export file for TestKprobeResolveCurrent (/tmp/tetragon.gotest.TestKprobeResolveCurrent.33323489.json)\n"}
	{"Time":"2025-10-29T11:47:38.388556651Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    logcapture.go:24: time=2025-10-29T11:43:12.022Z level=INFO msg=\"Sensor unloaded\" sensor=__base__ maps-error=[]\n"}
	{"Time":"2025-10-29T11:47:38.388561491Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"    base.go:198: cleanup: unloading base sensor\n"}
	{"Time":"2025-10-29T11:47:38.388565438Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"level=info msg=\"Unloading sensor __base__\"\n"}
	{"Time":"2025-10-29T11:47:38.388571599Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"--- FAIL: TestKprobeResolveCurrent (1.18s)\n"}
	{"Time":"2025-10-29T11:47:38.388579404Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]\n"}
	{"Time":"2025-10-29T11:47:38.388583822Z","Action":"output","Test":"TestKprobeResolveCurrent","Output":"[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1242ec5]\n"}

As you can see, we only receive `Action: output` lines,
but never receive the `fail` one since a panic is triggered during the test.
Therefore we skip all of them and are not able to mark the test as failed.

Signed-off-by: Federico Di Pierro <[email protected]>
In case of multiple matches, the code expects the first one found with correct type to be used.

Signed-off-by: Federico Di Pierro <[email protected]>
@FedeDP FedeDP force-pushed the fix/vmtests_fails branch from 3bf3386 to 5b55edf Compare October 31, 2025 07:29
@olsajiri olsajiri merged commit a467e2d into cilium:main Oct 31, 2025
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-backport/1.6 This PR needs backporting to v1.6 release-note/ci This PR makes changes to the CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants