Merge pull request #6126 from reasonerjt/no-scanall-bootstrap

Not submit scan all job when core container starts
This commit is contained in:
Wenkai Yin 2018-10-26 12:45:01 +08:00 committed by GitHub
commit 591e3df9c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 ... // DefaultScanAllPolicy ...
var DefaultScanAllPolicy = ScanAllPolicy{ var DefaultScanAllPolicy = ScanAllPolicy{
Type: ScanAllDaily, Type: ScanAllNone,
Parm: map[string]interface{}{
ScanAllDailyTime: 0,
},
} }

View File

@ -181,7 +181,7 @@ func TestConfig(t *testing.T) {
t.Errorf("unexpected mode: %s != %s", mode, "db_auth") 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) t.Errorf("unexpected scan all policy %v", s)
} }

View File

@ -18,7 +18,6 @@ import (
"encoding/gob" "encoding/gob"
"fmt" "fmt"
"os" "os"
"reflect"
"strconv" "strconv"
"github.com/astaxie/beego" "github.com/astaxie/beego"
@ -122,22 +121,6 @@ func main() {
if err := dao.InitClairDB(clairDB); err != nil { if err := dao.InitClairDB(clairDB); err != nil {
log.Fatalf("failed to initialize clair database: %v", err) 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 { if err := core.Init(); err != nil {