~ubuntu-branches/ubuntu/precise/torque/precise-updates

« back to all changes in this revision

Viewing changes to src/server/req_rerun.c

  • Committer: Bazaar Package Importer
  • Author(s): Dominique Belhachemi
  • Date: 2010-05-17 20:56:46 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100517205646-yjsoqs5r1s9xpnu9
Tags: upstream-2.4.8+dfsg
ImportĀ upstreamĀ versionĀ 2.4.8+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
#include "server.h"
94
94
#include "credential.h"
95
95
#include "batch_request.h"
96
 
#include "job.h"
 
96
#include "pbs_job.h"
97
97
#include "pbs_error.h"
98
98
#include "log.h"
99
99
#include "acct.h"
155
155
 
156
156
 
157
157
 
158
 
/*
 
158
/**
159
159
 * req_rerunjob - service the Rerun Job Request
160
160
 *
161
161
 * This request Reruns a job by:
162
 
 *  sending to MOM a signal job request with SIGKILL
163
 
 *  marking the job as being rerun by setting the substate.
 
162
 * sending to MOM a signal job request with SIGKILL
 
163
 * marking the job as being rerun by setting the substate.
 
164
 *
 
165
 * NOTE:  can be used to requeue active jobs or completed jobs.
164
166
 */
165
167
 
166
168
void req_rerunjob(
169
171
 
170
172
  {
171
173
  job *pjob;
 
174
  struct work_task      *pwt;
172
175
 
173
176
  int  Force;
174
177
 
175
178
  int  rc;
176
179
 
 
180
  int  MgrRequired = TRUE;
 
181
 
 
182
  /* check if requestor is admin, job owner, etc */
 
183
 
177
184
  if ((pjob = chk_job_request(preq->rq_ind.rq_rerun, preq)) == 0)
178
185
    {
179
186
    /* FAILURE */
183
190
    return;
184
191
    }
185
192
 
186
 
  if (preq->rq_extend && !strncasecmp(preq->rq_extend, RERUNFORCE, strlen(RERUNFORCE)))
187
 
    Force = 1;
188
 
  else
189
 
    Force = 0;
190
 
 
191
 
  if ((preq->rq_perm & (ATR_DFLAG_MGWR | ATR_DFLAG_OPWR)) == 0)
192
 
    {
193
 
    /* FAILURE */
194
 
 
195
 
    req_reject(PBSE_PERM, 0, preq, NULL, NULL);
196
 
 
197
 
    return;
198
 
    }
199
 
 
200
193
  /* the job must be running or completed */
201
194
 
202
 
  if ((pjob->ji_qs.ji_state < JOB_STATE_EXITING) &&
203
 
      (pjob->ji_qs.ji_state != JOB_STATE_RUNNING))
204
 
    {
205
 
    /* FAILURE */
 
195
  if (pjob->ji_qs.ji_state >= JOB_STATE_EXITING)
 
196
    {
 
197
    if (pjob->ji_wattr[(int)JOB_ATR_checkpoint_name].at_flags & ATR_VFLAG_SET)
 
198
      {
 
199
      /* allow end-users to rerun checkpointed jobs */
 
200
 
 
201
      MgrRequired = FALSE;
 
202
      }
 
203
    }
 
204
  else if (pjob->ji_qs.ji_state == JOB_STATE_RUNNING)
 
205
    {
 
206
    /* job is running */
 
207
 
 
208
    /* NO-OP */
 
209
    }
 
210
  else
 
211
    {
 
212
    /* FAILURE - job is in bad state */
206
213
 
207
214
    req_reject(PBSE_BADSTATE, 0, preq, NULL, NULL);
208
215
 
209
216
    return;
210
217
    }
211
218
 
 
219
  if ((MgrRequired == TRUE) &&
 
220
      ((preq->rq_perm & (ATR_DFLAG_MGWR | ATR_DFLAG_OPWR)) == 0))
 
221
    {
 
222
    /* FAILURE */
 
223
 
 
224
    req_reject(PBSE_PERM, 0, preq, NULL, NULL);
 
225
 
 
226
    return;
 
227
    }
 
228
 
212
229
  /* the job must be rerunnable */
213
230
 
214
231
  if (pjob->ji_wattr[(int)JOB_ATR_rerunable].at_val.at_long == 0)
230
247
    rc = issue_signal(pjob, "SIGKILL", post_rerun, 0);
231
248
    }
232
249
  else
233
 
    {
 
250
    { 
234
251
    if (pjob->ji_wattr[(int)JOB_ATR_hold].at_val.at_long == HOLD_n)
235
252
      {
236
253
      svr_setjobstate(pjob, JOB_STATE_QUEUED, JOB_SUBSTATE_QUEUED);
240
257
      svr_setjobstate(pjob, JOB_STATE_HELD, JOB_SUBSTATE_HELD);
241
258
      }
242
259
 
 
260
    /* reset some job attributes */
 
261
    
 
262
    pjob->ji_wattr[(int)JOB_ATR_comp_time].at_flags &= ~ATR_VFLAG_SET;
 
263
    pjob->ji_wattr[(int)JOB_ATR_reported].at_flags &= ~ATR_VFLAG_SET;
 
264
 
 
265
    /*
 
266
     * delete any work task entries associated with the job
 
267
     * there may be tasks for keep_completed proccessing
 
268
     */
 
269
 
 
270
    while ((pwt = (struct work_task *)GET_NEXT(pjob->ji_svrtask)) != NULL) 
 
271
      {
 
272
      delete_task(pwt);
 
273
      }
 
274
 
243
275
    set_statechar(pjob);
244
276
 
245
277
    rc = -1;
246
278
    }
247
279
 
 
280
  if (preq->rq_extend && !strncasecmp(preq->rq_extend, RERUNFORCE, strlen(RERUNFORCE)))
 
281
    Force = 1;
 
282
  else
 
283
    Force = 0;
 
284
 
248
285
  switch (rc)
249
286
    {
250
287
 
251
288
    case - 1:
252
289
 
253
 
      /* completed job was requeued - NO-OP */
 
290
      /* completed job was requeued */
254
291
 
 
292
      /* clear out job completion time if there is one */
255
293
      break;
256
294
 
257
295
    case 0:
336
374
  /* So job has run and is to be rerun (not restarted) */
337
375
 
338
376
  pjob->ji_qs.ji_svrflags = (pjob->ji_qs.ji_svrflags &
339
 
                             ~(JOB_SVFLG_CHKPT | JOB_SVFLG_ChkptMig)) | JOB_SVFLG_HASRUN;
 
377
      ~(JOB_SVFLG_CHECKPOINT_FILE |JOB_SVFLG_CHECKPOINT_MIGRATEABLE |
 
378
       JOB_SVFLG_CHECKPOINT_COPIED)) | JOB_SVFLG_HASRUN;
340
379
 
341
380
  sprintf(log_buffer, msg_manager,
342
381
          msg_jobrerun,