From 8b543cb87e1204ab182d16632878050e1c966032 Mon Sep 17 00:00:00 2001 From: Furkat Gofurov Date: Wed, 8 Jan 2025 23:32:57 +0200 Subject: [PATCH] Fix setting folder S3 on etcd backups Signed-off-by: Furkat Gofurov --- pkg/rke2/config.go | 11 ++++------- pkg/rke2/config_test.go | 7 +------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/pkg/rke2/config.go b/pkg/rke2/config.go index a4a541d6..f3b4ea2d 100644 --- a/pkg/rke2/config.go +++ b/pkg/rke2/config.go @@ -319,16 +319,13 @@ func newRKE2ServerConfig(opts ServerConfigOpts) (*ServerConfig, []bootstrapv1.Fi }) } - rke2ServerConfig.EtcdSnapshotDir = opts.ServerConfig.Etcd.BackupConfig.S3.Folder - rke2ServerConfig.EtcdS3SkipSslVerify = !opts.ServerConfig.Etcd.BackupConfig.S3.EnforceSSLVerify - } else { rke2ServerConfig.EtcdSnapshotDir = opts.ServerConfig.Etcd.BackupConfig.Directory + rke2ServerConfig.EtcdSnapshotName = opts.ServerConfig.Etcd.BackupConfig.SnapshotName + rke2ServerConfig.EtcdSnapshotRetention = opts.ServerConfig.Etcd.BackupConfig.Retention + rke2ServerConfig.EtcdSnapshotScheduleCron = opts.ServerConfig.Etcd.BackupConfig.ScheduleCron + rke2ServerConfig.EtcdS3SkipSslVerify = !opts.ServerConfig.Etcd.BackupConfig.S3.EnforceSSLVerify } - rke2ServerConfig.EtcdSnapshotName = opts.ServerConfig.Etcd.BackupConfig.SnapshotName - rke2ServerConfig.EtcdSnapshotRetention = opts.ServerConfig.Etcd.BackupConfig.Retention - rke2ServerConfig.EtcdSnapshotScheduleCron = opts.ServerConfig.Etcd.BackupConfig.ScheduleCron - if opts.ServerConfig.Etcd.CustomConfig != nil { rke2ServerConfig.EtcdArgs = opts.ServerConfig.Etcd.CustomConfig.ExtraArgs rke2ServerConfig.EtcdImage = opts.ServerConfig.Etcd.CustomConfig.OverrideImage diff --git a/pkg/rke2/config_test.go b/pkg/rke2/config_test.go index b0394b11..7b3f25f7 100644 --- a/pkg/rke2/config_test.go +++ b/pkg/rke2/config_test.go @@ -121,7 +121,6 @@ var _ = Describe("RKE2ServerConfig", func() { Bucket: "testbucket", Region: "testregion", Endpoint: "testendpoint", - Folder: "testfolder", EnforceSSLVerify: true, }, Directory: "testdir", @@ -195,11 +194,7 @@ var _ = Describe("RKE2ServerConfig", func() { Expect(rke2ServerConfig.EtcdS3Folder).To(Equal(serverConfig.Etcd.BackupConfig.S3.Folder)) Expect(rke2ServerConfig.EtcdS3Endpoint).To(Equal(serverConfig.Etcd.BackupConfig.S3.Endpoint)) Expect(rke2ServerConfig.EtcdS3EndpointCA).To(Equal("/etc/rancher/rke2/etcd-s3-ca.crt")) - if serverConfig.Etcd.BackupConfig.S3 != nil { - Expect(rke2ServerConfig.EtcdSnapshotDir).To(Equal(serverConfig.Etcd.BackupConfig.S3.Folder)) - } else { - Expect(rke2ServerConfig.EtcdSnapshotDir).To(Equal(serverConfig.Etcd.BackupConfig.Directory)) - } + Expect(rke2ServerConfig.EtcdSnapshotDir).To(Equal(serverConfig.Etcd.BackupConfig.Directory)) Expect(rke2ServerConfig.EtcdSnapshotName).To(Equal(serverConfig.Etcd.BackupConfig.SnapshotName)) Expect(rke2ServerConfig.EtcdSnapshotRetention).To(Equal(serverConfig.Etcd.BackupConfig.Retention)) Expect(rke2ServerConfig.EtcdSnapshotScheduleCron).To(Equal(serverConfig.Etcd.BackupConfig.ScheduleCron))