Skip to content

Commit 23d5780

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

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
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...)

pkg/baremetal/tasks/baseprepare.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ func (task *sBaremetalPrepareTask) DoPrepare(ctx context.Context, cli *ssh.Clien
354354

355355
logclient.AddActionLogWithStartable(task, task.baremetal, logclient.ACT_PREPARE, infos.sysInfo, task.userCred, true)
356356

357-
log.Infof("Prepare complete")
357+
log.Infof("[Baremetal %s] Prepare complete", task.baremetal.GetId())
358358
return nil
359359
}
360360

0 commit comments

Comments
 (0)