Skip to content

Commit 2646335

Browse files
committed
fix(baremetal): debug info for task queue
1 parent 2857dca commit 2646335

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pkg/baremetal/manager.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1311,8 +1311,10 @@ func (b *SBaremetalInstance) GetTask() tasks.ITask {
13111311
func (b *SBaremetalInstance) SetTask(task tasks.ITask) {
13121312
b.taskQueue.AppendTask(task)
13131313
if reflect.DeepEqual(task, b.taskQueue.GetTask()) {
1314-
log.Infof("Set task equal, ExecuteTask %s", task.GetName())
1314+
log.Infof("[Baremetal %s] Set task equal, ExecuteTask %s", b.GetId(), task.GetName())
13151315
tasks.ExecuteTask(task, nil)
1316+
} else {
1317+
log.Warningf("[Baremetal %s] task queue is not empty: %s", b.GetId(), b.taskQueue.String())
13161318
}
13171319
}
13181320

pkg/baremetal/tasks/base.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,20 @@ func (q *Queue) String() string {
8080
return fmt.Sprintf("%v", itemStrings)
8181
}
8282

83+
type iStringer interface {
84+
String() string
85+
}
86+
8387
func debugString(elem *list.Element) []string {
8488
if elem == nil {
8589
return nil
8690
}
91+
val := elem.Value
92+
valStr, ok := val.(iStringer)
8793
strings := []string{fmt.Sprintf("%v", elem.Value)}
94+
if ok {
95+
strings[0] = valStr.String()
96+
}
8897
rest := debugString(elem.Next())
8998
if rest != nil {
9099
strings = append(strings, rest...)

0 commit comments

Comments
 (0)