Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Add missing job state transition #2202

Merged
merged 2 commits into from
Jul 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/ApiService/ApiService/onefuzzlib/JobOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -73,6 +74,17 @@ public async Async.Task StopNeverStartedJobs() {
}
}

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);
chkeita marked this conversation as resolved.
Show resolved Hide resolved
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();
Expand Down