diff --git a/pkg/image/options/options.go b/pkg/image/options/options.go index e1a308dcd3..4a185ebb8f 100644 --- a/pkg/image/options/options.go +++ b/pkg/image/options/options.go @@ -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 +} diff --git a/pkg/image/service/service.go b/pkg/image/service/service.go index 5f548908a6..8ed467375a 100644 --- a/pkg/image/service/service.go +++ b/pkg/image/service/service.go @@ -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() }