Skip to content

Commit 949404b

Browse files
committed
chore: add more debugging logs for META and volumes
Doesn't fix anything, but the hope is that it would help with #9852 and #9786. Signed-off-by: Andrey Smirnov <[email protected]> (cherry picked from commit b15917e)
1 parent 7d73853 commit 949404b

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

Diff for: internal/app/machined/pkg/controllers/block/volume_manager.go

+22-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,28 @@ func (ctrl *VolumeManagerController) Run(ctx context.Context, r controller.Runti
346346
}
347347

348348
if prevPhase != volumeStatus.Phase || err != nil {
349-
volumeLogger.Info("volume status", zap.String("phase", fmt.Sprintf("%s -> %s", prevPhase, volumeStatus.Phase)), zap.Error(err))
349+
fields := []zap.Field{
350+
zap.String("phase", fmt.Sprintf("%s -> %s", prevPhase, volumeStatus.Phase)),
351+
zap.Error(err),
352+
}
353+
354+
if volumeStatus.Location != "" {
355+
fields = append(fields, zap.String("location", volumeStatus.Location))
356+
}
357+
358+
if volumeStatus.MountLocation != "" && volumeStatus.MountLocation != volumeStatus.Location {
359+
fields = append(fields, zap.String("mountLocation", volumeStatus.MountLocation))
360+
}
361+
362+
if volumeStatus.ParentLocation != "" {
363+
fields = append(fields, zap.String("parentLocation", volumeStatus.ParentLocation))
364+
}
365+
366+
if len(volumeStatus.EncryptionFailedSyncs) > 0 {
367+
fields = append(fields, zap.Strings("encryptionFailedSyncs", volumeStatus.EncryptionFailedSyncs))
368+
}
369+
370+
volumeLogger.Info("volume status", fields...)
350371
}
351372

352373
allClosed = allClosed && volumeStatus.Phase == block.VolumePhaseClosed

Diff for: internal/pkg/meta/internal/adv/syslinux/syslinux.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package syslinux
77

88
import (
99
"encoding/binary"
10+
"fmt"
1011
"io"
1112

1213
"github.com/siderolabs/talos/internal/pkg/meta/internal/adv"
@@ -38,12 +39,12 @@ func NewADV(r io.ReadSeeker) (adv ADV, err error) {
3839

3940
_, err = r.Seek(-2*AdvSize, io.SeekEnd)
4041
if err != nil {
41-
return nil, err
42+
return nil, fmt.Errorf("failed to seek for syslinux adv: %w", err)
4243
}
4344

4445
_, err = io.ReadFull(r, b)
4546
if err != nil {
46-
return nil, err
47+
return nil, fmt.Errorf("failed to read syslinux adv: %w", err)
4748
}
4849

4950
adv = b

Diff for: internal/pkg/meta/internal/adv/talos/talos.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func NewADV(r io.Reader) (*ADV, error) {
7171

7272
_, err := io.ReadFull(r, buf)
7373
if err != nil {
74-
return nil, err
74+
return nil, fmt.Errorf("failed to load first block: %w", err)
7575
}
7676

7777
if err = a.Unmarshal(buf); err == nil {
@@ -81,10 +81,14 @@ func NewADV(r io.Reader) (*ADV, error) {
8181
// try 2nd copy
8282
_, err = io.ReadFull(r, buf)
8383
if err != nil {
84-
return nil, err
84+
return nil, fmt.Errorf("failed to load second block: %w", err)
85+
}
86+
87+
if err = a.Unmarshal(buf); err != nil {
88+
return a, fmt.Errorf("failed to unmarshal second block: %w", err)
8589
}
8690

87-
return a, a.Unmarshal(buf)
91+
return a, nil
8892
}
8993

9094
// Unmarshal single copy from the serialized representation.

Diff for: internal/pkg/meta/meta.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ func (meta *Meta) Reload(ctx context.Context) error {
146146
defer parentDev.Unlock() //nolint:errcheck
147147
}
148148

149+
meta.opts.printer("META: loading from %s", path)
150+
149151
f, err := os.Open(path)
150152
if err != nil {
151153
return err
@@ -160,12 +162,12 @@ func (meta *Meta) Reload(ctx context.Context) error {
160162
adv, err := talos.NewADV(f)
161163
if adv == nil && err != nil {
162164
// if adv is not nil, but err is nil, it might be missing ADV, ignore it
163-
return err
165+
return fmt.Errorf("failed to load Talos adv: %w", err)
164166
}
165167

166168
legacyAdv, err := syslinux.NewADV(f)
167169
if err != nil {
168-
return err
170+
return fmt.Errorf("failed to load syslinux adv: %w", err)
169171
}
170172

171173
// copy values from in-memory to on-disk version
@@ -244,6 +246,8 @@ func (meta *Meta) Flush() error {
244246
defer parentDev.Unlock() //nolint:errcheck
245247
}
246248

249+
meta.opts.printer("META: saving to %s", path)
250+
247251
f, err := os.OpenFile(path, os.O_RDWR, 0)
248252
if err != nil {
249253
return err

0 commit comments

Comments
 (0)