mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-07-01 01:36:11 +08:00
feat(scheduler): class metadata ignore public system image
This commit is contained in:
@@ -18,11 +18,13 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/core"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
type ClassMetadataPredicate struct {
|
||||
@@ -97,8 +99,13 @@ func (p *ClassMetadataPredicate) PreExecute(u *core.Unit, cs []core.Candidater)
|
||||
if err != nil {
|
||||
return false, errors.Wrapf(err, "unable to fetch cachedimage %s", disks[0].ImageId)
|
||||
}
|
||||
stand = &obj.SStandaloneAnonResourceBase
|
||||
guestSource.keyword = "image"
|
||||
// no check if image if system public image
|
||||
public := jsonutils.QueryBoolean(obj.Info, "is_public", false)
|
||||
publicScope, _ := obj.Info.GetString("public_scope")
|
||||
if !public || publicScope != string(rbacutils.ScopeSystem) {
|
||||
stand = &obj.SStandaloneAnonResourceBase
|
||||
guestSource.keyword = "image"
|
||||
}
|
||||
case disks[0].SnapshotId != "":
|
||||
obj, err := models.SnapshotManager.FetchById(disks[0].SnapshotId)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user