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

« back to all changes in this revision

Viewing changes to src/server/svr_movejob.c

  • Committer: Bazaar Package Importer
  • Author(s): Dominique Belhachemi
  • Date: 2010-05-17 20:56:46 UTC
  • mfrom: (0.1.3 sid) (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100517205646-yipvh4jq5n5n1kgo
Tags: 2.4.8+dfsg-5
install man pages together with their associated binaries (Closes: #581576)

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
#include "work_task.h"
102
102
#include "log.h"
103
103
#include "queue.h"
104
 
#include "job.h"
 
104
#include "pbs_job.h"
105
105
#include "pbs_nodes.h"
106
106
#include "credential.h"
107
107
#include "batch_request.h"
123
123
 
124
124
extern void stat_mom_job A_((job *));
125
125
extern void remove_stagein(job *);
 
126
extern void remove_checkpoint(job *);
126
127
extern int  job_route A_((job *));
127
128
 
128
129
extern struct pbsnode *PGetNodeFromAddr(pbs_net_t);
147
148
extern char  server_host[];
148
149
extern char  server_name[];
149
150
extern char *msg_badexit;
150
 
extern char *msg_routebad;
151
151
extern char *msg_routexceed;
152
152
extern char *msg_manager;
153
153
extern char *msg_movejob;
368
368
 
369
369
  switch (r)
370
370
    {
371
 
 
372
371
    case 0:  /* normal return, job was routed */
373
372
 
374
373
      if (jobp->ji_qs.ji_svrflags & JOB_SVFLG_StagedIn)
375
374
        remove_stagein(jobp);
376
375
 
 
376
      if (jobp->ji_qs.ji_svrflags & JOB_SVFLG_CHECKPOINT_COPIED)
 
377
        remove_checkpoint(jobp);
 
378
 
377
379
      job_purge(jobp); /* need to remove server job struct */
378
380
 
379
381
      return;
405
407
      svr_setjobstate(jobp, newstate, newsub);
406
408
 
407
409
      if ((r = job_route(jobp)) == PBSE_ROUTEREJ)
408
 
        job_abt(&jobp, msg_routebad);
 
410
        job_abt(&jobp, pbse_to_txt(PBSE_ROUTEREJ));
409
411
      else if (r != 0)
410
412
        job_abt(&jobp, msg_routexceed);
411
413
 
482
484
      if (jobp->ji_qs.ji_svrflags & JOB_SVFLG_StagedIn)
483
485
        remove_stagein(jobp);
484
486
 
 
487
      if (jobp->ji_qs.ji_svrflags & JOB_SVFLG_CHECKPOINT_COPIED)
 
488
        remove_checkpoint(jobp);
 
489
 
485
490
      strcpy(log_buffer, msg_movejob);
486
491
 
487
492
      sprintf(log_buffer + strlen(log_buffer), msg_manager,
541
546
 * Start a child to do the work.  Connect to the destination host and port,
542
547
 * and go through the protocol to transfer the job.
543
548
 *
 
549
 * @see svr_strtjob2() - parent
 
550
 *
544
551
 * Returns (parent): 2 on success (child forked),
545
552
 *    -1 on failure (pbs_errno set to error number)
546
553
 *
554
561
 
555
562
  job       *jobp,
556
563
  pbs_net_t  hostaddr, /* host address, host byte order */
557
 
  int      port, /* service port, host byte order */
558
 
  int      move_type, /* move, route, or execute */
 
564
  int        port, /* service port, host byte order */
 
565
  int        move_type, /* move, route, or execute */
559
566
  void (*post_func) A_((struct work_task *)),     /* after move */
560
 
  void     *data) /* ptr to optional batch_request to be put */
561
 
/* in the work task structure */
 
567
  void      *data)  /* ptr to optional batch_request to be put */
 
568
                    /* in the work task structure */
 
569
 
562
570
  {
563
571
  tlist_head  attrl;
564
572
  enum conn_type cntype = ToServerDIS;
565
 
  int   con;
 
573
  int    con;
566
574
  char  *destin = jobp->ji_qs.ji_destin;
567
 
  int   encode_type;
568
 
  int   i;
 
575
  int    encode_type;
 
576
  int    i;
569
577
  int    NumRetries;
 
578
 
570
579
  char  *id = "send_job";
 
580
 
571
581
  char   job_id[PBS_MAXSVRJOBID + 1];
 
582
 
572
583
  attribute *pattr;
573
 
  pid_t   pid;
 
584
 
 
585
  pid_t  pid;
574
586
 
575
587
  struct attropl *pqjatr;      /* list (single) of attropl for quejob */
576
588
  char  *safail = "sigaction failed\n";
594
606
 
595
607
  if (sigprocmask(SIG_BLOCK, &child_set, NULL) == -1)
596
608
    {
597
 
    log_err(errno, id, spfail);
 
609
    log_err(errno,id,spfail);
598
610
 
599
611
    pbs_errno = PBSE_SYSTEM;
600
612
 
609
621
 
610
622
  if (LOGLEVEL >= 6)
611
623
    {
 
624
    sprintf(log_buffer,"about to send job - type=%d",
 
625
      move_type);
 
626
 
612
627
    log_event(
613
628
      PBSEVENT_JOB,
614
629
      PBS_EVENTCLASS_JOB,
637
652
    /* The parent (main server) */
638
653
 
639
654
    /* create task to monitor job startup */
 
655
 
640
656
    /* CRI:   need way to report to scheduler job is starting, not started */
641
657
 
642
658
    ptask = set_task(WORK_Deferred_Child, pid, post_func, jobp);
660
676
    if (sigprocmask(SIG_UNBLOCK, &child_set, NULL) == -1)
661
677
      log_err(errno, id, spfail);
662
678
 
663
 
    if (LOGLEVEL >= 7)
664
 
      {
665
 
      sprintf(log_buffer, "send_job child job pid is %d",
666
 
              pid);
667
 
 
668
 
      log_event(
669
 
        PBSEVENT_JOB,
670
 
        PBS_EVENTCLASS_JOB,
671
 
        jobp->ji_qs.ji_jobid,
672
 
        log_buffer);
673
 
      }
674
 
 
675
679
    if (LOGLEVEL >= 1)
676
680
      {
677
681
      extern long   DispatchTime[];
745
749
 
746
750
  if (move_type == MOVE_TYPE_Exec)
747
751
    {
 
752
    /* moving job to MOM - ie job start */
 
753
 
748
754
    resc_access_perm = ATR_DFLAG_MOM;
749
755
    encode_type = ATR_ENCODE_MOM;
750
756
    cntype = ToServerDIS;
751
757
    }
752
758
  else
753
759
    {
 
760
    /* moving job to alternate server? */
 
761
 
754
762
    resc_access_perm =
755
763
      ATR_DFLAG_USWR |
756
764
      ATR_DFLAG_OPWR |
768
776
 
769
777
  for (i = 0;i < (int)JOB_ATR_LAST;i++)
770
778
    {
771
 
    if ((job_attr_def + i)->at_flags & resc_access_perm)
 
779
    if (((job_attr_def + i)->at_flags & resc_access_perm) ||
 
780
      ((strncmp((job_attr_def + i)->at_name,"session_id",10) == 0) &&
 
781
      (jobp->ji_wattr[(int)JOB_ATR_checkpoint_name].at_flags & ATR_VFLAG_SET)))
772
782
      {
773
783
      (job_attr_def + i)->at_encode(
774
784
        pattr + i,
836
846
    if ((con = svr_connect(hostaddr, port, 0, cntype)) == PBS_NET_RC_FATAL)
837
847
      {
838
848
      sprintf(log_buffer, "send_job failed to %lx port %d",
839
 
              hostaddr,
840
 
              port);
 
849
        hostaddr,
 
850
        port);
841
851
 
842
852
      log_err(pbs_errno, id, log_buffer);
843
853
 
896
906
          }
897
907
 
898
908
        sprintf(log_buffer, "send of job to %s failed error = %d",
899
 
 
900
 
                destin,
901
 
                pbs_errno);
 
909
          destin,
 
910
          pbs_errno);
902
911
 
903
912
        log_event(
904
913
          PBSEVENT_JOB,
917
926
          continue;
918
927
        }
919
928
 
 
929
      /* XXX may need to change the logic below, if we are sending the job to
 
930
         a mom on the same host and the mom and server are not sharing the same
 
931
         spool directory, then we still need to move the file */
 
932
 
920
933
      if ((move_type == MOVE_TYPE_Exec) &&
921
934
          (jobp->ji_qs.ji_svrflags & JOB_SVFLG_HASRUN) &&
922
935
          (hostaddr != pbs_server_addr))
923
936
        {
924
937
        /* send files created on prior run */
925
938
 
926
 
        if ((move_job_file(con, jobp, StdOut) != 0) ||
927
 
            (move_job_file(con, jobp, StdErr) != 0) ||
928
 
            (move_job_file(con, jobp, Chkpt) != 0))
 
939
        if ((move_job_file(con,jobp,StdOut) != 0) ||
 
940
            (move_job_file(con,jobp,StdErr) != 0) ||
 
941
            (move_job_file(con,jobp,Checkpoint) != 0))
 
942
          {
929
943
          continue;
 
944
          }
930
945
        }
931
946
 
932
947
      /* ignore signals */
974
989
              rc,
975
990
              (connection[con].ch_errtxt != NULL) ? connection[con].ch_errtxt : "N/A");
976
991
 
977
 
      log_err(errno2, id, log_buffer);
 
992
      log_ext(errno2, id, log_buffer, LOG_WARNING);
978
993
 
979
994
      /* if failure occurs, pbs_mom should purge job and pbs_server should set *
980
995
         job state to idle w/error msg */
992
1007
        sprintf(log_buffer, "child commit request timed-out for job %s, increase tcp_timeout?",
993
1008
                jobp->ji_qs.ji_jobid);
994
1009
 
995
 
        log_err(errno2, id, log_buffer);
 
1010
        log_ext(errno2, id, log_buffer, LOG_WARNING);
996
1011
 
997
1012
        /* don't retry on timeout--break out and report error! */
998
1013
 
1003
1018
        sprintf(log_buffer, "child failed in commit request for job %s",
1004
1019
                jobp->ji_qs.ji_jobid);
1005
1020
 
1006
 
        log_err(errno2, id, log_buffer);
 
1021
        log_ext(errno2, id, log_buffer, LOG_CRIT);
1007
1022
 
1008
1023
        /* FAILURE */
1009
1024
 
1031
1046
    sprintf(log_buffer, "child timed-out attempting to start job %s",
1032
1047
            jobp->ji_qs.ji_jobid);
1033
1048
 
1034
 
    log_err(pbs_errno, id, log_buffer);
 
1049
    log_ext(pbs_errno, id, log_buffer, LOG_WARNING);
1035
1050
 
1036
1051
    exit(10);
1037
1052
    }
1039
1054
  if (should_retry_route(pbs_errno) == -1)
1040
1055
    {
1041
1056
    sprintf(log_buffer, "child failed and will not retry job %s",
1042
 
            jobp->ji_qs.ji_jobid);
 
1057
      jobp->ji_qs.ji_jobid);
1043
1058
 
1044
1059
    log_err(pbs_errno, id, log_buffer);
1045
1060
 
1056
1071
 
1057
1072
 
1058
1073
 
 
1074
 
1059
1075
/*
1060
1076
 * net_move_die - clean up child and report bad status to parent.
1061
1077
 *
1174
1190
  {
1175
1191
  switch (err)
1176
1192
    {
1177
 
 
1178
1193
    case 0:
1179
1194
 
1180
1195
    case EADDRINUSE:
1217
1232
 
1218
1233
 
1219
1234
 
1220
 
static int move_job_file(conn, pjob, which)
1221
 
int   conn;
1222
 
job  *pjob;
1223
 
enum job_file which;
 
1235
static int
 
1236
move_job_file(int conn, job *pjob, enum job_file which)
1224
1237
  {
1225
1238
  char path[MAXPATHLEN+1];
1226
1239
 
1231
1244
    (void)strcat(path, JOB_STDOUT_SUFFIX);
1232
1245
  else if (which == StdErr)
1233
1246
    (void)strcat(path, JOB_STDERR_SUFFIX);
1234
 
  else if (which == Chkpt)
1235
 
    (void)strcat(path, JOB_CKPT_SUFFIX);
 
1247
  else if (which == Checkpoint)
 
1248
    (void)strcat(path, JOB_CHECKPOINT_SUFFIX);
1236
1249
 
1237
1250
  if (access(path, F_OK) < 0)
1238
1251
    {