Skip to content

fix s3 snapshot isolation#577

Open
navsalehi wants to merge 1 commit intorancher:mainfrom
navsalehi:fix_s3_snapshot_isolation
Open

fix s3 snapshot isolation#577
navsalehi wants to merge 1 commit intorancher:mainfrom
navsalehi:fix_s3_snapshot_isolation

Conversation

@navsalehi
Copy link
Contributor

This PR adds S3 bucket handling to the snapshot restore tests and introduces reusable helpers (CreateS3Bucket and DeleteS3Bucket) under actions/etcdsnapshot to avoid duplication.

Both K3S and RKE2 tests now create a bucket dynamically, configure ETCD to use S3, validate snapshot/restore, and clean up the bucket during teardown.

@github-actions
Copy link

S3SnapshotRestoreTestSuite TearDownSuite
S3SnapshotRestoreTestSuite TearDownSuite
S3SnapshotRestoreTestSuite SetupSuite
S3SnapshotRestoreTestSuite SetupSuite
S3SnapshotRestoreTestSuite TearDownSuite
S3SnapshotRestoreTestSuite TearDownSuite
S3SnapshotRestoreTestSuite SetupSuite
S3SnapshotRestoreTestSuite SetupSuite

TestSuites above were modified. TestSuites below use modified code from this PR.

s3types "github.com/aws/aws-sdk-go-v2/service/s3/types"
)

// builds AWS config using static credentials and region
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: generally speaking its standard to add the function name to the string so that would mean this would look like

// awsS3Config builds AWS config using static credentials and region

}

func (s *S3SnapshotRestoreTestSuite) TearDownSuite() {
if s.createdTestBucket && s.s3BucketName != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit curious, what would happen if the test failed before creating the S3 bucket. Would this throw a cleanup error and cause the rest of cleanup to not run?

Copy link
Contributor

@markusewalker markusewalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left comments that apply to both K3s and RKE2. Once addressed, let's test again to ensure all is good. Overall, nice job!

@@ -3,22 +3,28 @@
package k3s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will want both k3s and rke2 in our recurring tests, so please be sure to add //go:build validation || recurring at the beginning of both files.

s.session.Cleanup()
}

type awsCredentialsConfig struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think this is necessary. clusterConfig parameter has all of these defined and this test is assumed to be ran with AWS. So this should just be removed.

client *rancher.Client
cattleConfig map[string]any
cluster *v1.SteveAPIObject
s3BucketName string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The s3 params you added in the struct can be removed. You would do this if you reference in a test function, but it doesn't seem that you're doing that in this PR. Since it's all seemingly in the SetupSuite function, you would would just remove these and remove the s. when you do call it in this function.

awsCredsConfig := new(awsCredentialsConfig)
operations.LoadObjectFromMap("awsCredentials", s.cattleConfig, awsCredsConfig)

s.awsAccessKey = awsCredsConfig.AccessKey
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines should be removed; see other comments as to why.

},
}

logrus.Infof("Provisioning K3S cluster with S3 snapshot config. bucket=%s region=%s endpoint=%s credential=%s", s.s3BucketName, s.s3Region, s.s3Endpoint, s.s3CloudCredName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just delete this log, not really necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants