mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 10:45:45 +01:00
Merge pull request #2865 from vmware/fix_issue_#2680
Fix config change watching issue
This commit is contained in:
commit
8612a9ac84
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user