Skip to content
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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

Conversation

mnonnenmacher
Copy link
Contributor

The few classes in the orchestrator currently have a very high degree of coupling and no clear separation of concerns. For example:

  • The logic to determine the next jobs is partly implemented in WorkerScheduleInfo and partly in WorkerScheduleContext.
  • Messaging is handled by Orchestrator, WorkerScheduleContext, and WorkerScheduleInfo.
  • Orchestrator, WorkerJobRepositories, and WorkerScheduleInfo 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.

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(
Copy link
Contributor

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 a WorkerScheduleContext, and with the help of this context, an OrtRunInfo. This is because the latter has its own state derived from the context (this is not really untangling). It would be better if OrtRunInfo was stateless and only implemented the scheduling strategy. The getNextJobs() function could be passed a WorkerScheduleContext 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) {
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants