This commit is contained in:
Wenkai Yin 2016-05-16 13:57:30 +08:00
parent c95fbb6e3f
commit 5e5fc9b2cb
5 changed files with 15 additions and 7 deletions

View File

@ -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
}

View File

@ -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/"
}

View File

@ -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,

View File

@ -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 {

View File

@ -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)