fix: remove listening socket to fix Talos in a container restart

Fixes #4462

As `/system` volumes survives restarts in a container mode, we need to
make sure listening file socket is removed before creating a listener.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
This commit is contained in:
Andrey Smirnov 2021-10-28 18:59:40 +03:00
parent 53bbb13ed8
commit f6110f8036
No known key found for this signature in database
GPG Key ID: 7B26396447AB6DFD

View File

@ -72,6 +72,11 @@ func (o *APID) PreFunc(ctx context.Context, r runtime.Runtime) error {
return err
}
// clean up the socket if it already exists (important for Talos in a container)
if err := os.RemoveAll(constants.APIRuntimeSocketPath); err != nil {
return err
}
listener, err := net.Listen("unix", constants.APIRuntimeSocketPath)
if err != nil {
return err