From 264633597c2c4332618ec0b839c9bce876498e3e Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Mon, 2 Dec 2024 16:15:38 +0800 Subject: [PATCH] fix(baremetal): debug info for task queue --- pkg/baremetal/manager.go | 4 +++- pkg/baremetal/tasks/base.go | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/baremetal/manager.go b/pkg/baremetal/manager.go index 3f2ccfa1f9e..16570b6f793 100644 --- a/pkg/baremetal/manager.go +++ b/pkg/baremetal/manager.go @@ -1311,8 +1311,10 @@ func (b *SBaremetalInstance) GetTask() tasks.ITask { func (b *SBaremetalInstance) SetTask(task tasks.ITask) { b.taskQueue.AppendTask(task) if reflect.DeepEqual(task, b.taskQueue.GetTask()) { - log.Infof("Set task equal, ExecuteTask %s", task.GetName()) + log.Infof("[Baremetal %s] Set task equal, ExecuteTask %s", b.GetId(), task.GetName()) tasks.ExecuteTask(task, nil) + } else { + log.Warningf("[Baremetal %s] task queue is not empty: %s", b.GetId(), b.taskQueue.String()) } } diff --git a/pkg/baremetal/tasks/base.go b/pkg/baremetal/tasks/base.go index 86623275695..30095008bf5 100644 --- a/pkg/baremetal/tasks/base.go +++ b/pkg/baremetal/tasks/base.go @@ -80,11 +80,20 @@ func (q *Queue) String() string { return fmt.Sprintf("%v", itemStrings) } +type iStringer interface { + String() string +} + func debugString(elem *list.Element) []string { if elem == nil { return nil } + val := elem.Value + valStr, ok := val.(iStringer) strings := []string{fmt.Sprintf("%v", elem.Value)} + if ok { + strings[0] = valStr.String() + } rest := debugString(elem.Next()) if rest != nil { strings = append(strings, rest...)