lxc-to-incus: Log deferred errors with WarnOnError

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
This commit is contained in:
Stéphane Graber 2026-05-28 14:51:28 -04:00
parent 0c41c18ab2
commit ecd9e93885
No known key found for this signature in database
GPG Key ID: C638974D64792D67
3 changed files with 6 additions and 3 deletions

View File

@ -9,6 +9,7 @@ import (
"strings"
internalUtil "github.com/lxc/incus/v7/internal/util"
"github.com/lxc/incus/v7/shared/logger"
"github.com/lxc/incus/v7/shared/util"
)
@ -130,7 +131,7 @@ func parseConfig(path string) ([]string, error) {
return nil, err
}
defer func() { _ = file.Close() }()
defer logger.WarnOnError(file.Close, "Failed to close file")
var config []string

View File

@ -9,6 +9,7 @@ import (
"github.com/spf13/cobra"
"github.com/lxc/incus/v7/internal/eagain"
"github.com/lxc/incus/v7/shared/logger"
"github.com/lxc/incus/v7/shared/util"
)
@ -56,7 +57,7 @@ func (c *cmdNetcat) run(cmd *cobra.Command, args []string) error {
wg.Add(1)
go func() {
defer func() { _ = conn.Close() }()
defer logger.WarnOnError(conn.Close, "Failed to close connection")
defer wg.Done()
_, _ = util.SafeCopy(eagain.Writer{Writer: os.Stdout}, eagain.Reader{Reader: conn})

View File

@ -13,6 +13,7 @@ import (
"github.com/lxc/incus/v7/internal/linux"
"github.com/lxc/incus/v7/internal/migration"
"github.com/lxc/incus/v7/shared/logger"
"github.com/lxc/incus/v7/shared/ws"
)
@ -24,7 +25,7 @@ func rsyncSend(conn *websocket.Conn, path string, rsyncArgs string) error {
}
if dataSocket != nil {
defer func() { _ = dataSocket.Close() }()
defer logger.WarnOnError(dataSocket.Close, "Failed to close connection")
}
readDone, writeDone := ws.Mirror(conn, dataSocket)