Skip to content

Commit

Permalink
BF: CS-348 incorrect timestamp from qstat -j jobid -xml
Browse files Browse the repository at this point in the history
EH: CS-592 Zombie jobs show a different time stamp as normal jobs
  • Loading branch information
jgabler-hpc committed Sep 18, 2024
1 parent 7a384c0 commit c293751
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
2 changes: 1 addition & 1 deletion source/clients/qstat/ocs_qstat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1874,7 +1874,7 @@ qstat_show_job(lList *jid_list, u_long32 isXML, qstat_env_t *qstat_env) {
alp = sge_gdi(SGE_SME_LIST, SGE_GDI_GET, &ilp, nullptr, what);
lFreeWhat(&what);

if (!isXML){
if (!isXML) {
for_each_ep(aep, alp) {
if (lGetUlong(aep, AN_status) != STATUS_OK) {
fprintf(stderr, "%s\n", lGetString(aep, AN_text));
Expand Down
17 changes: 11 additions & 6 deletions source/clients/qstat/ocs_qstat_xml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,8 @@ static int qstat_xml_job(job_handler_t* handler, u_long32 jid, job_summary_t *su
int sge_ext, tsk_ext, sge_urg, sge_pri, sge_time;
dstring ds = DSTRING_INIT;
lList *attribute_list = nullptr;

static bool compat = sge_getenv("SGE_QSTAT_SGE_COMPATIBILITY") != nullptr;

DENTER(TOP_LAYER);

ctx->job_elem = lCreateElem(XMLE_Type);
Expand Down Expand Up @@ -441,18 +442,22 @@ static int qstat_xml_job(job_handler_t* handler, u_long32 jid, job_summary_t *su
xml_append_Attr_S(attribute_list, "state", summary->state);

if (sge_time) {
u_long64 timestamp;
const char *attrib;
if (summary->is_running) {
xml_append_Attr_S(attribute_list, "JAT_start_time", sge_ctime64_xml(summary->start_time, &ds));
}
else {
xml_append_Attr_S(attribute_list, "JB_submission_time", sge_ctime64_xml(summary->submit_time, &ds));
attrib = "JAT_start_time";
timestamp = summary->start_time;
} else {
attrib = "JAT_submission_time";
timestamp = summary->submit_time;
}
xml_append_Attr_S(attribute_list, attrib, sge_ctime64(timestamp, &ds, true, compat ? false : true));
}

/* deadline time */
if (sge_urg) {
if (summary->deadline) {
xml_append_Attr_S(attribute_list, "JB_deadline", sge_ctime64_xml(summary->deadline, &ds));
xml_append_Attr_S(attribute_list, "JB_deadline", sge_ctime64(summary->deadline, &ds, true, compat ? false : true));
}
}

Expand Down
32 changes: 28 additions & 4 deletions source/libs/sgeobj/sge_cull_xml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@
#include "uti/sge_dstring.h"
#include "uti/sge_log.h"
#include "uti/sge_rmon_macros.h"
#include "uti/sge_time.h"

#include "cull/cull_lerrnoP.h"
#include "cull/cull_list.h"
#include "cull/msg_cull.h"

#include "sgeobj/sge_cull_xml.h"

static void lWriteElemXML_(const lListElem *ep, int nesting_level, FILE *fp, int ignore_cull_name);
static void lWriteElemXML_(const lListElem *ep, int nesting_level, FILE *fp, int ignore_cull_name);
static void lWriteListXML_(const lList *lp, int nesting_level, FILE *fp, int ignore_cull_name);
static bool lAttributesToString_(const lList *attr_list, dstring *attr);
static void lWriteXMLHead_(const lListElem *ep, int nesting_level, FILE *fp, int ignore_cull_name);
Expand Down Expand Up @@ -383,11 +384,34 @@ static void lWriteElemXML_(const lListElem *ep, int nesting_level, FILE *fp, int
}
break;
case lUlong64T:
if (!fp) {
DPRINTF( sge_u64, lGetPosUlong64(ep, i));
{
u_long64 value = lGetPosUlong64(ep, i);

// hack: assume it is a timestamp when the attribute name contains "time"
if (strstr(attr_name, "time") != nullptr) {
static bool compat = sge_getenv("SGE_QSTAT_SGE_COMPATIBILITY") != nullptr;
if (compat) {
if (!fp) {
DPRINTF(sge_u64, value / 1000000);
} else {
fprintf(fp, sge_u64, value / 1000000);
}
} else {
DSTRING_STATIC(dstr, 128);
if (!fp) {
DPRINTF("%s", sge_ctime64_xml(value, &dstr));
} else {
fprintf(fp, "%s", sge_ctime64_xml(value, &dstr));
}
}
} else {
fprintf(fp, sge_u64, lGetPosUlong64(ep, i));
if (!fp) {
DPRINTF(sge_u64, value);
} else {
fprintf(fp, sge_u64, value);
}
}
}
break;
case lStringT:
{
Expand Down

0 comments on commit c293751

Please sign in to comment.