source: trunk/slurm_drmaa/job.c @ 26

Revision 26, 19.8 KB checked in by mmamonski, 12 years ago (diff)

ifdef WAIT_FRONT_END

  • Property svn:executable set to *
  • Property svn:keywords set to Id
Line 
1/* $Id$ */
2/*
3 * PSNC DRMAA for SLURM
4 * Copyright (C) 2011 Poznan Supercomputing and Networking Center
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                                }
56                                slurm_self->user_suspended = true;
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;
64                                job_desc.alloc_sid = 0;
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                                }
73                                slurm_self->user_suspended = false;
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;
111        slurmdrmaa_job_t * slurm_self = (slurmdrmaa_job_t *) self;
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) ) {
118                        fsd_exc_raise_fmt(      FSD_ERRNO_INTERNAL_ERROR,"slurm_load_jobs error: %s,job_id: %s",slurm_strerror(slurm_get_errno()),self->job_id);
119        }
120               
121                self->exit_status = job_info->job_array[0].exit_code;
122                fsd_log_debug(("exit_status = %d -> %d",self->exit_status, WEXITSTATUS(self->exit_status)));
123
124                switch(job_info->job_array[0].job_state)
125                {
126                        case JOB_PENDING:
127                                switch(job_info->job_array[0].state_reason)
128                                {
129                                        case WAIT_NO_REASON:   /* not set or job not pending */
130                                        case WAIT_PRIORITY:    /* higher priority jobs exist */
131                                        case WAIT_DEPENDENCY:  /* dependent job has not completed */
132                                        case WAIT_RESOURCES:   /* required resources not available */
133                                        case WAIT_PART_NODE_LIMIT:   /* request exceeds partition node limit */
134                                        case WAIT_PART_TIME_LIMIT:   /* request exceeds partition time limit */
135                                        #if SLURM_VERSION_NUMBER < SLURM_VERSION_NUM(2,2,0)
136                                        case WAIT_PART_STATE:
137                                        #endif
138                                        #if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,2,0)
139                                        case WAIT_PART_DOWN:   /* requested partition is down */
140                                        case WAIT_PART_INACTIVE:  /* requested partition is inactive */
141                                        #endif
142                                                self->state = DRMAA_PS_QUEUED_ACTIVE;
143                                                break;
144                                        #if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,2,0)
145                                        case WAIT_HELD_USER:   /* job is held by user */
146                                       
147                                                self->state = DRMAA_PS_USER_ON_HOLD;
148                                                break;
149                                        case WAIT_HELD:  /* job is held by administrator */
150                                                self->state = DRMAA_PS_SYSTEM_ON_HOLD;
151                                                break;
152                                        #else
153                                        case WAIT_HELD: 
154                                                self->state = DRMAA_PS_USER_ON_HOLD;
155                                                break;
156                                        #endif
157                                        case WAIT_TIME:  /* job waiting for specific begin time */
158                                        case WAIT_LICENSES:  /* job is waiting for licenses */
159                                        case WAIT_ASSOC_JOB_LIMIT:  /* user/bank job limit reached */
160                                        case WAIT_ASSOC_RESOURCE_LIMIT:  /* user/bank resource limit reached */
161                                        case WAIT_ASSOC_TIME_LIMIT:  /* user/bank time limit reached */
162                                        case WAIT_RESERVATION:    /* reservation not available */
163                                        case WAIT_NODE_NOT_AVAIL:  /* required node is DOWN or DRAINED */
164                                        #if SLURM_VERSION_NUMBER < SLURM_VERSION_NUM(2,2,0)
165                                        case WAIT_TBD1:
166                                        #else
167                                        case WAIT_QOS_THRES:       /* required QOS threshold has been reached */
168                                        #endif                                 
169                                        #if SLURM_VERSION_NUMBER < SLURM_VERSION_NUM(2,3,0)
170                                        case WAIT_TBD2:
171                                        #else
172                                        #ifdef WAIT_FRONT_END
173                                        case WAIT_FRONT_END: /* Front end nodes are DOWN */
174                                        #endif
175                                        case WAIT_QOS_JOB_LIMIT: /* QOS job limit reached */   
176                                        case WAIT_QOS_RESOURCE_LIMIT: /* QOS resource limit reached */
177                                        case WAIT_QOS_TIME_LIMIT: /*  QOS time limit reached */
178                                        #endif
179                                                self->state = DRMAA_PS_QUEUED_ACTIVE;
180                                                break;
181                                        case FAIL_DOWN_PARTITION:  /* partition for job is DOWN */
182                                        case FAIL_DOWN_NODE:       /* some node in the allocation failed */
183                                        case FAIL_BAD_CONSTRAINTS: /* constraints can not be satisfied */
184                                        case FAIL_SYSTEM:          /* slurm system failure */
185                                        case FAIL_LAUNCH:          /* unable to launch job */
186                                        case FAIL_EXIT_CODE:       /* exit code was non-zero */
187                                        case FAIL_TIMEOUT:         /* reached end of time limit */
188                                        case FAIL_INACTIVE_LIMIT:  /* reached slurm InactiveLimit */
189                                        #if SLURM_VERSION_NUMBER < SLURM_VERSION_NUM(2,2,0)
190                                        case FAIL_BANK_ACCOUNT:
191                                        #else
192                                        case FAIL_ACCOUNT:         /* invalid account */
193                                        case FAIL_QOS:             /* invalid QOS */
194                                        #endif
195                                                self->state = DRMAA_PS_FAILED;
196                                                break;
197                                        default:
198                                                fsd_log_error(("job_state_reason = %d, assert(0)",job_info->job_array[0].state_reason));
199                                                fsd_assert(false);
200       
201                                }
202                                break;
203                        case JOB_RUNNING:
204                                self->state = DRMAA_PS_RUNNING;
205                                break;
206                        case JOB_SUSPENDED:
207                                if(slurm_self->user_suspended == true)
208                                        self->state = DRMAA_PS_USER_SUSPENDED;
209                                else
210                                        self->state = DRMAA_PS_SYSTEM_SUSPENDED; /* assume SYSTEM - suspendig jobs is administrator only */
211                                break;
212                        case JOB_COMPLETE:
213                                self->state = DRMAA_PS_DONE;
214                                break;
215                        case JOB_CANCELLED:
216                                self->exit_status = -1;
217                        case JOB_FAILED:
218                        case JOB_TIMEOUT:
219                        case JOB_NODE_FAIL:
220                                self->state = DRMAA_PS_FAILED;
221                                break;
222                        default: /*transient states */
223                                if(job_info->job_array[0].job_state >= 0x8000) {
224                                        fsd_log_debug(("state COMPLETING"));
225                                }
226                                else if (job_info->job_array[0].job_state >= 0x4000) {
227                                        fsd_log_debug(("state Allocated nodes booting"));
228                                }
229                                else {
230                                        fsd_log_error(("job_state = %d, assert(0)",job_info->job_array[0].job_state));
231                                        fsd_assert(false);
232                                }
233                }
234
235                if(self->exit_status == -1) /* input,output,error path failure etc*/
236                        self->state = DRMAA_PS_FAILED;
237
238                fsd_log_debug(("state: %d ,state_reason: %d-> %s", job_info->job_array[0].job_state, job_info->job_array[0].state_reason, drmaa_job_ps_to_str(self->state)));
239
240                self->last_update_time = time(NULL);
241       
242                if( self->state >= DRMAA_PS_DONE )
243                        fsd_cond_broadcast( &self->status_cond );
244        }
245        FINALLY
246        {
247                if(job_info != NULL)
248                        slurm_free_job_info_msg (job_info);
249
250                fsd_mutex_unlock( &self->session->drm_connection_mutex );
251        }
252        END_TRY
253       
254        fsd_log_return(( "" ));
255}
256
257fsd_job_t *
258slurmdrmaa_job_new( char *job_id )
259{
260        slurmdrmaa_job_t *self = NULL;
261        self = (slurmdrmaa_job_t*)fsd_job_new( job_id );
262
263        fsd_realloc( self, 1, slurmdrmaa_job_t );
264
265        self->super.control = slurmdrmaa_job_control;
266        self->super.update_status = slurmdrmaa_job_update_status;
267        self->old_priority = UINT32_MAX;
268        self->user_suspended = true;
269        return (fsd_job_t*)self;
270}
271
272
273void
274slurmdrmaa_job_create_req(
275                fsd_drmaa_session_t *session,
276                const fsd_template_t *jt,
277                fsd_environ_t **envp,
278                job_desc_msg_t * job_desc,
279                int n_job /* ~job_step */
280                )
281{
282        fsd_expand_drmaa_ph_t *volatile expand = NULL;
283
284        TRY
285         {
286                expand = fsd_expand_drmaa_ph_new( NULL, NULL, fsd_asprintf("%d",n_job) );
287                slurmdrmaa_job_create( session, jt, envp, expand, job_desc, n_job);
288         }
289        EXCEPT_DEFAULT
290         {
291                fsd_exc_reraise();
292         }
293        FINALLY
294         {
295                if( expand )
296                        expand->destroy( expand );
297         }
298        END_TRY
299}
300
301static char *
302internal_map_file( fsd_expand_drmaa_ph_t *expand, const char *path,
303                bool *host_given, const char *name )
304{
305        const char *p;
306
307        for( p = path;  *p != ':';  p++ )
308                if( *p == '\0' )
309                        fsd_exc_raise_fmt( FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_FORMAT,
310                                                        "invalid format of drmaa_%s_path: missing colon", name );
311        if( host_given )
312                *host_given = ( p != path );
313
314        p++;
315
316        return expand->expand( expand, fsd_strdup(p), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD | FSD_DRMAA_PH_INCR );
317}
318
319void
320slurmdrmaa_job_create(
321                fsd_drmaa_session_t *session,
322                const fsd_template_t *jt,
323                fsd_environ_t **envp,
324                fsd_expand_drmaa_ph_t *expand,
325                job_desc_msg_t * job_desc,
326                int n_job
327                )
328{
329        const char *input_path_orig = NULL;
330        const char *output_path_orig = NULL;
331        const char *error_path_orig = NULL;
332        char *volatile input_path = NULL;
333        char *volatile output_path = NULL;
334        char *volatile error_path = NULL;
335        bool input_host = false;
336        bool output_host = false;
337        bool error_host = false;
338        bool join_files = false;
339        const char *value;
340        const char *const *vector;
341        const char *job_category = "default";
342       
343        slurmdrmaa_init_job_desc( job_desc );
344
345        slurm_init_job_desc_msg( job_desc );
346       
347        job_desc->user_id = getuid();
348        job_desc->group_id = getgid();
349
350        job_desc->env_size = 0;
351       
352        /* job name */
353        value = jt->get_attr( jt, DRMAA_JOB_NAME );
354        if( value )
355        {
356                job_desc->name = fsd_strdup(value);
357                fsd_log_debug(("# job_name = %s",job_desc->name));
358        }
359       
360        /* job state at submit */
361        value = jt->get_attr( jt, DRMAA_JS_STATE );
362        if( value )
363        {
364                if( 0 == strcmp( value, DRMAA_SUBMISSION_STATE_ACTIVE ) )
365                {}
366                else if( 0 == strcmp( value, DRMAA_SUBMISSION_STATE_HOLD ) )
367                {
368                        job_desc->priority = 0;
369                        fsd_log_debug(("# hold = user"));
370                }
371                else
372                {
373                        fsd_exc_raise_msg(FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE, "invalid value of drmaa_js_state attribute" );
374                }
375        }
376       
377        TRY
378        {
379                const char *command = NULL;
380                char *command_expanded = NULL;
381                char *temp_script_old = NULL;
382                char *temp_script = "";
383                const char *const *i;
384                int j;
385
386                /* remote command */
387                command = jt->get_attr( jt, DRMAA_REMOTE_COMMAND );
388                if( command == NULL )
389                        fsd_exc_raise_msg(
390                                        FSD_DRMAA_ERRNO_CONFLICTING_ATTRIBUTE_VALUES,
391                                        "drmaa_remote_command not set for job template"
392                                        );
393
394                command_expanded = expand->expand( expand, fsd_strdup(command), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD );
395
396                temp_script = fsd_asprintf("#!/bin/bash\n%s",command_expanded);
397                fsd_free(command_expanded);
398
399                /* arguments list */
400                vector = jt->get_v_attr( jt, DRMAA_V_ARGV );
401
402                if( vector )
403                {
404                        for( i = vector, j = 2;  *i;  i++, j++ )
405                        {
406                                char *arg_expanded = expand->expand( expand, fsd_strdup(*i), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD );
407                               
408                                temp_script_old = fsd_strdup(temp_script);
409                               
410                                if (strcmp(temp_script, "") != 0) {
411                                        fsd_free(temp_script);
412                                }
413                                /* add too script */
414                                temp_script = fsd_asprintf("%s '%s'", temp_script_old, arg_expanded);
415                                fsd_free(temp_script_old);
416                                fsd_free(arg_expanded);
417                        }
418                }
419               
420                job_desc->script = fsd_asprintf("%s\n", temp_script);
421                fsd_log_debug(("# Script:\n%s", job_desc->script));
422                fsd_free(temp_script);
423        }
424        END_TRY
425       
426
427        /* start time */
428        value = jt->get_attr( jt, DRMAA_START_TIME );
429        if( value )
430        {
431                job_desc->begin_time = fsd_datetime_parse( value );
432                fsd_log_debug(( "\n  drmaa_start_time: %s -> %ld", value, (long)job_desc->begin_time));
433        }
434
435        /*  propagate all environment variables from submission host */
436        {
437                extern char **environ;
438                char **i;
439                unsigned j = 0;
440
441                for ( i = environ; *i; i++) {
442                        job_desc->env_size++;
443                }
444               
445                fsd_log_debug(("environ env_size = %d",job_desc->env_size));
446                fsd_calloc(job_desc->environment, job_desc->env_size+1, char *);
447               
448                for( i = environ;  *i;  i++,j++ )
449                {
450                        job_desc->environment[j] = fsd_strdup(*i);
451                }
452
453        }
454
455        /* environment */
456       
457        vector = jt->get_v_attr( jt, DRMAA_V_ENV );
458        if( vector )
459        {
460                const char *const *i;
461                unsigned j = 0;
462                unsigned env_offset = job_desc->env_size;
463
464                for( i = vector;  *i;  i++ )
465                {
466                        job_desc->env_size++;
467                }
468                fsd_log_debug(("jt env_size = %d",job_desc->env_size));
469
470                fsd_log_debug(("# environment ="));
471                fsd_realloc(job_desc->environment, job_desc->env_size+1, char *);
472
473                for( i = vector;  *i;  i++,j++ )
474                {
475                        job_desc->environment[j + env_offset] = fsd_strdup(*i);
476                        fsd_log_debug((" %s", job_desc->environment[j+ env_offset]));
477                }
478         }
479       
480        /* wall clock time hard limit */
481        value = jt->get_attr( jt, DRMAA_WCT_HLIMIT );
482        if (value)
483        {
484                job_desc->time_limit = slurmdrmaa_datetime_parse( value );
485                fsd_log_debug(("# wct_hlimit = %s -> %ld",value, (long int)slurmdrmaa_datetime_parse( value )));
486        }
487
488               
489        /*expand->set(expand, FSD_DRMAA_PH_INCR,fsd_asprintf("%d", n_job));*/ /* set current value */
490        /* TODO: test drmaa_ph_incr */
491        /* job working directory */
492        value = jt->get_attr( jt, DRMAA_WD );
493        if( value )
494        {
495                char *cwd_expanded = expand->expand( expand, fsd_strdup(value), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_INCR );
496
497                expand->set( expand, FSD_DRMAA_PH_WD, fsd_strdup(cwd_expanded));
498
499                fsd_log_debug(("# work_dir = %s",cwd_expanded));
500                job_desc->work_dir = fsd_strdup(cwd_expanded);
501                fsd_free(cwd_expanded);
502        }
503        else
504        {
505                char cwdbuf[4096] = "";
506
507                if ((getcwd(cwdbuf, 4095)) == NULL) {
508                        char errbuf[256] = "InternalError";
509                        (void)strerror_r(errno, errbuf, 256); /*on error the default message would be returned */
510                        fsd_log_error(("getcwd failed: %s", errbuf));
511                        job_desc->work_dir = fsd_strdup(".");
512                } else {
513                        job_desc->work_dir = fsd_strdup(cwdbuf);
514                }
515
516                fsd_log_debug(("work_dir(default:CWD) %s", job_desc->work_dir));
517        }
518
519        TRY
520        {
521                /* input path */
522                input_path_orig = jt->get_attr( jt, DRMAA_INPUT_PATH );
523                if( input_path_orig )
524                {
525                        input_path = internal_map_file( expand, input_path_orig, &input_host,"input" );
526                        fsd_log_debug(( "\n  drmaa_input_path: %s -> %s", input_path_orig, input_path ));
527                }
528
529                /* output path */
530                output_path_orig = jt->get_attr( jt, DRMAA_OUTPUT_PATH );
531                if( output_path_orig )
532                {
533                        output_path = internal_map_file( expand, output_path_orig, &output_host,"output" );
534                        fsd_log_debug(( "\n  drmaa_output_path: %s -> %s", output_path_orig, output_path ));
535                }
536
537                /* error path */
538                error_path_orig = jt->get_attr( jt, DRMAA_ERROR_PATH );
539                if( error_path_orig )
540                {
541                        error_path = internal_map_file( expand, error_path_orig, &error_host,"error" );
542                        fsd_log_debug(( "\n  drmaa_error_path: %s -> %s", error_path_orig, error_path ));
543                }
544
545                /* join files */
546                value = jt->get_attr( jt, DRMAA_JOIN_FILES );
547                if( value )
548                {
549                        if( (value[0] == 'y' || value[0] == 'Y')  &&  value[1] == '\0' )
550                                join_files = true;
551                        else if( (value[0] == 'n' || value[0] == 'N')  &&  value[1] == '\0' )
552                                join_files = false;
553                        else
554                                fsd_exc_raise_msg(
555                                                FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,
556                                                "invalid value of drmaa_join_files attribute" );
557                }
558
559                if( join_files )
560                {
561                        if( output_path == NULL )
562                                fsd_exc_raise_msg(FSD_DRMAA_ERRNO_CONFLICTING_ATTRIBUTE_VALUES, "drmaa_join_files is set and output file is not given" );
563                        if( error_path!=NULL && 0 != strcmp( output_path, error_path ) )
564                                fsd_log_warning(( "Error file was given but will be ignored since drmaa_join_files was set." ));
565
566                        if (error_path)
567                                fsd_free(error_path);
568
569                         error_path = fsd_strdup(output_path);
570                }
571                else
572                {
573                        if( error_path == NULL  &&  output_path )
574                                error_path = fsd_strdup( "/dev/null" );
575                        if( output_path == NULL  &&  error_path )
576                                output_path = fsd_strdup( "/dev/null" );
577                }
578
579
580                /* email addresses to send notifications */
581                vector = jt->get_v_attr( jt, DRMAA_V_EMAIL );
582                if( vector  &&  vector[0] )
583                {
584                        /* only to one email address message may be send */
585                        job_desc->mail_user = fsd_strdup(vector[0]);
586                        job_desc->mail_type = MAIL_JOB_BEGIN | MAIL_JOB_END |  MAIL_JOB_FAIL;
587                        fsd_log_debug(("# mail_user = %s\n",vector[0]));
588                        fsd_log_debug(("# mail_type = %o\n",job_desc->mail_type));
589                        if( vector[1] != NULL )
590                        {
591                                fsd_log_error(( "SLURM only supports one e-mail notification address" ));
592                                fsd_exc_raise_msg(FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,"SLURM only supports one e-mail notification address");
593                        }
594                }
595
596                /* block email */
597                value = jt->get_attr( jt, DRMAA_BLOCK_EMAIL );
598                if( value )
599                {
600                        bool block;
601                        if( strcmp(value, "0") == 0 )
602                        {
603                                block = true;
604                                fsd_log_debug(("# block_email = true"));
605                                fsd_log_debug(("# mail_user delated"));
606                                fsd_free(job_desc->mail_user);
607                                job_desc->mail_user = NULL;
608                        }
609                        else if( strcmp(value, "1") == 0 )
610                                block = false;
611                        else
612                                fsd_exc_raise_msg(FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,"invalid value of drmaa_block_email attribute" );
613
614                        if( block && output_path == NULL )
615                        {
616                                fsd_log_debug(( "output path not set and we want to block e-mail, set to /dev/null" ));
617                                output_path = fsd_strdup( "/dev/null" );
618                        }
619                }
620
621                if( input_path )
622                {
623                        job_desc->std_in = fsd_strdup(input_path);
624                        fsd_log_debug(("# input = %s", input_path));
625                }
626
627                if( output_path )
628                {
629                        job_desc->std_out = fsd_strdup(output_path);
630                        fsd_log_debug(("# output = %s", output_path));
631                }
632
633                if( error_path )
634                {
635                        job_desc->std_err = fsd_strdup(error_path);
636                        fsd_log_debug(("# error = %s", error_path));
637                }
638         }
639        FINALLY
640        {
641                fsd_free( input_path );
642                fsd_free( output_path );
643                fsd_free( error_path );
644                input_path = NULL;
645                output_path = NULL;
646                error_path = NULL;
647        }
648        END_TRY                 
649       
650        /* native specification */
651        value = jt->get_attr( jt, DRMAA_NATIVE_SPECIFICATION );
652        if( value )
653        {
654                fsd_log_debug(("# Native specification: %s\n", value));
655                slurmdrmaa_parse_native(job_desc, value);
656        }
657               
658        /* job category */
659        value = jt->get_attr( jt, DRMAA_JOB_CATEGORY );
660        if( value )
661                job_category = value;
662
663        {
664                fsd_conf_option_t *category_value = NULL;
665                category_value = fsd_conf_dict_get( session->job_categories, job_category );
666
667                if( category_value != NULL )
668                {
669                        if( category_value->type != FSD_CONF_STRING )
670                                fsd_exc_raise_fmt(
671                                                FSD_ERRNO_INTERNAL_ERROR,
672                                                "configuration error: job category should be string"
673                                                );
674
675                        fsd_log_debug(("# Job category %s : %s\n",value,category_value->val.string));                   
676                        slurmdrmaa_parse_native(job_desc,category_value->val.string);                   
677                }
678                else
679                {
680                        if( value != NULL )
681                                fsd_exc_raise_fmt(
682                                                FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,
683                                                "invalid job category: %s", job_category
684                                                );
685                }
686        }
687       
688}               
689               
690
Note: See TracBrowser for help on using the repository browser.