From ad3f592747cf1840405502d3bae26d7d55309b24 Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Tue, 15 Nov 2022 00:49:46 +0800 Subject: [PATCH] fix(scheduler): ignore fetch disk image failed (#15361) --- .../predicates/class_metadata_predicate.go | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/pkg/scheduler/algorithm/predicates/class_metadata_predicate.go b/pkg/scheduler/algorithm/predicates/class_metadata_predicate.go index 279d7c3423..6d8a73d9c7 100644 --- a/pkg/scheduler/algorithm/predicates/class_metadata_predicate.go +++ b/pkg/scheduler/algorithm/predicates/class_metadata_predicate.go @@ -95,24 +95,23 @@ func (p *ClassMetadataPredicate) PreExecute(ctx context.Context, u *core.Unit, c } stand = obj.(db.IStandaloneModel) case len(disks) == 0: + break case disks[0].ImageId != "": obj, err := models.CachedimageManager.GetCachedimageById(ctx, auth.AdminCredential(), disks[0].ImageId, false) - if err != nil { - return false, errors.Wrapf(err, "unable to fetch cachedimage %s", disks[0].ImageId) - } - // 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 - guestSource.keyword = "image" + if err == nil { + // 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 + guestSource.keyword = "image" + } } case disks[0].SnapshotId != "": obj, err := models.SnapshotManager.FetchById(disks[0].SnapshotId) - if err != nil { - return false, errors.Wrapf(err, "unable to fetch snapshot %s", disks[0].SnapshotId) + if err == nil { + stand = obj.(db.IStandaloneModel) } - stand = obj.(db.IStandaloneModel) case disks[0].BackupId != "": obj, err := models.DiskBackupManager.FetchById(disks[0].BackupId) if err != nil {