diff --git a/ebpf/executor.go b/ebpf/executor.go index 3fa3230583..aeb66c8ac0 100644 --- a/ebpf/executor.go +++ b/ebpf/executor.go @@ -44,11 +44,6 @@ func (e defaultBpftoolExecutor) Run(args []string) (int, string, error) { // run command e.log.Debugf("running bpftool command: %v", cmd.String()) - // early exit if dry-run mode is enabled - if e.dryRun { - return 0, "", nil - } - err := cmd.Run() if err != nil { err = fmt.Errorf("encountered error (%w) using args (%s): %s", err, args, stderr.String()) diff --git a/injector/disk_failure_test.go b/injector/disk_failure_test.go index c21c4c22fc..ab8b44c1d9 100644 --- a/injector/disk_failure_test.go +++ b/injector/disk_failure_test.go @@ -273,6 +273,27 @@ var _ = Describe("Disk Failure", func() { }) }) }) + + Context("with dry run mode enabled", func() { + BeforeEach(func() { + config.Disruption.DryRun = true + }) + + It("should validate eBPF capabilities and start successfully", func() { + Expect(err).ShouldNot(HaveOccurred()) + + // Verify that validation still occurs in dry run mode since bpftool probe is read-only + BPFConfigInformerMock.AssertCalled(GinkgoT(), "ValidateRequiredSystemConfig") + BPFConfigInformerMock.AssertCalled(GinkgoT(), "GetMapTypes") + + // Verify that the command was still created + cmdFactoryMock.AssertCalled(GinkgoT(), "NewCmd", mock.Anything, EBPFDiskFailureCmd, []string{ + "-process", strconv.Itoa(0), + "-path", "/", + "-probability", "100", + }) + }) + }) }) }) })