实现持久化 assignment handoff
This commit is contained in:
@@ -6,8 +6,8 @@ import (
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"git.ddupan.top/panxiao81/gitea-dynamic-runner/internal/taskassignment"
|
||||
"git.ddupan.top/panxiao81/gitea-dynamic-runner/internal/taskidentity"
|
||||
"git.ddupan.top/panxiao81/gitea-dynamic-runner/internal/taskscheduler"
|
||||
)
|
||||
|
||||
// Phase is observed from Kubernetes or OpenSandbox, never stored by the worker.
|
||||
@@ -38,7 +38,7 @@ type Metadata struct {
|
||||
// Every method must be idempotent.
|
||||
type Backend interface {
|
||||
Find(context.Context, string) (*Executor, error)
|
||||
Create(context.Context, taskscheduler.Assignment, Metadata) (*Executor, error)
|
||||
Create(context.Context, taskassignment.Assignment, Metadata) (*Executor, error)
|
||||
BindIdentity(context.Context, *Executor, taskidentity.Identity) error
|
||||
Delete(context.Context, *Executor) error
|
||||
}
|
||||
@@ -59,7 +59,7 @@ type Worker struct {
|
||||
|
||||
// Handle performs one reconciliation. Done means the queue message may be
|
||||
// acknowledged. A false result should remain pending and be reconciled again.
|
||||
func (w Worker) Handle(ctx context.Context, assignment taskscheduler.Assignment) (done bool, err error) {
|
||||
func (w Worker) Handle(ctx context.Context, assignment taskassignment.Assignment) (done bool, err error) {
|
||||
if w.Backend == nil || w.Tasks == nil {
|
||||
return false, errors.New("backend and Gitea task state are required")
|
||||
}
|
||||
@@ -114,11 +114,12 @@ func (w Worker) Handle(ctx context.Context, assignment taskscheduler.Assignment)
|
||||
}
|
||||
|
||||
// BackendMetadata is the shared metadata contract for Pods and OpenSandbox.
|
||||
func BackendMetadata(assignment taskscheduler.Assignment) Metadata {
|
||||
func BackendMetadata(assignment taskassignment.Assignment) Metadata {
|
||||
return Metadata{
|
||||
Labels: map[string]string{
|
||||
"ci.ddupan.top/assignment-id": assignment.ID,
|
||||
"ci.ddupan.top/task-id": strconv.FormatInt(assignment.Task.GetId(), 10),
|
||||
"ci.ddupan.top/backend": string(assignment.Backend),
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
"ci.ddupan.top/repository": assignment.Identity.Repository,
|
||||
|
||||
Reference in New Issue
Block a user