-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added schedule introspector for debugging
source manager now has function for dumping schedule scheduler now has function for dumping its own state synchronously server now has /v1/scheduler endpoint for getting data client library now has function for calling /v1/scheduler and getting data into a struct cli now has `scheduler` or `sched` command (hidden from help) for looking at scheduler state easily. Scheduler is still borked though, and with the help of these tools, I can see that.
- Loading branch information
1 parent
7c7431c
commit 1a01df8
Showing
7 changed files
with
169 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"time" | ||
|
||
"github.com/doomsday-project/doomsday/client/doomsday" | ||
"github.com/olekukonko/tablewriter" | ||
"github.com/starkandwayne/goutils/ansi" | ||
) | ||
|
||
type schedulerCmd struct{} | ||
|
||
func (*schedulerCmd) Run() error { | ||
state, err := client.GetSchedulerState() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
printSchedTaskList(state.Tasks) | ||
return nil | ||
} | ||
|
||
func printSchedTaskList(tasks []doomsday.GetSchedulerTask) { | ||
fmt.Printf("\n") | ||
table := tablewriter.NewWriter(os.Stdout) | ||
table.SetBorder(false) | ||
table.SetRowLine(true) | ||
table.SetAutoWrapText(false) | ||
table.SetReflowDuringAutoWrap(false) | ||
table.SetHeader([]string{"At", "Reason", "Kind", "Ready"}) | ||
|
||
readyStr := ansi.Sprintf("@G{YES}") | ||
notReadyStr := ansi.Sprintf("@R{NO}") | ||
now := time.Now() | ||
for _, task := range tasks { | ||
timeUntilStr := time.Unix(task.At, 0).Sub(now).String() | ||
readyOutStr := notReadyStr | ||
if task.Ready { | ||
readyOutStr = readyStr | ||
} | ||
table.Append([]string{ | ||
timeUntilStr, | ||
task.Reason, | ||
task.Kind, | ||
readyOutStr, | ||
}) | ||
} | ||
table.Render() | ||
fmt.Printf("\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters