-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): zombie worker task detection & automatic resubmission (#2081
) close #2055
- Loading branch information
Showing
51 changed files
with
1,252 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
core/src/main/java/io/kestra/core/repositories/WorkerInstanceRepositoryInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.kestra.core.repositories; | ||
|
||
import io.kestra.core.runners.WorkerInstance; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface WorkerInstanceRepositoryInterface { | ||
Optional<WorkerInstance> findByWorkerUuid(String workerUuid); | ||
|
||
List<WorkerInstance> findAll(); | ||
|
||
void delete(WorkerInstance workerInstance); | ||
|
||
WorkerInstance save(WorkerInstance workerInstance); | ||
} |
13 changes: 13 additions & 0 deletions
13
core/src/main/java/io/kestra/core/repositories/WorkerJobRunningRepositoryInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.kestra.core.repositories; | ||
|
||
|
||
import io.kestra.core.runners.WorkerJobRunning; | ||
|
||
import java.util.Optional; | ||
|
||
public interface WorkerJobRunningRepositoryInterface { | ||
Optional<WorkerJobRunning> findByTaskRunId(String taskRunId); | ||
|
||
void deleteByTaskRunId(String taskRunId); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
jdbc-h2/src/main/java/io/kestra/repository/h2/H2WorkerInstanceRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.kestra.repository.h2; | ||
|
||
import io.kestra.core.runners.WorkerInstance; | ||
import io.kestra.jdbc.repository.AbstractJdbcWorkerInstanceRepository; | ||
import io.micronaut.context.ApplicationContext; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
|
||
@Singleton | ||
@H2RepositoryEnabled | ||
public class H2WorkerInstanceRepository extends AbstractJdbcWorkerInstanceRepository { | ||
@Inject | ||
public H2WorkerInstanceRepository(ApplicationContext applicationContext) { | ||
super(new H2Repository<>(WorkerInstance.class, applicationContext)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
jdbc-h2/src/main/java/io/kestra/repository/h2/H2WorkerJobRunningRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.kestra.repository.h2; | ||
|
||
import io.kestra.core.runners.WorkerJobRunning; | ||
import io.kestra.jdbc.repository.AbstractJdbcWorkerJobRunningRepository; | ||
import io.micronaut.context.ApplicationContext; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
|
||
@Singleton | ||
@H2RepositoryEnabled | ||
public class H2WorkerJobRunningRepository extends AbstractJdbcWorkerJobRunningRepository { | ||
@Inject | ||
public H2WorkerJobRunningRepository(ApplicationContext applicationContext) { | ||
super(new H2Repository<>(WorkerJobRunning.class, applicationContext)); | ||
} | ||
} |
23 changes: 12 additions & 11 deletions
23
jdbc-h2/src/main/java/io/kestra/runner/h2/H2WorkerJobQueue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,40 @@ | ||
package io.kestra.runner.h2; | ||
|
||
import io.kestra.core.exceptions.DeserializationException; | ||
import io.kestra.core.queues.QueueFactoryInterface; | ||
import io.kestra.core.queues.QueueInterface; | ||
import io.kestra.core.queues.WorkerJobQueueInterface; | ||
import io.kestra.core.runners.WorkerJob; | ||
import io.kestra.core.utils.Either; | ||
import io.kestra.jdbc.JdbcWorkerJobQueueService; | ||
import io.micronaut.context.ApplicationContext; | ||
import io.micronaut.inject.qualifiers.Qualifiers; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.util.function.Consumer; | ||
|
||
@Slf4j | ||
public class H2WorkerJobQueue implements WorkerJobQueueInterface { | ||
QueueInterface<WorkerJob> workerTaskQueue; | ||
private final JdbcWorkerJobQueueService jdbcworkerjobQueueService; | ||
|
||
@SuppressWarnings("unchecked") | ||
public H2WorkerJobQueue(ApplicationContext applicationContext) { | ||
this.workerTaskQueue = (QueueInterface<WorkerJob>) applicationContext.getBean( | ||
QueueInterface.class, | ||
Qualifiers.byName(QueueFactoryInterface.WORKERJOB_NAMED) | ||
); | ||
this.jdbcworkerjobQueueService = applicationContext.getBean(JdbcWorkerJobQueueService.class); | ||
} | ||
|
||
@Override | ||
public Runnable receive(String consumerGroup, Class<?> queueType, Consumer<Either<WorkerJob, DeserializationException>> consumer) { | ||
return workerTaskQueue.receive(consumerGroup, queueType, consumer); | ||
return jdbcworkerjobQueueService.receive(consumerGroup, queueType, consumer); | ||
} | ||
|
||
@Override | ||
public void pause() { | ||
jdbcworkerjobQueueService.pause(); | ||
} | ||
|
||
@Override | ||
public void cleanup() { | ||
jdbcworkerjobQueueService.cleanup(); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
|
||
jdbcworkerjobQueueService.close(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
jdbc-h2/src/main/resources/migrations/h2/V1_2__worker_heartbeat.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* ----------------------- workerInstance ----------------------- */ | ||
CREATE TABLE IF NOT EXISTS worker_instance ( | ||
"key" VARCHAR(250) NOT NULL PRIMARY KEY, | ||
"value" TEXT NOT NULL, | ||
"worker_uuid" VARCHAR(36) NOT NULL GENERATED ALWAYS AS (JQ_STRING("value",'.workerUuid')), | ||
"hostname" VARCHAR(150) NOT NULL GENERATED ALWAYS AS (JQ_STRING("value",'.hostname')), | ||
"port" INT GENERATED ALWAYS AS (JQ_INTEGER("value",'.port')), | ||
"management_port" INT GENERATED ALWAYS AS (JQ_INTEGER("value",'.managementPort')), | ||
"worker_group" VARCHAR(150) GENERATED ALWAYS AS (JQ_STRING("value",'.workerGroup')), | ||
"status" VARCHAR(10) NOT NULL GENERATED ALWAYS AS (JQ_STRING("value",'.status')), | ||
"heartbeat_date" TIMESTAMP NOT NULL GENERATED ALWAYS AS (PARSEDATETIME(JQ_STRING("value", '.heartbeatDate'), 'yyyy-MM-dd''T''HH:mm:ss.SSSXXX')) | ||
); | ||
|
||
/* ----------------------- worker_job_running ----------------------- */ | ||
CREATE TABLE IF NOT EXISTS worker_job_running ( | ||
"key" VARCHAR(250) NOT NULL PRIMARY KEY, | ||
"value" TEXT NOT NULL, | ||
"worker_uuid" VARCHAR(36) NOT NULL GENERATED ALWAYS AS (JQ_STRING("value",'.workerInstance.workerUuid')), | ||
"taskrun_id" VARCHAR(150) NOT NULL GENERATED ALWAYS AS (JQ_STRING("value",'.taskRun.id')) | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS worker_job_running_worker_uuid ON worker_job_running ("worker_uuid"); |
6 changes: 6 additions & 0 deletions
6
jdbc-h2/src/test/java/io/kestra/repository/h2/H2WorkerInstanceRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.kestra.repository.h2; | ||
|
||
import io.kestra.jdbc.repository.AbstractJdbcWorkerInstanceRepositoryTest; | ||
|
||
public class H2WorkerInstanceRepositoryTest extends AbstractJdbcWorkerInstanceRepositoryTest { | ||
} |
Oops, something went wrong.