Why is this an issue?
The CSI driver spawns a signal handler goroutine that calls d.Stop() but has no way to synchronize on completion. The goroutine exits after calling Stop with no wait for driver to fully shut down.
What is causing it?
In cmd/csi-driver/main.go:49-54:
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
d.Stop()
}()
When a signal is received:
- The goroutine calls
d.Stop()
- The goroutine exits immediately
- There's no synchronization to wait for
d.Stop() to complete
- The main process may exit before the driver fully stops
How can it be solved?
Add synchronization:
stopped := make(chan struct{})
go func() {
<-c
d.Stop()
close(stopped)
}()
// In Run(), check stopped or use context with timeout
select {
case <-stopped:
// Driver stopped gracefully
case <-time.After(shutdownTimeout):
// Force exit
}
Category
Severity
Why is this an issue?
The CSI driver spawns a signal handler goroutine that calls
d.Stop()but has no way to synchronize on completion. The goroutine exits after calling Stop with no wait for driver to fully shut down.What is causing it?
In
cmd/csi-driver/main.go:49-54:When a signal is received:
d.Stop()d.Stop()to completeHow can it be solved?
Add synchronization:
Category
Severity