adaptivecomputing / torque

Torque Repository
Other
251 stars 141 forks source link

Impossible to request the Walltime.Remaining job attribute via pbs_statjob() #238

Open jbarber opened 10 years ago

jbarber commented 10 years ago

It's not possible to request just the Walltime.Remaining attribute for a job using the pbs_statjob() function. This is problematic if a user of the API is only interested in the remaining walltime for all selectable jobs.

For example, the following code returns the error message "Undefined attribute":

// gcc -I/usr/include/torque -std=c99 test.c  -ltorque -g3
#include <stdio.h>
#include <stdlib.h>

#include <pbs_ifl.h>
#include <pbs_error.h>

int main (int argc, char **argv) {
    struct attrl attr = {
        .next = NULL,
        .name = "Walltime",
        .resource = "Remaining",
        .value = NULL
    };

    int handle = pbs_connect(NULL);
    if (handle < 0) {
        fprintf(stderr, "Connection failed");
        exit(EXIT_FAILURE);
    }

    struct batch_status *bs = pbs_statjob(handle, NULL, &attr, NULL);
    if (bs == NULL) {
        if (pbs_errno) {
            char *err = pbs_geterrmsg(handle);
            printf("%s\n", err);
            exit(EXIT_FAILURE);
        }
    }
    else {
        printf("Got jobs");
        pbs_statfree(bs);
    }
    pbs_disconnect(handle);

    return EXIT_SUCCESS;
}

Requesting all attributes (with a NULL pointer instead of *attr) returns the Walltime.Remaining.

Tested with 4.5.0 and 2.5 on RHEL6 x86_64.

knielson commented 9 years ago

In order to get walltime remaining there must be a walltime set on a job. If you use the default setup for Torque the batch queue has the resources_default.walltime attribute set. This adds the walltime to the job. If you submit jobs to a queue that do not have a walltime set or if you do not pass a walltime into the job there will be no walltime_remaining attribute returned

jbarber commented 9 years ago

My point was that it isn't possible to get just the walltime.remaining attribute of a job - at least with the versions I tested.