mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-22 22:28:50 +00:00
Add missing job state transition (#2202)
* Add missing job state transition * address PR comments
This commit is contained in:
@ -7,6 +7,7 @@ public interface IJobOperations : IStatefulOrm<Job, JobState> {
|
||||
Async.Task OnStart(Job job);
|
||||
IAsyncEnumerable<Job> SearchExpired();
|
||||
Async.Task<Job> Stopping(Job job);
|
||||
Async.Task<Job> Init(Job job);
|
||||
IAsyncEnumerable<Job> SearchState(IEnumerable<JobState> states);
|
||||
Async.Task StopNeverStartedJobs();
|
||||
Async.Task StopIfAllDone(Job job);
|
||||
@ -73,6 +74,17 @@ public class JobOperations : StatefulOrm<Job, JobState, JobOperations>, IJobOper
|
||||
}
|
||||
}
|
||||
|
||||
public async Async.Task<Job> Init(Job job) {
|
||||
_logTracer.Info($"init job: {job.JobId}");
|
||||
var enabled = job with { State = JobState.Enabled };
|
||||
var result = await Replace(enabled);
|
||||
if (result.IsOk) {
|
||||
return enabled;
|
||||
} else {
|
||||
throw new Exception($"Failed to save job {job.JobId} : {result.ErrorV}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Async.Task<Job> Stopping(Job job) {
|
||||
job = job with { State = JobState.Stopping };
|
||||
var tasks = await _context.TaskOperations.QueryAsync(filter: $"job_id eq '{job.JobId}'").ToListAsync();
|
||||
|
Reference in New Issue
Block a user