Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support storing MDM bootstrap packages in S3 #21156

Merged

Conversation

mna
Copy link
Member

@mna mna commented Aug 7, 2024

#19037

Checklist for submitter

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.
  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements)
  • Added/updated tests
  • Manual QA for all new/changed functionality


// TODO(mna): there is an inherent risk that we could delete files that were
// added between the query to list used IDs and now. We could minimize that
// risk by checking that the S3 file is older than a few seconds.
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is worth adding, I'll do it next week. It should make it practically impossible to delete S3 files that are in use (except in extreme cases where S3 API is super slow or the clock difference between S3 and our servers is significant, which I assume is very unlikely if Fleet is hosted in AWS itself).

Copy link
Contributor

Choose a reason for hiding this comment

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

S3 has consistency guarantees:

Amazon S3 provides strong read-after-write consistency for PUT and DELETE requests of objects in your Amazon S3 bucket in all AWS Regions. This behavior applies to both writes to new objects as well as PUT requests that overwrite existing objects and DELETE requests. In addition, read operations on Amazon S3 Select, Amazon S3 access controls lists (ACLs), Amazon S3 Object Tags, and object metadata (for example, the HEAD object) are strongly consistent.

https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html#ConsistencyModel

Not sure if it helps in this case, but figured I'd at least mention it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! Unfortunately in that case this doesn't change the risk because it's a question of integrity across mysql and S3 data - it's possible that an S3 object returned in that list is seen as "unused" by mysql and deleted, but in fact it should be seen as "used" because it has been added between the time we queried mysql and the time we list S3 objects.

@@ -7119,7 +7119,7 @@ func (s *integrationMDMTestSuite) TestMDMEnabledAndConfigured() {
Token: uuid.New().String(),
Bytes: []byte("foo"),
Sha256: []byte("foo-sha256"),
}))
}, nil))
Copy link
Member Author

Choose a reason for hiding this comment

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

I'll be working on adding an integration test suite, which enables S3 storage for all things that support it (software installers and bootstrap packages), so we have an easy way to integration-test those too (currently integration tests never use S3 for this).

Copy link
Member

Choose a reason for hiding this comment

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

sounds great, thank you! if it can be used as inspiration, we have integration tests that use s3 (via minio) for the good old sandbox

is := s3.SetupTestInstallerStore(t, "integration-tests", "")
opts := &TestServerOpts{FleetConfig: &cfg, Is: is}
if os.Getenv("FLEET_INTEGRATION_TESTS_DISABLE_LOG") != "" {
opts.Logger = kitlog.NewNopLogger()
}
users, server := RunServerForTestsWithDS(t, s.ds, opts)
s.server = server
s.users = users
s.token = s.getTestAdminToken()
s.installers = s3.SeedTestInstallerStore(t, is, enrollSecret)

@mna mna changed the base branch from main to feat-store-bootstrap-in-s3 August 7, 2024 19:57
@mna mna marked this pull request as ready for review August 7, 2024 20:23
// cron job will eventually cleanup.
// 5. if everything succeeds, data is consistent and the S3 package
// cannot be used before it is uploaded (since the DB row is inserted
// after upload).
Copy link
Member

Choose a reason for hiding this comment

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

thanks for the comment, makes total sense

@mna mna requested a review from lukeheath as a code owner August 12, 2024 13:23
@mna mna merged commit 0a056a8 into feat-store-bootstrap-in-s3 Aug 12, 2024
13 checks passed
@mna mna deleted the mna-19037-store-bootstrap-packages-in-s3 branch August 12, 2024 13:51
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