Skip to content

Commit

Permalink
fix(baremetal): debug info for task queue
Browse files Browse the repository at this point in the history
  • Loading branch information
zexi committed Dec 2, 2024
1 parent 2857dca commit 2646335
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/baremetal/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/baremetal/tasks/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down

0 comments on commit 2646335

Please sign in to comment.