-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start untangling orchestrator #1739
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Martin Nonnenmacher <[email protected]>
Signed-off-by: Martin Nonnenmacher <[email protected]>
Signed-off-by: Martin Nonnenmacher <[email protected]>
This makes the code more explicit and helps with upcoming refactorings. Also, the function name was confusing because it was not only responsible for scheduling jobs but also for executing the `onFailure` handler from the caller. Signed-off-by: Martin Nonnenmacher <[email protected]>
The word "current" does not carry any meaning in the context of the function. Signed-off-by: Martin Nonnenmacher <[email protected]>
Use the `WorkerScheduleInfo` enum instead of the `Endpoint` class to define the dependencies between jobs. This slightly simplifies the code and improves type safety. It also makes the companion object of `WorkerScheduleInfo` obsolete. Signed-off-by: Martin Nonnenmacher <[email protected]>
Extract the logic to determine which jobs should run next into a new `OrtRunInfo` class to be able to test it independently. The class will be taken into use in a follow-up commit. Signed-off-by: Martin Nonnenmacher <[email protected]>
If the analyzer did not run, it makes no sense to run the reporter worker as there is no data to report. Signed-off-by: Martin Nonnenmacher <[email protected]>
Add a new function `scheduleNextJobs` that uses the previously introduced `OrtRunInfo` to determine which jobs need to be scheduled and delete all now unused functions from the previous implementation. Signed-off-by: Martin Nonnenmacher <[email protected]>
With the introduction of the `JobStatus.final` property in 4d23673 the `WorkerJob.isCompleted()` helper function is not required anymore. Signed-off-by: Martin Nonnenmacher <[email protected]>
import org.eclipse.apoapsis.ortserver.model.JobStatus | ||
|
||
/** A class to store the required information to determine which jobs can be run. */ | ||
internal class OrtRunInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I like the idea to extract the scheduling logic to a dedicated class, I have some problems with the current implementation:
- IIUC, this class now contains the scheduling logic and is responsible to determine the next jobs that should run. This should also be reflected by the class name.
OrtRunInfo
is meaningless in this context and rather reminds of a data model class. - The relation between this class and
WorkerScheduleContext
is unclear.Orchestrator
now creates aWorkerScheduleContext
, and with the help of this context, anOrtRunInfo
. This is because the latter has its own state derived from the context (this is not really untangling). It would be better ifOrtRunInfo
was stateless and only implemented the scheduling strategy. ThegetNextJobs()
function could be passed aWorkerScheduleContext
info object and obtain all required information from there.
@@ -125,7 +125,7 @@ internal enum class WorkerScheduleInfo( | |||
configs.evaluator != null | |||
}, | |||
|
|||
REPORTER(ReporterEndpoint, runsAfter = listOf(EVALUATOR), runAfterFailure = true) { | |||
REPORTER(ReporterEndpoint, dependsOn = listOf(ANALYZER), runsAfter = listOf(EVALUATOR), runAfterFailure = true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a deliberate decision that the Reporter step should always be executed to enable use cases like an "ORT run report" containing information about the whole run with its successful and failing steps. So, I would be reluctant to say that it generally makes no sense to run the reporter after a failed analyzer step. In every case, the type "fix" is not correct for this commit because this is no bug, but the behavior was by design.
The few classes in the
orchestrator
currently have a very high degree of coupling and no clear separation of concerns. For example:WorkerScheduleInfo
and partly inWorkerScheduleContext
.Orchestrator
,WorkerScheduleContext
, andWorkerScheduleInfo
.Orchestrator
,WorkerJobRepositories
, andWorkerScheduleInfo
all interact with the repositories to create jobs or update their status.Besides some minor clean ups, this PR separates the logic to determine the next jobs into a new class that has no dependencies on infrastructure. It is the first in a series of changes to untangle the different responsibilities of the orchestrator to make them testable in isolation and improve overview.