fix: glance always init s3 client (#22129)

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2025-03-03 20:15:29 +08:00
committed by GitHub
co-authored by Qiu Jian
parent 58b90f1d9c
commit c25e1b5981
2 changed files with 11 additions and 9 deletions
+4
View File
@@ -80,3 +80,7 @@ func OnOptionsChange(oldO, newO interface{}) bool {
return changed
}
func (opt SImageOptions) HasValidS3Options() bool {
return len(opt.S3Endpoint) > 0 && len(opt.S3AccessKey) > 0 && len(opt.S3SecretKey) > 0 && len(opt.S3BucketName) > 0
}
+7 -9
View File
@@ -139,12 +139,13 @@ func StartService() {
deployclient.Init(options.Options.DeployServerSocketPath)
}
if options.Options.StorageDriver == api.IMAGE_STORAGE_DRIVER_S3 {
go initS3()
} else {
// Check the images after everything is ready
go models.CheckImages()
}
go func() {
if options.Options.HasValidS3Options() {
initS3()
}
// check image after s3 mounted
models.CheckImages()
}()
if !opts.IsSlaveNode {
cachesync.StartTenantCacheSync(opts.TenantCacheExpireSeconds)
@@ -253,7 +254,4 @@ func initS3() {
break
}
}
// check image after s3 mounted
models.CheckImages()
}