Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions ebpf/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the effect of the dryRun when it injects? Why did we previously exit when it was in dryRun?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what's the effect of the dryRun when it injects?

FWIK The dry-run will only execute read-only commands and will not apply the injection for real.

Why did we previously exit when it was in dryRun?

It was a long time ago, so I don't remember exactly the why... However, pbftool is only used to verify if the kernel can support eBPF programs so it makes sense to execute the command in dry-run mode to ensure the node is ready to support the disruption.
Before the fix, when the disruption is in dry run mode, the run command returns an empty string and the unmarshal command returns an error.

return 0, "", nil
}

err := cmd.Run()
if err != nil {
err = fmt.Errorf("encountered error (%w) using args (%s): %s", err, args, stderr.String())
Expand Down
21 changes: 21 additions & 0 deletions injector/disk_failure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
})
})
})
})
})
Expand Down