fix(preheat):remove health property check when saving instance

Signed-off-by: Steven Zou <szou@vmware.com>
This commit is contained in:
Steven Zou 2020-07-17 16:11:43 +08:00
parent af3a638980
commit 3c02b5da03
3 changed files with 4 additions and 7 deletions

View File

@ -26,7 +26,6 @@ var ErrorUnhealthy = errors.New("instance unhealthy")
// Controller defines related top interfaces to handle the workflow of // Controller defines related top interfaces to handle the workflow of
// the image distribution. // the image distribution.
// TODO: Add health check API
type Controller interface { type Controller interface {
// Get all the supported distribution providers // Get all the supported distribution providers
// //
@ -166,10 +165,8 @@ func (c *controller) CreateInstance(ctx context.Context, instance *providerModel
return 0, ErrorConflict return 0, ErrorConflict
} }
// !WARN: Check healthy status at fronted. // !WARN: We don't check the health of the instance here.
if instance.Status != "healthy" { // That is ok because the health of instance will be checked before enforcing the policy each time.
return 0, ErrorUnhealthy
}
instance.SetupTimestamp = time.Now().Unix() instance.SetupTimestamp = time.Now().Unix()

View File

@ -126,7 +126,7 @@ func (s *preheatSuite) TestCreateInstance() {
id, err = s.controller.CreateInstance(s.ctx, &providerModel.Instance{ id, err = s.controller.CreateInstance(s.ctx, &providerModel.Instance{
Endpoint: "http://localhost", Endpoint: "http://localhost",
}) })
s.Equal(ErrorUnhealthy, err) s.Equal(ErrorConflict, err)
s.Empty(id) s.Empty(id)
// Case: instance with invalid provider, expect error. // Case: instance with invalid provider, expect error.

View File

@ -603,7 +603,7 @@ func overrideSecuritySettings(p *pol.Schema, pro *models.Project) [][]interface{
case pol.FilterTypeVulnerability: case pol.FilterTypeVulnerability:
if v, ok := pro.Metadata[proMetaKeyVulnerability]; ok && v == "true" { if v, ok := pro.Metadata[proMetaKeyVulnerability]; ok && v == "true" {
if se, ok := pro.Metadata[proMetaKeySeverity]; ok && len(se) > 0 { if se, ok := pro.Metadata[proMetaKeySeverity]; ok && len(se) > 0 {
se = strings.ToTitle(se) se = strings.ToTitle(strings.ToLower(se))
code := vuln.Severity(se).Code() code := vuln.Severity(se).Code()
if sev, ok := fl.Value.(int); !ok || (ok && sev < code) { if sev, ok := fl.Value.(int); !ok || (ok && sev < code) {