Changeset 4452
- Timestamp:
- Jul 5, 2005, 7:12:22 AM (21 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 5 edited
-
doc/pcontrol.txt (modified) (6 diffs)
-
doc/scheduler.txt (modified) (7 diffs)
-
pantasks/CheckJobs.c (modified) (3 diffs)
-
pantasks/ControllerOps.c (modified) (4 diffs)
-
scripts/sched.pro (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/doc/pcontrol.txt
r4450 r4452 99 99 +host name : run job on specified host, error if not available (error when attempted, not when submitted) 100 100 -timeout N : seconds before controller gives up on job (once started) 101 -stdout name : redirect job stdout to file directly 102 -stderr name : redirect job stderr to file directly 101 103 102 104 * priority information? … … 137 139 currently down, while the transition idle -> down is immediately 138 140 followed by an attempt by pcontrol to move the host from down -> idle. 141 This functionality can be used with non-automatic calling of 142 CheckSystem to test the pcontrol host interface operations. 139 143 140 144 does it makes sense to kill all jobs on a host? this would only have … … 154 158 --- 155 159 156 write message157 read until MESSAGE END158 159 160 160 Job States: 161 161 … … 164 164 EXIT 165 165 CRASH 166 NEW 167 DEL 166 NEW * 167 DEL * 168 169 * - invisible states 168 170 169 171 Job State Transitions: … … 185 187 DOWN 186 188 OFF 187 NEW 188 DEL 189 NEW * 190 DEL * 191 192 * - invisible states 189 193 190 194 Host State Transitions: … … 214 218 StartHost - P 215 219 CheckHost - P 220 221 U - operation performed by the user 222 P - operation performed by the program -
trunk/Ohana/src/opihi/doc/scheduler.txt
r4450 r4452 1 2 2005.07.05 3 4 At this point, scheduler / pcontrol / pclient all work in a basic way. 5 pclient is the most robust of the three, having the simplest 6 responsibility. pcontrol is generally pretty good, though I need to 7 flesh out the user interface a bit and clean up the output warning / info 8 messages. scheduler will need the most attention, though it is 9 already fairly reasonable. I need to flesh out the user commands to 10 check on the controller status (basically, these need to replicate the 11 status commands available to the controller). 12 13 I also need to handle the case of timeout on the controller, 14 independently of timeout for a local job on the scheduler. currently, 15 if a local job exceeds the timeout value, scheduler flags it. but, it 16 does not make sense to use the same timeout value for a controller 17 job. I could pass the timeout to the controller when the job executes, 18 in which case it has the same meaning, essentially, for the controller 19 jobs as it does for the local jobs: once you start the function, it 20 needs to complete within NN seconds. However, I think I still need to 21 have a scheduler concept of a job which the controller is unable to 22 complete. It should be possible to prevent a job from sitting pending 23 on the controller forever. What exactly you do if the controller is 24 unwilling to execute a job is another story (possible reasons: 25 controller overload, missing required host, missing any hosts, 26 something hung somewhere?). 27 28 The scheduler does not do a good job of shutting down the controller 29 when it (the scheduler) exits. This works well for the 30 pcontrol/pclient interface, so the solution lies there. 31 32 I need to decide how to behave if the scheduler asks for a job with a 33 required host which the controller knows is currently down or 34 non-existent. Several options could be used. The controller could 35 simply hold the task until the scheduler notices it is not being 36 executed (after all, the controller does not know if the machine is 37 being serviced for a short time or a long time, but the scheduler 38 could know). The controller could immediately return a failure noting 39 the current state of the machine (this would put the burden of 40 deciding that the machine should be available on the scheduler). The 41 controller could try to execute the job a certain number of times, and 42 then it could report the failure to the scheduler. This is not so 43 different from having a pending-timeout which the scheduler tracks 44 (moves the timeout check to the controller, essentially). 45 46 There was some odd behavior with 'exec echo $stdout >> foo'. This 47 resulted in empty files 'foo'. The following work fine, so something 48 is just weird: 49 exec echo foobar >> foo 50 output foo 51 echo $stdout 52 output stdout 53 54 Various error conditions should be checked 55 56 What do we do if a task requests a host which is not available to the 57 controller (ie, not defined)? this is similar to the problem of 58 requesting a host which is down. I think the controller should either 59 immediately refuse or accept in anticipation that such a host may 60 eventually be defined. 61 62 I need to be careful about jobs sent to the controller and not 63 harvested before stopping the scheduler execution. 1 64 2 65 --- … … 5 68 6 69 - sched: validate task hosts with controller 7 - pcontrol: host (name) -check should return state8 - sched: start / stop controller connection?9 - pcontrol: add command to check status of a job10 - pcontrol: add command to dump stdout/stderr for a job11 70 12 71 --- … … 40 99 - may be in task or in task.macro (exit/exec) 41 100 (in task, value is static; in task.macro, value is defined for each instance) 101 - value of LOCAL runs job as local job (not on controller) 102 - value of NONE runs job on controller without specifying host 42 103 43 104 stderr (file / variable) … … 54 115 - defines relevant time-scale for the task 55 116 56 schedule 57 - runs the scheduler loop, executing the various tasks 58 59 scheduler functions: 60 61 InitTasks (); 62 FindTask (); 63 CreateTask (); 117 run 118 stop 119 - start or stop the scheduler loop, executing the various tasks 64 120 65 121 --- … … 67 123 local jobs vs controller jobs 68 124 69 if 'host' is 'local', task is run as background fork (ie, not on controller) 70 if 'host' is NULL or 'any', task is run on controller without specified host 71 if 'host' is (machine), task is run on controller with specified host 72 73 --- 74 75 scheduler / controller / local interactions 76 77 scheduler can execute local jobs and jobs on the controller. 78 scheduler needs to initiate the connection to the controller, if the 79 controller is being used. it also needs to fork each local command. 80 81 we need a command to define the controller hosts to be used. if a 82 task or job defines a host which is not known, how is this caught? 83 does sched need to keep a list of valid hosts, or should the host be 84 passed down to the controller. Also, the scheduler should not 85 initiate a connection to the controller unless it is requested. is 86 this implicit when defining a host? 87 88 - controller host foobar 89 90 this should setup the controller interface (if it does not currently 91 exist), and send the command 'host foobar'. scheduler should not 92 care if the connection is successful or not (we can know about hosts 93 which are currently off). 94 95 96 --- 97 controller interaction: 98 99 controller accepts the following commands: 100 101 job [options] argv0 argv1 argv2 ... 102 -host name : run job on specified host, or any other if not available 103 +host name : run job on specified host, error if not available 104 -timeout N : seconds before controller gives up on job (once started) 105 -stdout name : redirect job stdout to file directly 106 -stderr name : redirect job stderr to file directly 107 * priority information? 108 * returns JobID 109 110 status (JobID) 111 112 stdout (JobID) 113 114 stderr (JobID) 115 116 stop (JobID) 117 118 delete (JobID) 125 a local job is run as background fork (ie, not on controller) 126 a controller job is sent to the controller to run when it can 119 127 120 128 --- … … 127 135 - controller says command not found 128 136 - controller has too many processes 129 - controller takes to long to start job ( schedulertimeout)137 - controller takes to long to start job (pending timeout) 130 138 - controller says job timed out 131 139 - controller says job crashed … … 138 146 - watch for NFS lags / blocking. if NFS has file visibility lags, we 139 147 may need to add blocking as an option to the job (-block filename) 140 -
trunk/Ohana/src/opihi/pantasks/CheckJobs.c
r4451 r4452 12 12 while ((job = NextJob ()) != NULL) { 13 13 14 /* check for timeout */15 if ( GetTaskTimer(job[0].start) >= job[0].task[0].timeout_period) {14 /* check for timeout - only local jobs timeout here */ 15 if ((job[0].mode == JOB_LOCAL) && (GetTaskTimer(job[0].start) >= job[0].task[0].timeout_period)) { 16 16 fprintf (stderr, "timeout on %s\n", job[0].task[0].name); 17 17 /* run task[0].timeout macro, if it exists */ … … 29 29 status = CheckJob (job); 30 30 switch (status) { 31 case JOB_PENDING: 32 fprintf (stderr, "job %s (%d) pending\n", job[0].task[0].name, job[0].JobID); 33 break; 34 31 35 case JOB_BUSY: 32 36 fprintf (stderr, "job %s (%d) busy\n", job[0].task[0].name, job[0].JobID); … … 65 69 66 70 default: 67 fprintf (stderr, "unknown exit status \n");71 fprintf (stderr, "unknown exit status: %d\n", status); 68 72 /** do something more useful here ?? **/ 69 73 break; -
trunk/Ohana/src/opihi/pantasks/ControllerOps.c
r4451 r4452 5 5 int status = FALSE; 6 6 int stdin_cntl, stdout_cntl, stderr_cntl; 7 8 /* we read Nbytes from the host, then watch for the prompt */9 int GetJobOutput (char *cmd, int pid, IOBuffer *buffer, int Nbytes) {10 11 int i, status, Nstart;12 char *line;13 14 /* flush any earlier messages */15 ReadtoIOBuffer (buffer, stdout_cntl);16 FlushIOBuffer (buffer);17 Nstart = buffer[0].Nbuffer;18 19 /* send command to get appropriate channel */20 ALLOCATE (line, char, MAX (1, strlen(cmd) + 15));21 sprintf (line, "%s %d\n", cmd, pid);22 status = write (stdin_cntl, line, strlen(line));23 free (line);24 25 /* is pipe still open? */26 if ((status == -1) && (errno == EPIPE)) return (CONTROLLER_DOWN);27 28 /* read at least Nbytes, then watch for CONTROLLER_PROMPT */29 line = NULL;30 status = -1;31 for (i = 0; (i < CONTROLLER_TIMEOUT) && (status == -1) && (line == NULL); i++) {32 status = ReadtoIOBuffer (buffer, stdout_cntl);33 if ((buffer[0].Nbuffer - Nstart) >= Nbytes) {34 line = memstr (buffer[0].buffer, CONTROLLER_PROMPT, buffer[0].Nbuffer);35 }36 if (status == -1) usleep (10000);37 }38 if (status == 0) return (CONTROLLER_DOWN);39 if (status == -1) return (CONTROLLER_HUNG);40 41 fprintf (stderr, "message received (GetJobOutput : %s)\n", cmd);42 /* drop extra bytes from pcontrol (not pclient:job) */43 buffer[0].Nbuffer = Nstart + Nbytes;44 if (buffer[0].Nalloc > buffer[0].Nbuffer) {45 bzero (buffer[0].buffer + buffer[0].Nbuffer, buffer[0].Nalloc - buffer[0].Nbuffer);46 }47 return (CONTROLLER_GOOD);48 }49 7 50 8 int CheckControllerJob (Job *job) { … … 123 81 } 124 82 83 /* we read Nbytes from the host, then watch for the prompt */ 84 int GetJobOutput (char *cmd, int pid, IOBuffer *buffer, int Nbytes) { 85 86 int i, status, Nstart; 87 char *line; 88 89 /* flush any earlier messages */ 90 ReadtoIOBuffer (buffer, stdout_cntl); 91 FlushIOBuffer (buffer); 92 Nstart = buffer[0].Nbuffer; 93 94 /* send command to get appropriate channel */ 95 ALLOCATE (line, char, MAX (1, strlen(cmd) + 15)); 96 sprintf (line, "%s %d\n", cmd, pid); 97 status = write (stdin_cntl, line, strlen(line)); 98 free (line); 99 100 /* is pipe still open? */ 101 if ((status == -1) && (errno == EPIPE)) return (CONTROLLER_DOWN); 102 103 /* read at least Nbytes, then watch for CONTROLLER_PROMPT */ 104 line = NULL; 105 status = -1; 106 for (i = 0; (i < CONTROLLER_TIMEOUT) && (status == -1) && (line == NULL); i++) { 107 status = ReadtoIOBuffer (buffer, stdout_cntl); 108 if ((buffer[0].Nbuffer - Nstart) >= Nbytes) { 109 line = memstr (buffer[0].buffer, CONTROLLER_PROMPT, buffer[0].Nbuffer); 110 } 111 if (status == -1) usleep (10000); 112 } 113 if (status == 0) return (CONTROLLER_DOWN); 114 if (status == -1) return (CONTROLLER_HUNG); 115 116 fprintf (stderr, "message received (GetJobOutput : %s)\n", cmd); 117 /* drop extra bytes from pcontrol (not pclient:job) */ 118 buffer[0].Nbuffer = Nstart + Nbytes; 119 if (buffer[0].Nalloc > buffer[0].Nbuffer) { 120 bzero (buffer[0].buffer + buffer[0].Nbuffer, buffer[0].Nalloc - buffer[0].Nbuffer); 121 } 122 return (CONTROLLER_GOOD); 123 } 124 125 125 /* submitting a job to the controller automatically starts controller */ 126 126 int SubmitControllerJob (Job *job) { … … 165 165 } 166 166 167 fprintf (stderr, "sending command to controller: %s\n", cmd); 167 168 InitIOBuffer (&buffer, 0x100); 168 169 ControllerCommand (cmd, CONTROLLER_PROMPT, &buffer); 169 170 free (cmd); 170 171 172 fprintf (stderr, "response from controller: %s\n", buffer.buffer); 173 171 174 /* extract the job PID from the controller response */ 172 p = memstr (buffer.buffer, " STATUS", buffer.Nbuffer);175 p = memstr (buffer.buffer, "JobID", buffer.Nbuffer); 173 176 if (p == NULL) { 174 177 fprintf (stderr, "missing PID in pcontrol message : programming error\n"); … … 298 301 FlushIOBuffer (buffer); 299 302 303 fprintf (stderr, "send: %s\n", cmd); 304 300 305 /* send command to client (adding on \n) */ 301 /* fprintf (stderr, "send: %s (%d)\n", command, buffer[0].Nbuffer); */302 306 ALLOCATE (line, char, MAX (1, strlen(cmd))); 303 307 sprintf (line, "%s\n", cmd); -
trunk/Ohana/src/opihi/scripts/sched.pro
r4451 r4452 1 2 controller host localhost 1 3 2 4 task test … … 5 7 periods -exec 2.0 6 8 periods -timeout 2.0 7 host local 9 # host local 10 host localhost 8 11 # local is default 9 12
Note:
See TracChangeset
for help on using the changeset viewer.
