Skip to content

Commit d5b770a

Browse files
Introduce 'clean-test' target in Makefile
When tests fail they could leave debris behind such as - overlay mounts - cgroups - metadata These debris can cause subsequent tests to fail Co-authored-by: Danail Branekov <[email protected]> Signed-off-by: Georgi Sabev <[email protected]>
1 parent 591e52c commit d5b770a

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,20 @@ clean: ## clean up binaries
231231
@echo "$(WHALE) $@"
232232
@rm -f $(BINARIES)
233233

234+
clean-test: ## clean up debris from previously failed tests
235+
@echo "$(WHALE) $@"
236+
$(eval containers=$(shell find /run/containerd/runc -mindepth 2 -maxdepth 3 -type d -exec basename {} \;))
237+
$(shell pidof containerd containerd-shim runc | xargs -r -n 1 kill -9)
238+
@( for container in $(containers); do \
239+
grep $$container /proc/self/mountinfo | while read -r mountpoint; do \
240+
umount $$(echo $$mountpoint | awk '{print $$5}'); \
241+
done; \
242+
find /sys/fs/cgroup -name $$container -print0 | xargs -r -0 rmdir; \
243+
done )
244+
@rm -rf /run/containerd/runc/*
245+
@rm -rf /run/containerd/fifo/*
246+
@rm -rf /run/containerd-test/*
247+
234248
install: ## install binaries
235249
@echo "$(WHALE) $@ $(BINARIES)"
236250
@mkdir -p $(DESTDIR)/bin

0 commit comments

Comments
 (0)