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

Take and use backups of the launcher database #1755

Merged
merged 14 commits into from
Jun 20, 2024

Conversation

RebeccaMahany
Copy link
Contributor

@RebeccaMahany RebeccaMahany commented Jun 14, 2024

  • launcher takes periodic backups of its own database, beginning 10 mins after startup
  • bbolt checkup includes stats about the backup database
  • If its original database is unavailable but a backup is, launcher uses that backup db
  • On remote uninstall, the backup database is deleted

@RebeccaMahany RebeccaMahany changed the title Take backups of the launcher database Take and use backups of the launcher database Jun 17, 2024
@RebeccaMahany RebeccaMahany marked this pull request as ready for review June 17, 2024 19:40
Copy link
Contributor

@directionless directionless left a comment

Choose a reason for hiding this comment

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

early nits

ee/agent/storage/bbolt/backup.go Show resolved Hide resolved
return filepath.Join(rootDir, "launcher.db")
}

func BackupLauncherDbLocation(rootDir string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

I hate to say this, but we probably need to keep N and rotate. Otherwise we can probably get inconsistency if there's a reader and writer. :|

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't super worried about that because of how the access remains relatively restricted in this implementation --

  • On launcher startup, before any rungroups execute, launcher may rename launcher.db.bak to launcher.db; nothing else is accessing either db at this time
  • After rungroups begin to execute, this actor is the only thing touching launcher.db.bak -- nothing else will read from it or write to it
  • (Except for the flare checkup -- and data inconsistency probably isn't a huge deal there, and I'm not sure how much we even care about having that checkup anyway)
  • (There's also remote uninstall, but that just wants to delete the file)

Is there something I'm missing?

I'm happy to keep N and rotate if we feel like that's a safer option, regardless.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added rotation in 15183fa -- lmk what you're thinking!

ee/agent/storage/bbolt/backup.go Show resolved Hide resolved
ee/agent/storage/bbolt/backup.go Show resolved Hide resolved
ee/agent/storage/bbolt/backup.go Outdated Show resolved Hide resolved
ee/agent/storage/bbolt/backup.go Outdated Show resolved Hide resolved
zackattack01
zackattack01 previously approved these changes Jun 18, 2024
zackattack01
zackattack01 previously approved these changes Jun 18, 2024
directionless
directionless previously approved these changes Jun 18, 2024
Copy link
Contributor

@directionless directionless left a comment

Choose a reason for hiding this comment

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

I don't quite have the focus to really think through some of this. I think it's okay, and I'm nitpicking small things.

ee/agent/storage/bbolt/backup.go Outdated Show resolved Hide resolved
ee/agent/storage/bbolt/backup.go Outdated Show resolved Hide resolved
directionless
directionless previously approved these changes Jun 18, 2024
ee/agent/storage/bbolt/backup.go Outdated Show resolved Hide resolved
@RebeccaMahany RebeccaMahany added this pull request to the merge queue Jun 20, 2024
Merged via the queue into kolide:main with commit 4cee664 Jun 20, 2024
29 checks passed
@RebeccaMahany RebeccaMahany deleted the becca/db-bak branch June 20, 2024 13:14
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