summaryrefslogtreecommitdiff
diff options
authorMichael Vogt <mvo@ubuntu.com>2022-06-21 13:34:48 +0200
committerMichael Vogt <mvo@ubuntu.com>2022-06-21 13:34:48 +0200
commit8bfb91f8461507366a2a5f3fbb574b9873263ef9 (patch)
tree51c6f00a271ecac32ac168997253a496922c0f54
parent687fa0fa6f8d4775fd9495c5b79725cdc230aa55 (diff)
devicestate: print some debug output when seeding failsdebug-seed-failure
When seeding fails that is a rare but catastrophic event. To help understanding these problems this commit adds some extra debug output. For now that is just the `timedatectl` output as this is the most common source of issues but we could extend it in the future.
-rw-r--r--overlord/devicestate/devicemgr.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/overlord/devicestate/devicemgr.go b/overlord/devicestate/devicemgr.go
index 98690d558e..0da5e8ab88 100644
--- a/overlord/devicestate/devicemgr.go
+++ b/overlord/devicestate/devicemgr.go
@@ -20,11 +20,13 @@
package devicestate
import (
+ "bytes"
"context"
"errors"
"fmt"
"io/ioutil"
"os"
+ "os/exec"
"path/filepath"
"regexp"
"strings"
@@ -1366,6 +1368,25 @@ func (e *ensureError) Error() string {
// no \n allowed in warnings
var seedFailureFmt = `seeding failed with: %v. This indicates an error in your distribution, please see https://forum.snapcraft.io/t/16341 for more information.`
+func debugSeedFailure(err error) string {
+ buf := bytes.NewBuffer(nil)
+
+ h1fmt := "\n==================== %s ===================="
+ h2fmt := "========== %s =========="
+
+ fmt.Fprintf(buf, h1fmt, "seeding failed")
+ fmt.Fprintf(buf, "error: %v", err)
+
+ fmt.Fprintf(buf, h2fmt, "timedatectl output")
+ output, err := exec.Command("timedatectl", "status").CombinedOutput()
+ if err != nil {
+ fmt.Fprintf(buf, "failed: %v", err)
+ }
+ fmt.Fprintf(buf, "%v", output)
+
+ return buf.String()
+}
+
// Ensure implements StateManager.Ensure.
func (m *DeviceManager) Ensure() error {
var errs []error
@@ -1375,6 +1396,8 @@ func (m *DeviceManager) Ensure() error {
m.state.Warnf(seedFailureFmt, err)
m.state.Unlock()
errs = append(errs, fmt.Errorf("cannot seed: %v", err))
+
+ logger.Noticef("%s", debugSeedFailure(err))
}
if !m.preseed {