mirror of
https://github.com/go-gitea/gitea.git
synced 2025-04-08 17:05:45 +02:00
chore(runner): add soft deleted field
This commit is contained in:
parent
9648482ed6
commit
699f5c5a06
2
go.mod
2
go.mod
@ -107,6 +107,7 @@ require (
|
||||
golang.org/x/text v0.4.0
|
||||
golang.org/x/tools v0.1.12
|
||||
google.golang.org/grpc v1.47.0
|
||||
google.golang.org/protobuf v1.28.1
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||
gopkg.in/ini.v1 v1.67.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
@ -299,7 +300,6 @@ require (
|
||||
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
|
2
go.sum
2
go.sum
@ -83,8 +83,6 @@ git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4H
|
||||
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
|
||||
gitea.com/gitea/act v0.0.0-20221008102131-d89ab14fb580 h1:F/VSl4oP5Gqe0FQ2i6BX/ODIhBc/cxfp5p5yA8pOSb4=
|
||||
gitea.com/gitea/act v0.0.0-20221008102131-d89ab14fb580/go.mod h1:lpzib6X73FHLSaTqTakan1xcsCAVhlZvPSpLns7jkRo=
|
||||
gitea.com/gitea/proto-go v0.0.0-20221010074642-cc3659a7348b h1:BEEgR2+rEOyWGbY3iyGCIrv6wmlaj9dAECWONexibrI=
|
||||
gitea.com/gitea/proto-go v0.0.0-20221010074642-cc3659a7348b/go.mod h1:hD8YwSHusjwjEEgubW6XFvnZuNhMZTHz6lwjfltEt/Y=
|
||||
gitea.com/gitea/proto-go v0.0.0-20221010094818-eedee304e2b9 h1:roFxcMnXJrjZvHBfba5Py6Jin9VTTute0WwzRXhJnQs=
|
||||
gitea.com/gitea/proto-go v0.0.0-20221010094818-eedee304e2b9/go.mod h1:hD8YwSHusjwjEEgubW6XFvnZuNhMZTHz6lwjfltEt/Y=
|
||||
gitea.com/go-chi/binding v0.0.0-20220309004920-114340dabecb h1:Yy0Bxzc8R2wxiwXoG/rECGplJUSpXqCsog9PuJFgiHs=
|
||||
|
@ -226,7 +226,7 @@ func GetBuildByRepoAndIndex(repoID, index int64) (*Build, error) {
|
||||
}
|
||||
|
||||
// AssignBuildToRunner assign a build to a runner
|
||||
func AssignBuildToRunner(buildID int64, runnerID int64) error {
|
||||
func AssignBuildToRunner(buildID, runnerID int64) error {
|
||||
cnt, err := db.GetEngine(db.DefaultContext).
|
||||
Where("runner_id=0").
|
||||
And("id=?", buildID).
|
||||
|
@ -81,15 +81,15 @@ func (r *Run) LoadAttributes(ctx context.Context) error {
|
||||
|
||||
// InsertRun inserts a bot run
|
||||
func InsertRun(run *Run, jobs []*jobparser.SingleWorkflow) error {
|
||||
var groupId int64
|
||||
var groupID int64
|
||||
{
|
||||
// tricky way to get resource group id
|
||||
h := fnv.New64()
|
||||
_, _ = h.Write([]byte(fmt.Sprintf("%d_%s", run.RepoID, run.WorkflowID)))
|
||||
groupId = int64(h.Sum64())
|
||||
groupID = int64(h.Sum64())
|
||||
}
|
||||
|
||||
index, err := db.GetNextResourceIndex("bots_run_index", groupId)
|
||||
index, err := db.GetNextResourceIndex("bots_run_index", groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -54,11 +54,8 @@ func (job *RunJob) LoadAttributes(ctx context.Context) error {
|
||||
}
|
||||
job.Run = run
|
||||
}
|
||||
if err := job.Run.LoadAttributes(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return job.Run.LoadAttributes(ctx)
|
||||
}
|
||||
|
||||
// ErrRunJobNotExist represents an error for bot run job not exist
|
||||
|
@ -55,6 +55,8 @@ type Runner struct {
|
||||
|
||||
LastOnline timeutil.TimeStamp `xorm:"index"`
|
||||
Created timeutil.TimeStamp `xorm:"created"`
|
||||
Updated timeutil.TimeStamp `xorm:"updated"`
|
||||
Deleted timeutil.TimeStamp `xorm:"deleted"`
|
||||
}
|
||||
|
||||
func (Runner) TableName() string {
|
||||
|
@ -36,8 +36,9 @@ type RunnerToken struct {
|
||||
Repo *repo_model.Repository `xorm:"-"`
|
||||
IsActive bool
|
||||
|
||||
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
|
||||
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
|
||||
Created timeutil.TimeStamp `xorm:"created"`
|
||||
Updated timeutil.TimeStamp `xorm:"updated"`
|
||||
Deleted timeutil.TimeStamp `xorm:"deleted"`
|
||||
}
|
||||
|
||||
func (RunnerToken) TableName() string {
|
||||
|
@ -21,7 +21,7 @@ type Task struct {
|
||||
Attempt int64
|
||||
RunnerID int64 `xorm:"index"`
|
||||
LogToFile bool // read log from database or from storage
|
||||
LogUrl string // url of the log file in storage
|
||||
LogURL string // url of the log file in storage
|
||||
Result runnerv1.Result
|
||||
Started timeutil.TimeStamp
|
||||
Stopped timeutil.TimeStamp
|
||||
@ -50,11 +50,8 @@ func (task *Task) LoadAttributes(ctx context.Context) error {
|
||||
}
|
||||
task.Job = job
|
||||
}
|
||||
if err := task.Job.LoadAttributes(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return task.Job.LoadAttributes(ctx)
|
||||
}
|
||||
|
||||
func CreateTask(runner *Runner) (*Task, bool, error) {
|
||||
@ -71,7 +68,7 @@ func CreateTask(runner *Runner) (*Task, bool, error) {
|
||||
|
||||
// TODO: a more efficient way to filter labels
|
||||
var job *RunJob
|
||||
labels := append(runner.AgentLabels, runner.CustomLabels...)
|
||||
labels := append([]string{}, append(runner.AgentLabels, runner.CustomLabels...)...)
|
||||
for _, v := range jobs {
|
||||
if isSubset(labels, v.RunsOn) {
|
||||
job = v
|
||||
|
Loading…
x
Reference in New Issue
Block a user