fix(glance): set glance s3 bucket name default onecloud-images (#24171)

This commit is contained in:
wanyaoqi
2026-02-01 20:10:57 +08:00
committed by GitHub
parent e1730556e1
commit a1bfcc1d9f
3 changed files with 19 additions and 1 deletions
+1 -1
View File
@@ -182,7 +182,7 @@ type S3CommonOptions struct {
S3SecretKey string `help:"s3 secret key"`
S3Endpoint string `help:"s3 endpoint"`
S3UseSSL bool `help:"s3 access use ssl"`
S3BucketName string `help:"s3 bucket name" default:"onecloud-screendump"`
S3BucketName string `help:"s3 bucket name"`
S3BucketLifecycleKeepDay int `help:"s3 bucket lifecycle keep day" default:"180"`
}
+6
View File
@@ -172,6 +172,8 @@ func (host *SHostService) initHandlers(app *appsrv.Application) {
app_common.ExportOptionsHandler(app, &options.HostOptions)
}
const DEFAULT_SCREENDUMP_S3_BUCKET = "onecloud-screendump-new"
func initS3() {
url := options.HostOptions.S3Endpoint
if len(url) == 0 {
@@ -185,6 +187,10 @@ func initS3() {
}
url = prefix + url
}
if options.HostOptions.S3BucketName == "" {
options.HostOptions.S3BucketName = DEFAULT_SCREENDUMP_S3_BUCKET
}
err := s3.Init(
url,
options.HostOptions.S3AccessKey,
+12
View File
@@ -204,7 +204,13 @@ func hasVmwareAccount() (bool, error) {
return res.Total > 0, nil
}
const DEFAULT_IMAGE_S3_BUCKET = "onecloud-images"
func initS3() {
if options.Options.S3BucketName == "" {
options.Options.S3BucketName = DEFAULT_IMAGE_S3_BUCKET
}
err := s3.Init(
options.Options.S3Endpoint,
options.Options.S3AccessKey,
@@ -216,6 +222,12 @@ func initS3() {
if err != nil {
log.Fatalf("failed init s3 client %s", err)
}
if options.Options.S3BucketName == "onecloud-screendump" {
if err = s3.SetBucketLifecycle(""); err != nil {
log.Warningf("remove onecloud-screendump lifecycle %s", err)
}
}
func() {
fd, err := os.OpenFile("/tmp/s3-pass", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {