Skip to content

Commit 5cda6ab

Browse files
authored
fix(disk-failure): allow bpftool probe in dry run (#1005)
Removes dry run early exit from bpftool executor since 'bpftool feature probe' is read-only and safe to execute. This allows proper eBPF capability validation even in dry run mode, preventing false failures when testing disk failure disruptions at node level. Jira: CHAOSPLT-1326
1 parent 87022df commit 5cda6ab

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

ebpf/executor.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ func (e defaultBpftoolExecutor) Run(args []string) (int, string, error) {
4444
// run command
4545
e.log.Debugf("running bpftool command: %v", cmd.String())
4646

47-
// early exit if dry-run mode is enabled
48-
if e.dryRun {
49-
return 0, "", nil
50-
}
51-
5247
err := cmd.Run()
5348
if err != nil {
5449
err = fmt.Errorf("encountered error (%w) using args (%s): %s", err, args, stderr.String())

injector/disk_failure_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,27 @@ var _ = Describe("Disk Failure", func() {
273273
})
274274
})
275275
})
276+
277+
Context("with dry run mode enabled", func() {
278+
BeforeEach(func() {
279+
config.Disruption.DryRun = true
280+
})
281+
282+
It("should validate eBPF capabilities and start successfully", func() {
283+
Expect(err).ShouldNot(HaveOccurred())
284+
285+
// Verify that validation still occurs in dry run mode since bpftool probe is read-only
286+
BPFConfigInformerMock.AssertCalled(GinkgoT(), "ValidateRequiredSystemConfig")
287+
BPFConfigInformerMock.AssertCalled(GinkgoT(), "GetMapTypes")
288+
289+
// Verify that the command was still created
290+
cmdFactoryMock.AssertCalled(GinkgoT(), "NewCmd", mock.Anything, EBPFDiskFailureCmd, []string{
291+
"-process", strconv.Itoa(0),
292+
"-path", "/",
293+
"-probability", "100",
294+
})
295+
})
296+
})
276297
})
277298
})
278299
})

0 commit comments

Comments
 (0)