mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-30 20:48:23 +01:00
commit
8845331d60
@ -2,6 +2,7 @@ package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/vmware/harbor/models"
|
||||
)
|
||||
@ -107,7 +108,7 @@ func UpdateRepJobStatus(id int64, status string) error {
|
||||
}
|
||||
num, err := o.Update(&j, "Status")
|
||||
if num == 0 {
|
||||
err = fmt.Errorf("Failed to update replication job with id: %d", id)
|
||||
err = fmt.Errorf("Failed to update replication job with id: %d %s", id, err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/vmware/harbor/utils/log"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/vmware/harbor/utils/log"
|
||||
)
|
||||
|
||||
const defaultMaxWorkers int = 10
|
||||
@ -20,7 +21,7 @@ func init() {
|
||||
maxJobWorkers = defaultMaxWorkers
|
||||
}
|
||||
|
||||
localRegURL := os.Getenv("LOCAL_REGISTRY_URL")
|
||||
localRegURL = os.Getenv("LOCAL_REGISTRY_URL")
|
||||
if len(localRegURL) == 0 {
|
||||
localRegURL = "http://registry:5000/"
|
||||
}
|
||||
|
@ -67,6 +67,9 @@ type BaseHandler struct {
|
||||
func InitBaseHandler(repository, srcURL, srcSecretKey,
|
||||
dstURL, dstUsr, dstPwd string, tags []string, logger *utils.Logger) (*BaseHandler, error) {
|
||||
|
||||
logger.Infof("initializing base handler: repository: %s, tags: %v, source URL: %s, destination URL: %s, destination user: %s",
|
||||
repository, tags, srcURL, dstURL, dstUsr)
|
||||
|
||||
base := &BaseHandler{
|
||||
repository: repository,
|
||||
tags: tags,
|
||||
|
@ -141,12 +141,15 @@ func (sm *JobSM) Init() {
|
||||
sm.lock = &sync.Mutex{}
|
||||
sm.Handlers = make(map[string]StateHandler)
|
||||
sm.Transitions = make(map[string]map[string]struct{})
|
||||
sm.AddTransition(models.JobPending, models.JobRunning, StatusUpdater{DummyHandler{JobID: sm.JobID}, models.JobRunning})
|
||||
sm.Handlers[models.JobError] = StatusUpdater{DummyHandler{JobID: sm.JobID}, models.JobError}
|
||||
sm.Handlers[models.JobStopped] = StatusUpdater{DummyHandler{JobID: sm.JobID}, models.JobStopped}
|
||||
|
||||
}
|
||||
func (sm *JobSM) Reset(jid int64) error {
|
||||
sm.JobID = jid
|
||||
|
||||
sm.AddTransition(models.JobPending, models.JobRunning, StatusUpdater{DummyHandler{JobID: sm.JobID}, models.JobRunning})
|
||||
sm.Handlers[models.JobError] = StatusUpdater{DummyHandler{JobID: sm.JobID}, models.JobError}
|
||||
sm.Handlers[models.JobStopped] = StatusUpdater{DummyHandler{JobID: sm.JobID}, models.JobStopped}
|
||||
|
||||
//init parms
|
||||
job, err := dao.GetRepJob(sm.JobID)
|
||||
if err != nil {
|
||||
|
@ -43,7 +43,7 @@ func (w *Worker) Stop() {
|
||||
func (w *Worker) handleRepJob(id int64) {
|
||||
err := w.SM.Reset(id)
|
||||
if err != nil {
|
||||
log.Errorf("Worker %d, failed to re-initialize statemachine, error: %v", err)
|
||||
log.Errorf("Worker %d, failed to re-initialize statemachine, error: %v", w.ID, err)
|
||||
err2 := dao.UpdateRepJobStatus(id, models.JobError)
|
||||
if err2 != nil {
|
||||
log.Errorf("Failed to update job status to ERROR, error:%v", err2)
|
||||
|
Loading…
Reference in New Issue
Block a user