Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] fix(baremetal): debug info for task queue #21719

Open
wants to merge 1 commit into
base: release/3.11
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion pkg/baremetal/tasks/baseprepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func (task *sBaremetalPrepareTask) DoPrepare(ctx context.Context, cli *ssh.Clien

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

log.Infof("Prepare complete")
log.Infof("[Baremetal %s] Prepare complete", task.baremetal.GetId())
return nil
}

Expand Down