From cbaec4d61454f7426d14b44bf25c67282251453c Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Thu, 20 Sep 2018 14:36:38 -0700 Subject: Wait for all async fs operations to complete before returning from Destroy. Destroy flushes dirent references, which triggers many async close operations. We must wait for those to finish before returning from Destroy, otherwise we may kill the gofer, causing a cascade of failing RPCs and leading to an inconsistent FS state. PiperOrigin-RevId: 213884637 Change-Id: Id054b47fc0f97adc5e596d747c08d3b97a1d1f71 --- runsc/boot/controller.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'runsc') diff --git a/runsc/boot/controller.go b/runsc/boot/controller.go index ddba117c6..7d7803e92 100644 --- a/runsc/boot/controller.go +++ b/runsc/boot/controller.go @@ -315,6 +315,13 @@ func (cm *containerManager) Destroy(cid *string, _ *struct{}) error { return fmt.Errorf("error removing directory %q: %v", containerRoot, err) } + // Flushing dirent references triggers many async close operations. We + // must wait for those to complete before returning, otherwise the + // caller may kill the gofer before they complete, causing a cascade of + // failing RPCs. + log.Infof("Waiting for async filesystem operations to complete") + fs.AsyncBarrier() + // We made it! log.Debugf("Destroyed container %q", *cid) return nil -- cgit v1.2.3