Init commit of jobs output/error message peek project.
This commit is contained in:
parent
c772d7e601
commit
d2b47e3985
38 changed files with 2267 additions and 21 deletions
|
|
@ -3,6 +3,7 @@ package backend
|
|||
import (
|
||||
"apiserver/models"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -76,6 +77,33 @@ func IsArrayJob(id uint64) bool {
|
|||
return extractIDTag(id) == tagJobArray
|
||||
}
|
||||
|
||||
// FormatJobID formats a packed 64-bit job ID as a human-readable string,
|
||||
// matching the C fmt_jobid() output in src/lib/utils.c.
|
||||
// - Regular job: "{cluster}-{apiserver}-{timestamp}-{sequence}"
|
||||
// - Array child: "{cluster}-{apiserver}-{timestamp}-{base}[{idx}]"
|
||||
func FormatJobID(uniqueJobID int64) string {
|
||||
id := uint64(uniqueJobID)
|
||||
clusterID := extractBits(id, clusterIDShift, nClusterIDBits)
|
||||
apiserverID := extractBits(id, apiserverIDShift, nApiserverIDBits)
|
||||
timestamp := extractBits(id, timestampShift, nTimestampBits)
|
||||
|
||||
if extractIDTag(id) == tagJobArray {
|
||||
arrayBase := extractBits(id, sequenceHighShift, nSequenceBits-nArrayIdxBits) << uint(sequenceHighShift)
|
||||
arrayIdx := extractBits(id, 0, nArrayIdxBits)
|
||||
return fmt.Sprintf("%d-%d-%d-%d[%d]",
|
||||
clusterID, apiserverID, timestamp, arrayBase, arrayIdx)
|
||||
}
|
||||
sequence := extractBits(id, 0, nSequenceBits)
|
||||
return fmt.Sprintf("%d-%d-%d-%d",
|
||||
clusterID, apiserverID, timestamp, sequence)
|
||||
}
|
||||
|
||||
// WorkerDefaultOutputPath returns the output file path the worker uses by default
|
||||
// for the given job ID and task index, matching uv_proc.c make_job_output_path().
|
||||
func WorkerDefaultOutputPath(uniqueJobID int64, taskIdx int) string {
|
||||
return fmt.Sprintf("/tmp/job_%s_task%d.out", FormatJobID(uniqueJobID), taskIdx)
|
||||
}
|
||||
|
||||
// rawStartInfo mirrors the C job_startinfo_t fields used by the Go model.
|
||||
type rawStartInfo struct {
|
||||
cmdline string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue