source: trunk/slurm_drmaa/job.c @ 29

Revision 29, 18.9 KB checked in by mmamonski, 12 years ago (diff)

bump version, avoid segault on missing jobs

  • Property svn:executable set to *
  • Property svn:keywords set to Id
RevLine 
[5]1/* $Id$ */
[1]2/*
3 * PSNC DRMAA for SLURM
[13]4 * Copyright (C) 2011 Poznan Supercomputing and Networking Center
[1]5 *
6 *  This program is free software: you can redistribute it and/or modify
7 *  it under the terms of the GNU General Public License as published by
8 *  the Free Software Foundation, either version 3 of the License, or
9 *  (at your option) any later version.
10 *
11 *  This program is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 *  GNU General Public License for more details.
15 *
16 *  You should have received a copy of the GNU General Public License
17 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19#include <string.h>
20#include <stdlib.h>
21#include <unistd.h>
22#include <signal.h>
23
24#include <drmaa_utils/common.h>
25#include <drmaa_utils/conf.h>
26#include <drmaa_utils/datetime.h>
27#include <drmaa_utils/drmaa.h>
28#include <drmaa_utils/drmaa_util.h>
29#include <drmaa_utils/environ.h>
30#include <drmaa_utils/template.h>
31
32#include <slurm_drmaa/job.h>
33#include <slurm_drmaa/session.h>
34#include <slurm_drmaa/util.h>
35
36#include <slurm/slurm.h>
37#include <stdint.h>
38
39static void
40slurmdrmaa_job_control( fsd_job_t *self, int action )
41{
42        slurmdrmaa_job_t *slurm_self = (slurmdrmaa_job_t*)self;
43        job_desc_msg_t job_desc;
44
45        fsd_log_enter(( "({job_id=%s}, action=%d)", self->job_id, action ));
46
47        fsd_mutex_lock( &self->session->drm_connection_mutex );
48        TRY
49         {
50                switch( action )
51                 {
52                        case DRMAA_CONTROL_SUSPEND:
53                                if(slurm_suspend(fsd_atoi(self->job_id)) == -1) {
54                                        fsd_exc_raise_fmt(      FSD_ERRNO_INTERNAL_ERROR,"slurm_suspend error: %s,job_id: %s",slurm_strerror(slurm_get_errno()),self->job_id);
55                                }
[7]56                                slurm_self->user_suspended = true;
[1]57                                break;
58                        case DRMAA_CONTROL_HOLD:
59                                /* change priority to 0*/
60                                slurm_init_job_desc_msg(&job_desc);
61                                slurm_self->old_priority = job_desc.priority;
62                                job_desc.job_id = atoi(self->job_id);
63                                job_desc.priority = 0;
[13]64                                job_desc.alloc_sid = 0;
[1]65                                if(slurm_update_job(&job_desc) == -1) {
66                                        fsd_exc_raise_fmt(      FSD_ERRNO_INTERNAL_ERROR,"slurm_update_job error: %s,job_id: %s",slurm_strerror(slurm_get_errno()),self->job_id);
67                                }
68                                break;
69                        case DRMAA_CONTROL_RESUME:
70                                if(slurm_resume(fsd_atoi(self->job_id)) == -1) {
71                                        fsd_exc_raise_fmt(      FSD_ERRNO_INTERNAL_ERROR,"slurm_resume error: %s,job_id: %s",slurm_strerror(slurm_get_errno()),self->job_id);
72                                }
[7]73                                slurm_self->user_suspended = false;
[1]74                                break;
75                        case DRMAA_CONTROL_RELEASE:
76                          /* change priority back*/
77                                slurm_init_job_desc_msg(&job_desc);
78                                job_desc.priority = 1;
79                                job_desc.job_id = atoi(self->job_id);
80                                if(slurm_update_job(&job_desc) == -1) {
81                                        fsd_exc_raise_fmt(      FSD_ERRNO_INTERNAL_ERROR,"slurm_update_job error: %s,job_id: %s",slurm_strerror(slurm_get_errno()),self->job_id);
82                                }
83                                break;
84                        case DRMAA_CONTROL_TERMINATE:
85                                if(slurm_kill_job(fsd_atoi(self->job_id),SIGKILL,0) == -1) {
86                                        fsd_exc_raise_fmt(      FSD_ERRNO_INTERNAL_ERROR,"slurm_terminate_job error: %s,job_id: %s",slurm_strerror(slurm_get_errno()),self->job_id);
87                                }
88                                break;
89                        default:
90                                fsd_exc_raise_fmt(
91                                                FSD_ERRNO_INVALID_ARGUMENT,
92                                                "job::control: unknown action %d", action );
93                 }
94                                       
95                fsd_log_debug(("job::control: successful"));
96         }
97        FINALLY
98         {
99                fsd_mutex_unlock( &self->session->drm_connection_mutex );
100         }
101        END_TRY
102
103        fsd_log_return(( "" ));
104}
105
106
107static void
108slurmdrmaa_job_update_status( fsd_job_t *self )
109{
110        job_info_msg_t *job_info = NULL;
[7]111        slurmdrmaa_job_t * slurm_self = (slurmdrmaa_job_t *) self;
[1]112        fsd_log_enter(( "({job_id=%s})", self->job_id ));
113
114        fsd_mutex_lock( &self->session->drm_connection_mutex );
115        TRY
116        {
117                if ( slurm_load_job( &job_info, fsd_atoi(self->job_id), SHOW_ALL) ) {
[27]118                        int _slurm_errno = slurm_get_errno();
119
120                        if (_slurm_errno == ESLURM_INVALID_JOB_ID) {
121                                self->on_missing(self);
122                        } else {
[29]123                                fsd_exc_raise_fmt(FSD_ERRNO_INTERNAL_ERROR,"slurm_load_jobs error: %s,job_id: %s", slurm_strerror(slurm_get_errno()), self->job_id);
[27]124                        }
125                }
[29]126                if (job_info) {
[27]127                        fsd_log_debug(("state = %d, state_reason = %d", job_info->job_array[0].job_state, job_info->job_array[0].state_reason));
[29]128                       
129                        switch(job_info->job_array[0].job_state & JOB_STATE_BASE)
130                        {
[1]131
[29]132                                case JOB_PENDING:
133                                        switch(job_info->job_array[0].state_reason)
134                                        {
135                                                #if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,2,0)
136                                                case WAIT_HELD_USER:   /* job is held by user */
137                                                        fsd_log_debug(("interpreting as DRMAA_PS_USER_ON_HOLD"));
138                                                        self->state = DRMAA_PS_USER_ON_HOLD;
139                                                        break;
140                                                #endif
141                                                case WAIT_HELD:  /* job is held by administrator */
142                                                        fsd_log_debug(("interpreting as DRMAA_PS_SYSTEM_ON_HOLD"));
143                                                        self->state = DRMAA_PS_SYSTEM_ON_HOLD;
144                                                        break;
145                                                default:
146                                                        fsd_log_debug(("interpreting as DRMAA_PS_QUEUED_ACTIVE"));
147                                                        self->state = DRMAA_PS_QUEUED_ACTIVE;
148                                        }
149                                        break;
150                                case JOB_RUNNING:
151                                        fsd_log_debug(("interpreting as DRMAA_PS_RUNNING"));
152                                        self->state = DRMAA_PS_RUNNING;
153                                        break;
154                                case JOB_SUSPENDED:
155                                        if(slurm_self->user_suspended == true) {
156                                                fsd_log_debug(("interpreting as DRMAA_PS_USER_SUSPENDED"));
157                                                self->state = DRMAA_PS_USER_SUSPENDED;
158                                        } else {
159                                                fsd_log_debug(("interpreting as DRMAA_PS_SYSTEM_SUSPENDED"));
160                                                self->state = DRMAA_PS_SYSTEM_SUSPENDED;
161                                        }
162                                        break;
163                                case JOB_COMPLETE:
164                                        fsd_log_debug(("interpreting as DRMAA_PS_DONE"));
165                                        self->state = DRMAA_PS_DONE;
166                                        self->exit_status = job_info->job_array[0].exit_code;
167                                        fsd_log_debug(("exit_status = %d -> %d",self->exit_status, WEXITSTATUS(self->exit_status)));
168                                        break;
169                                case JOB_CANCELLED:
170                                        fsd_log_debug(("interpreting as DRMAA_PS_FAILED (aborted)"));
171                                        self->state = DRMAA_PS_FAILED;
172                                        self->exit_status = -1;
173                                case JOB_FAILED:
174                                case JOB_TIMEOUT:
175                                case JOB_NODE_FAIL:
176                                #if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,3,0)
177                                case JOB_PREEMPTED:
178                                #endif
179                                        fsd_log_debug(("interpreting as DRMAA_PS_FAILED"));
180                                        self->state = DRMAA_PS_FAILED;
181                                        self->exit_status = job_info->job_array[0].exit_code;
182                                        fsd_log_debug(("exit_status = %d -> %d",self->exit_status, WEXITSTATUS(self->exit_status)));
183                                        break;
184                                default: /*unknown state */
185                                        fsd_log_error(("Unknown job state: %d. Please send bug report: http://apps.man.poznan.pl/trac/slurm-drmaa", job_info->job_array[0].job_state));
186                        }
[1]187
[29]188                        if (job_info->job_array[0].job_state & JOB_STATE_FLAGS & JOB_COMPLETING) {
189                                fsd_log_debug(("Epilog completing"));
190                        }
[27]191
[29]192                        if (job_info->job_array[0].job_state & JOB_STATE_FLAGS & JOB_CONFIGURING) {
193                                fsd_log_debug(("Nodes booting"));
194                        }
[27]195
[29]196                        if (self->exit_status == -1) /* input,output,error path failure etc*/
197                                self->state = DRMAA_PS_FAILED;
[1]198
[29]199                        self->last_update_time = time(NULL);
200               
201                        if( self->state >= DRMAA_PS_DONE ) {
202                                fsd_log_debug(("exit_status = %d, WEXITSTATUS(exit_status) = %d", self->exit_status, WEXITSTATUS(self->exit_status)));
203                                fsd_cond_broadcast( &self->status_cond );
204                        }
[27]205                }
[1]206        }
207        FINALLY
208        {
209                if(job_info != NULL)
210                        slurm_free_job_info_msg (job_info);
211
212                fsd_mutex_unlock( &self->session->drm_connection_mutex );
213        }
214        END_TRY
215       
216        fsd_log_return(( "" ));
217}
218
[27]219static void
220slurmdrmaa_job_on_missing( fsd_job_t *self )
221{
222
223        fsd_log_enter(( "({job_id=%s})", self->job_id ));
224        fsd_log_warning(( "Job %s missing from DRM queue", self->job_id ));
225
226        fsd_log_info(( "job_on_missing: last job_ps: %s (0x%02x)", drmaa_job_ps_to_str(self->state), self->state));
227
228        if( self->state >= DRMAA_PS_RUNNING ) { /*if the job ever entered running state assume finished */
229                self->state = DRMAA_PS_DONE;
230                self->exit_status = 0;
231        }
232        else {
233                self->state = DRMAA_PS_FAILED; /* otherwise failed */
234                self->exit_status = -1;
235        }
236
237        fsd_log_info(("job_on_missing evaluation result: state=%d exit_status=%d", self->state, self->exit_status));
238
239        fsd_cond_broadcast( &self->status_cond);
240        fsd_cond_broadcast( &self->session->wait_condition );
241
242        fsd_log_return(( "; job_ps=%s, exit_status=%d", drmaa_job_ps_to_str(self->state), self->exit_status ));
243}
244
[1]245fsd_job_t *
246slurmdrmaa_job_new( char *job_id )
247{
248        slurmdrmaa_job_t *self = NULL;
249        self = (slurmdrmaa_job_t*)fsd_job_new( job_id );
250
251        fsd_realloc( self, 1, slurmdrmaa_job_t );
252
253        self->super.control = slurmdrmaa_job_control;
254        self->super.update_status = slurmdrmaa_job_update_status;
[27]255        self->super.on_missing = slurmdrmaa_job_on_missing;
[1]256        self->old_priority = UINT32_MAX;
[7]257        self->user_suspended = true;
[1]258        return (fsd_job_t*)self;
259}
260
261
262void
263slurmdrmaa_job_create_req(
264                fsd_drmaa_session_t *session,
265                const fsd_template_t *jt,
266                fsd_environ_t **envp,
267                job_desc_msg_t * job_desc,
268                int n_job /* ~job_step */
269                )
270{
271        fsd_expand_drmaa_ph_t *volatile expand = NULL;
272
273        TRY
274         {
275                expand = fsd_expand_drmaa_ph_new( NULL, NULL, fsd_asprintf("%d",n_job) );
276                slurmdrmaa_job_create( session, jt, envp, expand, job_desc, n_job);
277         }
278        EXCEPT_DEFAULT
279         {
280                fsd_exc_reraise();
281         }
282        FINALLY
283         {
284                if( expand )
285                        expand->destroy( expand );
286         }
287        END_TRY
288}
289
290static char *
291internal_map_file( fsd_expand_drmaa_ph_t *expand, const char *path,
292                bool *host_given, const char *name )
293{
294        const char *p;
295
296        for( p = path;  *p != ':';  p++ )
297                if( *p == '\0' )
298                        fsd_exc_raise_fmt( FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_FORMAT,
299                                                        "invalid format of drmaa_%s_path: missing colon", name );
300        if( host_given )
301                *host_given = ( p != path );
302
303        p++;
304
305        return expand->expand( expand, fsd_strdup(p), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD | FSD_DRMAA_PH_INCR );
306}
307
308void
309slurmdrmaa_job_create(
310                fsd_drmaa_session_t *session,
311                const fsd_template_t *jt,
312                fsd_environ_t **envp,
313                fsd_expand_drmaa_ph_t *expand,
314                job_desc_msg_t * job_desc,
315                int n_job
316                )
317{
318        const char *input_path_orig = NULL;
319        const char *output_path_orig = NULL;
320        const char *error_path_orig = NULL;
321        char *volatile input_path = NULL;
322        char *volatile output_path = NULL;
323        char *volatile error_path = NULL;
324        bool input_host = false;
325        bool output_host = false;
326        bool error_host = false;
327        bool join_files = false;
328        const char *value;
329        const char *const *vector;
330        const char *job_category = "default";
331       
332        slurmdrmaa_init_job_desc( job_desc );
333
334        slurm_init_job_desc_msg( job_desc );
335       
336        job_desc->user_id = getuid();
337        job_desc->group_id = getgid();
338
339        job_desc->env_size = 0;
340       
341        /* job name */
342        value = jt->get_attr( jt, DRMAA_JOB_NAME );
343        if( value )
344        {
345                job_desc->name = fsd_strdup(value);
346                fsd_log_debug(("# job_name = %s",job_desc->name));
347        }
348       
349        /* job state at submit */
350        value = jt->get_attr( jt, DRMAA_JS_STATE );
351        if( value )
352        {
353                if( 0 == strcmp( value, DRMAA_SUBMISSION_STATE_ACTIVE ) )
354                {}
355                else if( 0 == strcmp( value, DRMAA_SUBMISSION_STATE_HOLD ) )
356                {
357                        job_desc->priority = 0;
358                        fsd_log_debug(("# hold = user"));
359                }
360                else
361                {
362                        fsd_exc_raise_msg(FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE, "invalid value of drmaa_js_state attribute" );
363                }
364        }
365       
366        TRY
367        {
368                const char *command = NULL;
369                char *command_expanded = NULL;
370                char *temp_script_old = NULL;
371                char *temp_script = "";
372                const char *const *i;
373                int j;
374
375                /* remote command */
376                command = jt->get_attr( jt, DRMAA_REMOTE_COMMAND );
377                if( command == NULL )
378                        fsd_exc_raise_msg(
379                                        FSD_DRMAA_ERRNO_CONFLICTING_ATTRIBUTE_VALUES,
380                                        "drmaa_remote_command not set for job template"
381                                        );
382
383                command_expanded = expand->expand( expand, fsd_strdup(command), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD );
384
385                temp_script = fsd_asprintf("#!/bin/bash\n%s",command_expanded);
386                fsd_free(command_expanded);
387
388                /* arguments list */
389                vector = jt->get_v_attr( jt, DRMAA_V_ARGV );
390
391                if( vector )
392                {
393                        for( i = vector, j = 2;  *i;  i++, j++ )
394                        {
395                                char *arg_expanded = expand->expand( expand, fsd_strdup(*i), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD );
396                               
397                                temp_script_old = fsd_strdup(temp_script);
398                               
399                                if (strcmp(temp_script, "") != 0) {
400                                        fsd_free(temp_script);
401                                }
402                                /* add too script */
403                                temp_script = fsd_asprintf("%s '%s'", temp_script_old, arg_expanded);
404                                fsd_free(temp_script_old);
405                                fsd_free(arg_expanded);
406                        }
407                }
408               
409                job_desc->script = fsd_asprintf("%s\n", temp_script);
410                fsd_log_debug(("# Script:\n%s", job_desc->script));
411                fsd_free(temp_script);
412        }
413        END_TRY
414       
415
416        /* start time */
417        value = jt->get_attr( jt, DRMAA_START_TIME );
418        if( value )
419        {
420                job_desc->begin_time = fsd_datetime_parse( value );
421                fsd_log_debug(( "\n  drmaa_start_time: %s -> %ld", value, (long)job_desc->begin_time));
422        }
423
[27]424        /*  propagate all environment variables from submission host */
425        {
[17]426                extern char **environ;
[27]427                char **i;
428                unsigned j = 0;
[17]429
[27]430                for ( i = environ; *i; i++) {
431                        job_desc->env_size++;
432                }
[17]433               
434                fsd_log_debug(("environ env_size = %d",job_desc->env_size));
435                fsd_calloc(job_desc->environment, job_desc->env_size+1, char *);
436               
[27]437                for ( i = environ; *i; i++,j++ ) {
438                        job_desc->environment[j] = fsd_strdup(*i);
439                }
440        }
[17]441
[1]442        /* environment */
[17]443       
[1]444        vector = jt->get_v_attr( jt, DRMAA_V_ENV );
445        if( vector )
446        {
447                const char *const *i;
448                unsigned j = 0;
[17]449                unsigned env_offset = job_desc->env_size;
[1]450
451                for( i = vector;  *i;  i++ )
452                {
453                        job_desc->env_size++;
454                }
[17]455                fsd_log_debug(("jt env_size = %d",job_desc->env_size));
[1]456
457                fsd_log_debug(("# environment ="));
[17]458                fsd_realloc(job_desc->environment, job_desc->env_size+1, char *);
[1]459
460                for( i = vector;  *i;  i++,j++ )
461                {
[17]462                        job_desc->environment[j + env_offset] = fsd_strdup(*i);
463                        fsd_log_debug((" %s", job_desc->environment[j+ env_offset]));
[1]464                }
465         }
466       
467        /* wall clock time hard limit */
468        value = jt->get_attr( jt, DRMAA_WCT_HLIMIT );
469        if (value)
470        {
471                job_desc->time_limit = slurmdrmaa_datetime_parse( value );
[17]472                fsd_log_debug(("# wct_hlimit = %s -> %ld",value, (long int)slurmdrmaa_datetime_parse( value )));
[1]473        }
474
475               
476        /*expand->set(expand, FSD_DRMAA_PH_INCR,fsd_asprintf("%d", n_job));*/ /* set current value */
477        /* TODO: test drmaa_ph_incr */
478        /* job working directory */
479        value = jt->get_attr( jt, DRMAA_WD );
480        if( value )
481        {
482                char *cwd_expanded = expand->expand( expand, fsd_strdup(value), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_INCR );
483
484                expand->set( expand, FSD_DRMAA_PH_WD, fsd_strdup(cwd_expanded));
485
486                fsd_log_debug(("# work_dir = %s",cwd_expanded));
487                job_desc->work_dir = fsd_strdup(cwd_expanded);
488                fsd_free(cwd_expanded);
489        }
490        else
491        {
492                char cwdbuf[4096] = "";
493
494                if ((getcwd(cwdbuf, 4095)) == NULL) {
495                        char errbuf[256] = "InternalError";
496                        (void)strerror_r(errno, errbuf, 256); /*on error the default message would be returned */
497                        fsd_log_error(("getcwd failed: %s", errbuf));
498                        job_desc->work_dir = fsd_strdup(".");
499                } else {
500                        job_desc->work_dir = fsd_strdup(cwdbuf);
501                }
502
503                fsd_log_debug(("work_dir(default:CWD) %s", job_desc->work_dir));
504        }
505
506        TRY
507        {
508                /* input path */
509                input_path_orig = jt->get_attr( jt, DRMAA_INPUT_PATH );
510                if( input_path_orig )
511                {
512                        input_path = internal_map_file( expand, input_path_orig, &input_host,"input" );
513                        fsd_log_debug(( "\n  drmaa_input_path: %s -> %s", input_path_orig, input_path ));
514                }
515
516                /* output path */
517                output_path_orig = jt->get_attr( jt, DRMAA_OUTPUT_PATH );
518                if( output_path_orig )
519                {
520                        output_path = internal_map_file( expand, output_path_orig, &output_host,"output" );
521                        fsd_log_debug(( "\n  drmaa_output_path: %s -> %s", output_path_orig, output_path ));
522                }
523
524                /* error path */
525                error_path_orig = jt->get_attr( jt, DRMAA_ERROR_PATH );
526                if( error_path_orig )
527                {
528                        error_path = internal_map_file( expand, error_path_orig, &error_host,"error" );
529                        fsd_log_debug(( "\n  drmaa_error_path: %s -> %s", error_path_orig, error_path ));
530                }
531
532                /* join files */
533                value = jt->get_attr( jt, DRMAA_JOIN_FILES );
534                if( value )
535                {
536                        if( (value[0] == 'y' || value[0] == 'Y')  &&  value[1] == '\0' )
537                                join_files = true;
538                        else if( (value[0] == 'n' || value[0] == 'N')  &&  value[1] == '\0' )
539                                join_files = false;
540                        else
541                                fsd_exc_raise_msg(
542                                                FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,
543                                                "invalid value of drmaa_join_files attribute" );
544                }
545
546                if( join_files )
547                {
548                        if( output_path == NULL )
549                                fsd_exc_raise_msg(FSD_DRMAA_ERRNO_CONFLICTING_ATTRIBUTE_VALUES, "drmaa_join_files is set and output file is not given" );
550                        if( error_path!=NULL && 0 != strcmp( output_path, error_path ) )
551                                fsd_log_warning(( "Error file was given but will be ignored since drmaa_join_files was set." ));
552
553                        if (error_path)
554                                fsd_free(error_path);
555
556                         error_path = fsd_strdup(output_path);
557                }
558                else
559                {
560                        if( error_path == NULL  &&  output_path )
561                                error_path = fsd_strdup( "/dev/null" );
562                        if( output_path == NULL  &&  error_path )
563                                output_path = fsd_strdup( "/dev/null" );
564                }
565
566
567                /* email addresses to send notifications */
568                vector = jt->get_v_attr( jt, DRMAA_V_EMAIL );
569                if( vector  &&  vector[0] )
570                {
571                        /* only to one email address message may be send */
572                        job_desc->mail_user = fsd_strdup(vector[0]);
[25]573                        job_desc->mail_type = MAIL_JOB_BEGIN | MAIL_JOB_END |  MAIL_JOB_FAIL;
[1]574                        fsd_log_debug(("# mail_user = %s\n",vector[0]));
[25]575                        fsd_log_debug(("# mail_type = %o\n",job_desc->mail_type));
[1]576                        if( vector[1] != NULL )
577                        {
[25]578                                fsd_log_error(( "SLURM only supports one e-mail notification address" ));
579                                fsd_exc_raise_msg(FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,"SLURM only supports one e-mail notification address");
[1]580                        }
581                }
582
583                /* block email */
584                value = jt->get_attr( jt, DRMAA_BLOCK_EMAIL );
585                if( value )
586                {
587                        bool block;
588                        if( strcmp(value, "0") == 0 )
589                        {
590                                block = true;
591                                fsd_log_debug(("# block_email = true"));
592                                fsd_log_debug(("# mail_user delated"));
593                                fsd_free(job_desc->mail_user);
594                                job_desc->mail_user = NULL;
595                        }
596                        else if( strcmp(value, "1") == 0 )
597                                block = false;
598                        else
599                                fsd_exc_raise_msg(FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,"invalid value of drmaa_block_email attribute" );
600
601                        if( block && output_path == NULL )
602                        {
603                                fsd_log_debug(( "output path not set and we want to block e-mail, set to /dev/null" ));
604                                output_path = fsd_strdup( "/dev/null" );
605                        }
606                }
607
608                if( input_path )
609                {
610                        job_desc->std_in = fsd_strdup(input_path);
611                        fsd_log_debug(("# input = %s", input_path));
612                }
613
614                if( output_path )
615                {
616                        job_desc->std_out = fsd_strdup(output_path);
617                        fsd_log_debug(("# output = %s", output_path));
618                }
619
620                if( error_path )
621                {
622                        job_desc->std_err = fsd_strdup(error_path);
623                        fsd_log_debug(("# error = %s", error_path));
624                }
625         }
626        FINALLY
627        {
628                fsd_free( input_path );
629                fsd_free( output_path );
630                fsd_free( error_path );
631                input_path = NULL;
632                output_path = NULL;
633                error_path = NULL;
634        }
635        END_TRY                 
636       
637        /* native specification */
638        value = jt->get_attr( jt, DRMAA_NATIVE_SPECIFICATION );
639        if( value )
640        {
641                fsd_log_debug(("# Native specification: %s\n", value));
642                slurmdrmaa_parse_native(job_desc, value);
643        }
644               
645        /* job category */
646        value = jt->get_attr( jt, DRMAA_JOB_CATEGORY );
647        if( value )
648                job_category = value;
649
650        {
651                fsd_conf_option_t *category_value = NULL;
652                category_value = fsd_conf_dict_get( session->job_categories, job_category );
653
654                if( category_value != NULL )
655                {
656                        if( category_value->type != FSD_CONF_STRING )
657                                fsd_exc_raise_fmt(
658                                                FSD_ERRNO_INTERNAL_ERROR,
659                                                "configuration error: job category should be string"
660                                                );
661
662                        fsd_log_debug(("# Job category %s : %s\n",value,category_value->val.string));                   
663                        slurmdrmaa_parse_native(job_desc,category_value->val.string);                   
664                }
665                else
666                {
667                        if( value != NULL )
668                                fsd_exc_raise_fmt(
669                                                FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,
670                                                "invalid job category: %s", job_category
671                                                );
672                }
673        }
674       
675}               
676
[27]677
Note: See TracBrowser for help on using the repository browser.