Not submit scan all job when core container starts

Fixes #6115

As for the change in migration sql file, in 1.7 we'll switch to
jobservice for scheduling "scan all" job.  To avoid inconsistency,
this item will be reset and user will need to configure the policy again.

Signed-off-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
Daniel Jiang 2018-10-24 17:16:54 +08:00
parent 6c033574fa
commit 39b4d011c7
5 changed files with 4 additions and 23 deletions

View File

@ -0,0 +1,2 @@
ALTER TABLE properties ALTER COLUMN v TYPE varchar(1024);
DELETE FROM properties where k='scan_all_policy';

View File

@ -1 +0,0 @@
ALTER TABLE properties ALTER COLUMN v TYPE varchar(1024);

View File

@ -131,8 +131,5 @@ const (
// DefaultScanAllPolicy ...
var DefaultScanAllPolicy = ScanAllPolicy{
Type: ScanAllDaily,
Parm: map[string]interface{}{
ScanAllDailyTime: 0,
},
Type: ScanAllNone,
}

View File

@ -181,7 +181,7 @@ func TestConfig(t *testing.T) {
t.Errorf("unexpected mode: %s != %s", mode, "db_auth")
}
if s := ScanAllPolicy(); s.Type != "daily" {
if s := ScanAllPolicy(); s.Type != "none" {
t.Errorf("unexpected scan all policy %v", s)
}

View File

@ -18,7 +18,6 @@ import (
"encoding/gob"
"fmt"
"os"
"reflect"
"strconv"
"github.com/astaxie/beego"
@ -122,22 +121,6 @@ func main() {
if err := dao.InitClairDB(clairDB); err != nil {
log.Fatalf("failed to initialize clair database: %v", err)
}
// Get policy configuration.
scanAllPolicy := config.ScanAllPolicy()
if scanAllPolicy.Type == notifier.PolicyTypeDaily {
dailyTime := 0
if t, ok := scanAllPolicy.Parm["daily_time"]; ok {
if reflect.TypeOf(t).Kind() == reflect.Int {
dailyTime = t.(int)
}
}
// Send notification to handle first policy change.
if err = notifier.Publish(notifier.ScanAllPolicyTopic,
notifier.ScanPolicyNotification{Type: scanAllPolicy.Type, DailyTime: (int64)(dailyTime)}); err != nil {
log.Errorf("failed to publish scan all policy topic: %v", err)
}
}
}
if err := core.Init(); err != nil {