mirror of
https://github.com/rancher/rke.git
synced 2025-09-01 23:16:22 +00:00
Determine etcd s3 snapshots by s3 config presence
This commit is contained in:
@@ -378,7 +378,6 @@ func RunEtcdSnapshotSave(ctx context.Context, etcdHost *hosts.Host, prsMap map[s
|
||||
}
|
||||
|
||||
func DownloadEtcdSnapshotFromS3(ctx context.Context, etcdHost *hosts.Host, prsMap map[string]v3.PrivateRegistry, etcdSnapshotImage string, name string, es v3.ETCDService) error {
|
||||
log.Infof(ctx, "[etcd] Get snapshot [%s] on host [%s]", name, etcdHost.Address)
|
||||
s3Backend := es.BackupConfig.S3BackupConfig
|
||||
if len(s3Backend.Endpoint) == 0 || len(s3Backend.BucketName) == 0 {
|
||||
return fmt.Errorf("failed to get snapshot [%s] from s3 on host [%s], invalid s3 configurations", name, etcdHost.Address)
|
||||
@@ -399,13 +398,21 @@ func DownloadEtcdSnapshotFromS3(ctx context.Context, etcdHost *hosts.Host, prsMa
|
||||
Image: etcdSnapshotImage,
|
||||
Env: es.ExtraEnv,
|
||||
}
|
||||
s3Logline := fmt.Sprintf("[etcd] Snapshot [%s] will be downloaded on host [%s] from S3 compatible backend at [%s] from bucket [%s] using accesskey [%s]", name, etcdHost.Address, s3Backend.Endpoint, s3Backend.BucketName, s3Backend.AccessKey)
|
||||
if s3Backend.Region != "" {
|
||||
s3Logline += fmt.Sprintf(" and using region [%s]", s3Backend.Region)
|
||||
}
|
||||
|
||||
if s3Backend.CustomCA != "" {
|
||||
caStr := base64.StdEncoding.EncodeToString([]byte(s3Backend.CustomCA))
|
||||
imageCfg.Cmd = append(imageCfg.Cmd, "--s3-endpoint-ca="+caStr)
|
||||
s3Logline += fmt.Sprintf(" and using endpoint CA [%s]", caStr)
|
||||
}
|
||||
if s3Backend.Folder != "" {
|
||||
imageCfg.Cmd = append(imageCfg.Cmd, "--s3-folder="+s3Backend.Folder)
|
||||
s3Logline += fmt.Sprintf(" and using folder [%s]", s3Backend.Folder)
|
||||
}
|
||||
log.Infof(ctx, s3Logline)
|
||||
hostCfg := &container.HostConfig{
|
||||
Binds: []string{
|
||||
fmt.Sprintf("%s:/backup:z", EtcdSnapshotPath),
|
||||
@@ -610,7 +617,10 @@ func configS3BackupImgCmd(ctx context.Context, imageCfg *container.Config, bc *v
|
||||
"--s3-bucketName=" + bc.S3BackupConfig.BucketName,
|
||||
"--s3-region=" + bc.S3BackupConfig.Region,
|
||||
}...)
|
||||
s3Logline := fmt.Sprintf("[etcd] Snapshot will be uploaded to S3 compatible backend at [%s] in region [%s] to bucket [%s] using accesskey [%s]", bc.S3BackupConfig.Endpoint, bc.S3BackupConfig.Region, bc.S3BackupConfig.BucketName, bc.S3BackupConfig.AccessKey)
|
||||
s3Logline := fmt.Sprintf("[etcd] Snapshots configured to S3 compatible backend at [%s] to bucket [%s] using accesskey [%s]", bc.S3BackupConfig.Endpoint, bc.S3BackupConfig.BucketName, bc.S3BackupConfig.AccessKey)
|
||||
if bc.S3BackupConfig.Region != "" {
|
||||
s3Logline += fmt.Sprintf(" and using region [%s]", bc.S3BackupConfig.Region)
|
||||
}
|
||||
if bc.S3BackupConfig.CustomCA != "" {
|
||||
caStr := base64.StdEncoding.EncodeToString([]byte(bc.S3BackupConfig.CustomCA))
|
||||
cmd = append(cmd, "--s3-endpoint-ca="+caStr)
|
||||
|
Reference in New Issue
Block a user