abhilekhsingh / gc3pie

Automatically exported from code.google.com/p/gc3pie
0 stars 0 forks source link

SLURM backend return `None` in case of invalid date #411

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The SLURM backend code parses an invalid date into a Python `None`
object, which generates a traceback in turn:

    gc3.gc3libs: DEBUG: Executed command 'sacct --noheader --parsable --format jobid,exitcode,ncpus,elapsed,totalcpu,submit,start,end,maxrss,maxvmsize -j 46743' on host 'baobab.unige.ch'; exit code: 0
    gc3.gc3libs: ERROR: Could not parse 'Unknown' as an SLURM 'standard' (ISO8601) timestamp: ValueError: time data 'Unknown' does not match format '%Y-%m-%dT%H:%M:%S' Please set the environment variable 'SLURM_TIME_FORMAT' to 'standard' on the SLURM frontend computer.
    gc3.gc3libs: ERROR: Error in querying Batch resource 'baobab': TypeError: can't compare datetime.datetime to NoneType
    gc3.gc3libs: DEBUG: Error getting status of application 'GdemoSimpleApp@2b6dea9fef90': TypeError: can't compare datetime.datetime to NoneType
    Traceback (most recent call last):
      File "/home/denisa/gc3pie/src/gc3libs/core.py", line 414, in __update_application
        state = lrms.update_job_state(app)
      File "/home/denisa/gc3pie/src/gc3libs/backends/__init__.py", line 150, in wrapper
        return fn(self, *args, **kwargs)
      File "/home/denisa/gc3pie/src/gc3libs/backends/batch.py", line 519, in update_job_state
        jobstatus = self._parse_acct_output(stdout)
      File "/home/denisa/gc3pie/src/gc3libs/backends/slurm.py", line 345, in _parse_acct_output
        acct['slurm_completion_time'] = max(submit, start, end)
    TypeError: can't compare datetime.datetime to NoneType
    gc3.gc3libs: WARNING: Ignored error in Core.update_job_state(): can't compare datetime.datetime to NoneType
    gc3.gc3libs: DEBUG: Ignored error in Core.update_job_state(): TypeError: can't compare datetime.datetime to NoneType
    Traceback (most recent call last):
      File "/home/denisa/gc3pie/src/gc3libs/core.py", line 423, in __update_application
        raise ex
    TypeError: can't compare datetime.datetime to NoneType

Actually, this behavior was explicitly marked as "dangerous" in the
code, see `slurm.py` lines 411--421:

        try:
            return datetime.datetime(
                *(time.strptime(ts, SlurmLrms._TIMEFMT_ISO8601)[0:6]))
        except ValueError, err:
            gc3libs.log.error(
                "Could not parse '%s' as an SLURM 'standard' (ISO8601)"
                " timestamp: %s: %s Please set the environment variable"
                " 'SLURM_TIME_FORMAT' to 'standard' on the SLURM frontend"
                " computer.", ts, err.__class__.__name__, err)
            # XXX: this results in an invalid timestamp...
            return None

What would be a better thing to do here?  Just propagate the exception?

Original issue reported on code.google.com by riccardo.murri@gmail.com on 30 Aug 2013 at 4:05