From 797039a3995b7bc689a76ee8cbcebce22e2bc995 Mon Sep 17 00:00:00 2001 From: rainzm Date: Thu, 3 Dec 2020 20:35:17 +0800 Subject: [PATCH] fix(region): inspect invalid guest template The glance service hangs and other external reasons may cause the guest template to be judged as invalid. Therefore, health inspection should be performed on time for invalid guest templates. --- pkg/compute/models/guest_template.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/compute/models/guest_template.go b/pkg/compute/models/guest_template.go index 3c484ecab3..38dd5ea4f1 100644 --- a/pkg/compute/models/guest_template.go +++ b/pkg/compute/models/guest_template.go @@ -791,6 +791,7 @@ func (gt *SGuestTemplate) inspect(ctx context.Context, userCred mcclient.TokenCr _, err := GuestTemplateManager.validateContent(ctx, userCred, gt.GetOwnerId(), jsonutils.NewDict(), gt.Content.(*jsonutils.JSONDict)) if err == nil { gt.updateCheckTime() + gt.SetStatus(userCred, computeapis.GT_READY, "inspect successfully") logclient.AddSimpleActionLog(gt, logclient.ACT_HEALTH_CHECK, "", userCred, true) return nil } @@ -804,7 +805,7 @@ func (gt *SGuestTemplate) inspect(ctx context.Context, userCred mcclient.TokenCr func (gm *SGuestTemplateManager) InspectAllTemplate(ctx context.Context, userCred mcclient.TokenCredential, isStart bool) { lastCheckTime := time.Now().Add(time.Duration(-options.Options.GuestTemplateCheckInterval) * time.Hour) - q := gm.Query().Equals("status", computeapis.GT_READY) + q := gm.Query() q = q.Filter(sqlchemy.OR(sqlchemy.IsNull(q.Field("last_check_time")), sqlchemy.LE(q.Field("last_check_time"), lastCheckTime))) gts := make([]SGuestTemplate, 0, 10)