Skip to content

volumemgr: build-tagged fault injection for volume delete - #6190

Draft
eriknordmark wants to merge 1 commit into
lf-edge:masterfrom
eriknordmark:fault-inject-volume-delete
Draft

volumemgr: build-tagged fault injection for volume delete#6190
eriknordmark wants to merge 1 commit into
lf-edge:masterfrom
eriknordmark:fault-inject-volume-delete

Conversation

@eriknordmark

@eriknordmark eriknordmark commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Description

Makes a volume destroy / PVC delete fail on demand so the volume-delete retry path (#6176) can be exercised end to end on a kubevirt/longhorn node — a scenario that is otherwise hard to arrange on a real cluster.

Two file-existence fault gates on the delete path, using the same marker idiom as kubeapi.DrainStatusFaultInjectionWait:

  • /tmp/VolumeDestroy_FaultInjection_Fail fails volumeHandlerCSI.DestroyVolume before the replicated-volume skip, so it drives the retry loop for replicated Longhorn volumes too.
  • /tmp/DeletePVC_FaultInjection_Fail fails kubeapi.DeletePVC on the non-replicated path.

Both are compiled in only under a new faultinjection build tag (FAULT_INJECTION=y); without it they resolve to no-op stubs returning false, so shipped images carry none of it. Wired through the linuxkit build-arg plumbing (top Makefile, pillar Makefile/Dockerfile).

This is test-only tooling that complements #6176; it is not required for the fix itself.

PR dependencies

None. Pairs with the companion eden e2e test (lf-edge/eden#1217), which consumes these markers.

How to test and validate this PR

Build an EVE-k image with the tag enabled:

make pkg/pillar HV=kubevirt FAULT_INJECTION=y   # or a full image build with FAULT_INJECTION=y

On a running kubevirt/longhorn EVE-k node, deploy an app with a volume and wait for the volume to reach the Created sub-state, then arm a fault and delete the app:

eve exec pillar touch /tmp/VolumeDestroy_FaultInjection_Fail

The volume destroy fails; with #6176 present the VolumeStatus stays published in the Deleting sub-state with an error and is re-driven off the gc tick. Removing the marker lets the next retry succeed and the volume is unpublished.

Automated: covered end to end by the companion eden suite (lf-edge/eden#1217). Validated on host EVE-k (master base): the retain→retry→recover and bounded give-up paths pass on an image built with this and #6176, and the recovery test fails on an image built with this but without #6176 — i.e. the test catches the pre-fix leak.

Without the faultinjection build tag the gates are no-op stubs, so a normal build is unaffected.

Changelog notes

No user-facing changes (test-only tooling, compiled out of shipped images).

PR Backports

Checklist

  • I've provided a proper description
  • I've added the proper documentation
  • I've tested my PR on amd64 device
  • I've tested my PR on arm64 device
  • I've written the test verification instructions
  • I've set the proper labels to this PR

🤖 Generated with Claude Code

Testing the delete-retry loop requires making a volume destroy fail on
demand and then recover, which is hard to arrange on a real
kubevirt/longhorn cluster. Add two file-existence fault-injection gates
on the delete path, using the same marker-file idiom as
kubeapi.DrainStatusFaultInjectionWait but compiled in only under a new
faultinjection build tag (FAULT_INJECTION=y), so production images never
carry them:

- VolumeDestroyFaultInjected gates volumeHandlerCSI.DestroyVolume before
  the replicated-volume skip, so it fails the destroy for any volume and
  drives volumemgr's retry loop directly.
- DeletePVCFaultInjected gates kubeapi.DeletePVC, reproducing a k8s
  PVC-delete failure on the non-replicated path.

Two separate markers let a test target a specific layer since which
operation fails in the field is not known in advance. Without the build
tag both gates resolve to a no-op returning false, so the fault branches
are dead code the compiler drops from the shipped binary.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 23.01%. Comparing base (e640d79) to head (58a60cb).

Files with missing lines Patch % Lines
pkg/pillar/kubeapi/vitoapiserver.go 0.00% 4 Missing ⚠️
pkg/pillar/volumehandlers/csihandler.go 0.00% 4 Missing ⚠️
...ar/kubeapi/faultinjection_volumedelete_disabled.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6190      +/-   ##
==========================================
+ Coverage   22.64%   23.01%   +0.37%     
==========================================
  Files         507      518      +11     
  Lines       93195    94921    +1726     
==========================================
+ Hits        21100    21848     +748     
- Misses      70369    71163     +794     
- Partials     1726     1910     +184     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant