From cb409c75b88849934f4e38e8948f75e080909cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Thu, 7 Nov 2024 09:48:31 +0800 Subject: [PATCH] fix(glance): image stream worker count (#21538) --- pkg/image/models/images.go | 5 ++++- pkg/image/options/options.go | 2 ++ pkg/image/service/service.go | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/image/models/images.go b/pkg/image/models/images.go index 17c1bd3a49..2413dcd40d 100644 --- a/pkg/image/models/images.go +++ b/pkg/image/models/images.go @@ -92,7 +92,10 @@ func init() { } ImageManager.SetVirtualObject(ImageManager) - imgStreamingWorkerMan = appsrv.NewWorkerManager("image_streaming_worker", 10, 1024, true) +} + +func InitImageStreamWorkers() { + imgStreamingWorkerMan = appsrv.NewWorkerManager("image_streaming_worker", options.Options.ImageStreamWorkerCount, 1024, true) } /* diff --git a/pkg/image/options/options.go b/pkg/image/options/options.go index bd1a155bc3..e1a308dcd3 100644 --- a/pkg/image/options/options.go +++ b/pkg/image/options/options.go @@ -51,6 +51,8 @@ type SImageOptions struct { S3BucketName string `help:"s3 bucket name" default:"onecloud-images"` S3MountPoint string `help:"s3fs mount point" default:"/opt/cloud/workspace/data/glance/s3images"` S3CheckImageStatus bool `help:"Enable s3 check image status"` + + ImageStreamWorkerCount int `help:"Image stream worker count" default:"10"` } var ( diff --git a/pkg/image/service/service.go b/pkg/image/service/service.go index 633591f012..b57511ef94 100644 --- a/pkg/image/service/service.go +++ b/pkg/image/service/service.go @@ -68,6 +68,8 @@ func StartService() { common_options.StartOptionManager(opts, opts.ConfigSyncPeriodSeconds, api.SERVICE_TYPE, api.SERVICE_VERSION, options.OnOptionsChange) + models.InitImageStreamWorkers() + if opts.PortV2 > 0 { log.Infof("Port V2 %d is specified, use v2 port", opts.PortV2) opts.Port = opts.PortV2