mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 06:09:39 +08:00
Merge pull request #10889 from ioito/automated-cherry-pick-of-#10888-upstream-release-3.7
Automated cherry pick of #10888: fix(region): avoid panic when sync resources
This commit is contained in:
@@ -17,6 +17,7 @@ package cronman
|
||||
import (
|
||||
"container/heap"
|
||||
"context"
|
||||
"fmt"
|
||||
"runtime/debug"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -393,7 +394,7 @@ func (job *SCronJob) runJobInWorker(isStart bool) {
|
||||
log.Debugf("Cron job: %s started", job.Name)
|
||||
ctx := context.Background()
|
||||
ctx = context.WithValue(ctx, appctx.APP_CONTEXT_KEY_APPNAME, "Cron-Service")
|
||||
ctx = context.WithValue(ctx, appctx.APP_CONTEXT_KEY_TASKNAME, job.Name)
|
||||
ctx = context.WithValue(ctx, appctx.APP_CONTEXT_KEY_TASKNAME, fmt.Sprintf("%s-%d", job.Name, time.Now().Unix()))
|
||||
userCred := DefaultAdminSessionGenerator()
|
||||
job.job(ctx, userCred, isStart)
|
||||
}
|
||||
|
||||
@@ -431,6 +431,7 @@ func (self *SCloudproviderregion) submitSyncTask(ctx context.Context, userCred m
|
||||
self.markStartSync(userCred)
|
||||
RunSyncCloudproviderRegionTask(ctx, self.getSyncTaskKey(), func() {
|
||||
nopanic.Run(func() {
|
||||
ctx = context.WithValue(ctx, "provider-region", fmt.Sprintf("%d", self.RowId))
|
||||
err := self.DoSync(ctx, userCred, syncRange)
|
||||
if err != nil {
|
||||
log.Errorf("DoSync faild %v", err)
|
||||
|
||||
Reference in New Issue
Block a user