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

batch tmutil call args to prevent argument list too long errors #1873

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion ee/agent/timemachine/timemachine_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,17 @@ func AddExclusions(ctx context.Context, k types.Knapsack) {
launcher.pid
*/

exclusionPatterns := []string{
exclusionPatternsFirstBatch := []string{
"*.json",
"*.json.gz",
"*.db",
}

addExclusionsFromPathPatterns(ctx, k, exclusionPatternsFirstBatch)

// Attempting to run this with a single tmutil call we see a lot of tmutil failures logged with error "argument list too long".
// To avoid this we run in two separate batches, attempting to cut the post-glob argument list roughly in half
exclusionPatternsSecondBatch := []string{
"*.sqlite",
"desktop_*",
"*.pid",
Expand All @@ -45,6 +52,10 @@ func AddExclusions(ctx context.Context, k types.Knapsack) {
"osquery*",
}

addExclusionsFromPathPatterns(ctx, k, exclusionPatternsSecondBatch)
}

func addExclusionsFromPathPatterns(ctx context.Context, k types.Knapsack, exclusionPatterns []string) {
var exclusionPaths []string
for _, pattern := range exclusionPatterns {
matches, err := filepath.Glob(filepath.Join(k.RootDirectory(), pattern))
Expand Down
Loading