Packing project content fails if there are UNIX domain sockets
If there's any stray UNIX domain sockets in the project directory, Spread fails to pack the project.
To reproduce this issue, create a socket (you can Ctrl+C the command as soon as it's started, we just want the side effect of creating a socket):
nc -lkU foo.sock
With this in place, trying to run spread fails (example project has a LXD backend, but this issue is most likely independent of backend):
spread -vv lxd
The error message:
2024-02-05 15:15:39 Error packing project content for delivery: cannot pack project tree: tar: foo.sock: socket ignored
As a workaround, we currently run find . -type s -delete before running spread to remove any UNIX domain sockets.
GNU tar supports configurable warning messages using --warning= with:
file‐ignored
"%s: Unknown file type; file ignored"
"%s: socket ignored"
"%s: door ignored"
The file-ignored warning ignores:
- Unknown file types (see calls to
unknown_file_error()insrc/create.cin tar's source) - UNIX domain sockets
- Doors, a Solaris-specific concept
It seems like one could add --warning=no-file-ignored to work around this issue:
diff --git a/spread/runner.go b/spread/runner.go
index c84ff63..ebf4b00 100644
--- a/spread/runner.go
+++ b/spread/runner.go
@@ -277,7 +277,7 @@ func (r *Runner) prepareContent() (err error) {
return fmt.Errorf("cannot remove temporary content file: %v", err)
}
- args := []string{"c", "--exclude=.spread-reuse.*"}
+ args := []string{"c", "--exclude=.spread-reuse.*", "--warning=no-file-ignored"}
if r.project.Repack == "" {
args[0] = "cz"
}
In my local tests, this fixed the issue and lets spread pack the local tree, ignoring any UNIX domain sockets.
@thp-canonical you could use the exclude config in spread.yaml to exclude any unwanted files (if their pattern is knowm), please check https://github.com/snapcore/spread/blob/master/README.md#including.
@thp-canonical you could use the exclude config in spread.yaml to exclude any unwanted files (if their pattern is know), please check https://github.com/snapcore/spread/blob/master/README.md#including.
cc @paul-rodriguez would that work for you?