Skip to content

Commit

Permalink
Only create swap file space when necessary (#416)
Browse files Browse the repository at this point in the history
* Only create swap file space when necessary
  • Loading branch information
martijnvans authored Feb 22, 2022
1 parent 309c171 commit 53c8b3e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 0 additions & 14 deletions integration_test/gce/gce_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,20 +977,6 @@ func attemptCreateInstance(ctx context.Context, logger *log.Logger, options VMOp
return nil, fmt.Errorf("attemptCreateInstance() failed to configure retries in zypp.conf: %v", err)
}
}

if !IsWindows(vm.Platform) {
// Enable swap file: https://linuxize.com/post/create-a-linux-swap-file/
_, err := RunRemotely(ctx, logger, vm, "", strings.Join([]string{
"sudo dd if=/dev/zero of=/swapfile bs=1024 count=102400",
"sudo chmod 600 /swapfile",
"sudo mkswap /swapfile",
"sudo swapon /swapfile",
}, " && "))
if err != nil {
return nil, err
}
}

return vm, nil
}

Expand Down
14 changes: 14 additions & 0 deletions integration_test/ops_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,20 @@ func metricsForPlatform(platform string) []string {
}

func testDefaultMetrics(ctx context.Context, t *testing.T, logger *logging.DirectoryLogger, vm *gce.VM, window time.Duration) {
if !gce.IsWindows(vm.Platform) {
// Enable swap file: https://linuxize.com/post/create-a-linux-swap-file/
// We do this so that swap file metrics will show up.
_, err := gce.RunRemotely(ctx, logger.ToMainLog(), vm, "", strings.Join([]string{
"sudo dd if=/dev/zero of=/swapfile bs=1024 count=102400",
"sudo chmod 600 /swapfile",
"sudo mkswap /swapfile",
"sudo swapon /swapfile",
}, " && "))
if err != nil {
t.Fatalf("Failed to enable swap file: %v", err)
}
}

// First make sure that the uptime metrics are being uploaded.
var uptimeWaitGroup sync.WaitGroup
regexes := agentVersionRegexesForPlatform(vm.Platform)
Expand Down

0 comments on commit 53c8b3e

Please sign in to comment.