Fix config change watching issue

This commit is contained in:
Steven Zou 2017-07-25 19:47:05 +08:00
parent 7f96ba48bc
commit 7c2699953d
4 changed files with 9 additions and 3 deletions

View File

@ -2,7 +2,6 @@ package notifier
import (
"errors"
"reflect"
"github.com/vmware/harbor/src/common/models"
"github.com/vmware/harbor/src/common/utils"
@ -27,8 +26,10 @@ func WatchConfigChanges(cfg map[string]interface{}) error {
}
if t, yes := policyCfg.Parm["daily_time"]; yes {
if reflect.TypeOf(t).Kind() == reflect.Int {
policyNotification.DailyTime = (int64)(t.(int))
if dt, success := t.(float64); success {
policyNotification.DailyTime = (int64)(dt)
} else {
return errors.New("Invalid daily_time type")
}
}

View File

@ -200,6 +200,8 @@ func (nw *NotificationWatcher) Notify(notification Notification) error {
if err := hd.Handle(notification.Value); err != nil {
//Currently, we just log the error
log.Errorf("Error occurred when triggerring handler %s of topic %s: %s\n", reflect.TypeOf(hd).String(), notification.Topic, err.Error())
} else {
log.Infof("Handle notification with topic '%s': %#v\n", notification.Topic, notification.Value)
}
}()
}(h, handlerChan)

View File

@ -5,6 +5,7 @@ import (
"time"
"github.com/vmware/harbor/src/common/scheduler/task"
"github.com/vmware/harbor/src/common/utils/log"
)
//AlternatePolicyConfiguration store the related configurations for alternate policy.
@ -125,6 +126,7 @@ func (alp *AlternatePolicy) Evaluate() (<-chan bool, error) {
}
if diff > 0 {
//Wait for a while.
log.Infof("Waiting for %d seconds after comparing offset %d and utc time %d\n", diff, alp.config.OffsetTime, utcTime)
select {
case <-time.After(time.Duration(diff) * time.Second):
case <-alp.terminator:

View File

@ -70,6 +70,7 @@ func (wc *Watcher) Start() {
select {
case <-evalChan:
{
log.Infof("Receive evaluation signal from policy '%s'\n", pl.Name())
//Start to run the attached tasks.
for _, t := range pl.Tasks() {
go func(tk task.Task) {