Skip to content

Commit

Permalink
Merge pull request #21 from yohamta/feature/update-status
Browse files Browse the repository at this point in the history
Feature/update status
  • Loading branch information
yohamta authored Apr 27, 2022
2 parents 1c27477 + 1a7e9af commit 44d7e86
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 4 deletions.
79 changes: 79 additions & 0 deletions internal/admin/handlers/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,20 @@ func HandleGetDAG(hc *DAGHandlerConfig) http.HandlerFunc {
switch params.Tab {
case DAG_TabType_Status:
data.Graph = models.StepGraph(dag.Status.Nodes, params.Tab != DAG_TabType_Config)

case DAG_TabType_Config:
steps := models.FromSteps(dag.Config.Steps)
data.Graph = models.StepGraph(steps, params.Tab != DAG_TabType_Config)
data.Definition, _ = config.ReadConfig(path.Join(hc.DAGsDir, params.Group, cfg))

case DAG_TabType_History:
logs, err := controller.New(dag.Config).GetStatusHist(30)
if err != nil {
encodeError(w, err)
return
}
data.LogData = buildLog(logs)

case DAG_TabType_StepLog:
if isJsonRequest(r) {
data.StepLog, err = readStepLog(c, params.File, params.Step, hc.LogEncodingCharset)
Expand All @@ -134,6 +137,7 @@ func HandleGetDAG(hc *DAGHandlerConfig) http.HandlerFunc {
return
}
}

case DAG_TabType_ScLog:
if isJsonRequest(r) {
data.ScLog, err = readSchedulerLog(c, params.File)
Expand All @@ -142,6 +146,7 @@ func HandleGetDAG(hc *DAGHandlerConfig) http.HandlerFunc {
return
}
}

default:
}

Expand Down Expand Up @@ -169,6 +174,7 @@ func HandlePostDAGAction(hc *PostDAGHandlerConfig) http.HandlerFunc {
action := r.FormValue("action")
group := r.FormValue("group")
reqId := r.FormValue("request-id")
step := r.FormValue("step")

cfg, err := getPathParameter(r)
if err != nil {
Expand Down Expand Up @@ -197,6 +203,7 @@ func HandlePostDAGAction(hc *PostDAGHandlerConfig) http.HandlerFunc {
w.Write([]byte(err.Error()))
return
}

case "stop":
if dag.Status.Status != scheduler.SchedulerStatus_Running {
w.WriteHeader(http.StatusBadRequest)
Expand All @@ -209,6 +216,7 @@ func HandlePostDAGAction(hc *PostDAGHandlerConfig) http.HandlerFunc {
w.Write([]byte(err.Error()))
return
}

case "retry":
if reqId == "" {
w.WriteHeader(http.StatusBadRequest)
Expand All @@ -221,6 +229,57 @@ func HandlePostDAGAction(hc *PostDAGHandlerConfig) http.HandlerFunc {
w.Write([]byte(err.Error()))
return
}

case "mark-success":
if dag.Status.Status == scheduler.SchedulerStatus_Running {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("DAG is running."))
return
}
if reqId == "" {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("request-id is required."))
return
}
if step == "" {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("step is required."))
return
}

err = updateStatus(c, reqId, step, scheduler.NodeStatus_Success)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
return
}

return

case "mark-failed":
if dag.Status.Status == scheduler.SchedulerStatus_Running {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("DAG is running."))
return
}
if reqId == "" {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("request-id is required."))
return
}
if step == "" {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("step is required."))
return
}

err = updateStatus(c, reqId, step, scheduler.NodeStatus_Error)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
return
}

default:
encodeError(w, errInvalidArgs)
return
Expand All @@ -230,6 +289,26 @@ func HandlePostDAGAction(hc *PostDAGHandlerConfig) http.HandlerFunc {
}
}

func updateStatus(c controller.Controller, reqId, step string, to scheduler.NodeStatus) error {
status, err := c.GetStatusByRequestId(reqId)
if err != nil {
return err
}
found := false
for i := range status.Nodes {
if status.Nodes[i].Step.Name == step {
status.Nodes[i].Status = to
status.Nodes[i].StatusText = to.String()
found = true
break
}
}
if !found {
return fmt.Errorf("step %s not found", step)
}
return c.UpdateStatus(status)
}

func readSchedulerLog(c controller.Controller, file string) (*schedulerLog, error) {
logFile := ""
if file == "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/admin/handlers/web/templates/base.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<div class="navbar-brand">
<a class="navbar-item" href="/">
<img alt="dagu" width="32" height="32" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAABYWlDQ1BrQ0dDb2xvclNwYWNlRGlzcGxheVAzAAAokWNgYFJJLCjIYWFgYMjNKykKcndSiIiMUmB/yMAOhLwMYgwKicnFBY4BAT5AJQwwGhV8u8bACKIv64LMOiU1tUm1XsDXYqbw1YuvRJsw1aMArpTU4mQg/QeIU5MLikoYGBhTgGzl8pICELsDyBYpAjoKyJ4DYqdD2BtA7CQI+whYTUiQM5B9A8hWSM5IBJrB+API1klCEk9HYkPtBQFul8zigpzESoUAYwKuJQOUpFaUgGjn/ILKosz0jBIFR2AopSp45iXr6SgYGRiaMzCAwhyi+nMgOCwZxc4gxJrvMzDY7v////9uhJjXfgaGjUCdXDsRYhoWDAyC3AwMJ3YWJBYlgoWYgZgpLY2B4dNyBgbeSAYG4QtAPdHFacZGYHlGHicGBtZ7//9/VmNgYJ/MwPB3wv//vxf9//93MVDzHQaGA3kAFSFl7jXH0fsAAACEZVhJZk1NACoAAAAIAAYBBgADAAAAAQACAAABEgADAAAAAQABAAABGgAFAAAAAQAAAFYBGwAFAAAAAQAAAF4BKAADAAAAAQACAACHaQAEAAAAAQAAAGYAAAAAAAAAhAAAAAEAAACEAAAAAQACoAIABAAAAAEAAABAoAMABAAAAAEAAABAAAAAAGYvjikAAAAJcEhZcwAAFE0AABRNAZTKjS8AAALqaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA2LjAuMCI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53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JuOw9W5se2bW15Yt80Ih3gOAdKU1BGppIU+/FKQepuh7Yf3cmZ/T1Dk0ee+pgTwcGOMCDfPKT6xQcSpwr+uKvNiwYLnkmUrjYzHjjglDbBb6fDSxsnrnZ+Hh9Z1vn8z8cP7f6RPGWlqqwBiZGYR5hnyIFcUy2WDfMwaNdo18ZTeonPd7Qfk5wBeC9QfLzubbVdRuAaF/P4NTrJ7qHv4T7iUefe/txtHka1xFcE157Lqd9GuNhprhk4rlkjeI6LhcDzDDD7D5CGwRRsnu3s3eve9DBbfAe/jw6Ft3Fj5Y4nTIDbbgrm3nCDTP8+O7d7rF3PHpEz25y5b0nFBaMd3Hd7OvKPnM9e+097ZDd4/fQ3t2ghy+mjTvyrKNw7+dCtGCd47SLfKZ/VkNWP2b22pHOQvaLfOtJ2aPxl4Jpj9lflb+MEvj/ERFJSfKBnJkAAAAASUVORK5CYII=">
<span id="nav-title">degu</span>
<span id="nav-title">dagu</span>
</a>
</div>
</nav>
Expand Down
80 changes: 77 additions & 3 deletions internal/admin/handlers/web/templates/dag.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,27 @@
{},
]
function NodeTable({ nodes, file = "", dag }) {
const [modal, setModal] = React.useState(false);
const [current, setCurrent] = React.useState(null);
const requireModal = (step) => {
if (dag.Status.Status == SCHEDULER_STATUS__RUNNING || dag.Status.Status == SCHEDULER_STATUS__NONE) {
return;
}
setCurrent(step);
setModal(true);
}
const dismissModal = () => { setModal(false); }
React.useEffect(() => {
document.addEventListener('keydown', (event) => {
const e = event || window.event;
if (e.keyCode === 27) { // Escape key
setModal(false);
}
});
return () => {
document.removeEventListener('keydown');
};
}, [])
const tableStyle = {
"tableLayout": "fixed",
"wordWrap": "break-word",
Expand All @@ -515,6 +536,10 @@
"overflow-x": "auto",
};
const styles = stepTabColStyles;
const modalbuttonStyle = {};
const modalStyle = {
display: modal ? "flex" : "none",
}
let i = 0;
if (!nodes.length) {
return null;
Expand All @@ -537,9 +562,49 @@
</tr>
</thead>
<tbody>
{nodes.map((n, idx) => <NodeTableRow rownum={idx + 1} node={n} file={file}></NodeTableRow>)}
{nodes.map((n, idx) => <NodeTableRow rownum={idx + 1} node={n} file={file} onRequireModal={requireModal}></NodeTableRow>)}
</tbody>
</table>

{current ? (
<div className="modal is-active" style={modalStyle}>
<div className="modal-background"></div>
<div className="modal-card">
<header className="modal-card-head">
<p className="modal-card-title">Update status of "{current.Name}"</p>
<button className="delete" aria-label="close" onClick={dismissModal}></button>
</header>
<section className="modal-card-body">
<div className="mr-4 pt-4 is-flex is-flex-direction-row">
<form method="post" onSubmit={null}>
<input type="hidden" name="group" value="{{.Group}}"></input>
<input type="hidden" name="request-id" value={dag.Status.RequestId}></input>
<input type="hidden" name="step" value={current.Name}></input>
<button type="submit" name="action" value="mark-success"
className="button is-info"
style={modalbuttonStyle}>
<span>Mark Success</span>
</button>
</form>
<form method="post" onSubmit={null}>
<input type="hidden" name="group" value="{{.Group}}"></input>
<input type="hidden" name="request-id" value={dag.Status.RequestId}></input>
<input type="hidden" name="step" value={current.Name}></input>
<button type="submit" name="action" value="mark-failed"
className="button is-info ml-4"
style={modalbuttonStyle}>
<span>Mark Failed</span>
</button>
</form>
</div>
</section>
<footer className="modal-card-foot">
<button className="button" onClick={dismissModal}>Cancel</button>
</footer>
</div>
</div>

) : null}
</div>
)
}
Expand All @@ -550,8 +615,15 @@
</React.Fragment>
)
}
function NodeTableRow({ rownum, node, file }) {
function NodeTableRow({ rownum, node, file, onRequireModal }) {
const url = encodeURI("?t=" + TAB_ID__STEPLOG + "&group={{.Group}}&file=" + file + "&step=" + node.Step.Name)
const buttonStyle = {
"margin": "0px",
"padding": "0px",
"border": "0px",
"background": "none",
"outline": "none",
};
return (
<tr>
<td> {rownum} </td>
Expand All @@ -561,7 +633,9 @@
<td> {node.Step.Args ? node.Step.Args.join(" ") : ""} </td>
<td> {node.StartedAt} </td>
<td> {node.FinishedAt} </td>
<td> <StatusTag status={node.Status}>{node.StatusText}</StatusTag></td>
<td> <button style={buttonStyle} onClick={() => onRequireModal(node.Step)}>
<StatusTag status={node.Status}>{node.StatusText}</StatusTag>
</button> </td>
<td> {node.Error} </td>
<td> <a href={url}> {node.Log} </a> </td>
</tr>
Expand Down
Loading

0 comments on commit 44d7e86

Please sign in to comment.