Skip to content

[loadgen] Wait before workspace termination #10585

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

Merged
merged 1 commit into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion dev/loadgen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You can find a short explanation of this tool in this [loom video](https://www.l
`gpctl clusters get-tls-config`
- Port-forward ws-manager
`kubectl port-forward deployment/ws-manager 12001:8080`
- Now you can start the benchmark with loadgen. If you want to keep the workspaces around after testing, add --interactive. Loadgen will then ask you before taking any destructive action.
- Now you can start the benchmark with loadgen. If you want to keep the workspaces around after testing, add --interactive. Loadgen will then ask you before taking any destructive action. If you do not specify `--interative` loadgen will wait 2 minutes before workspaces are deleted.
`loadgen benchmark [config-file] --host localhost:12001 --tls ./wsman-tls --interactive`

In order to configure the benchmark, you can use the configuration file
Expand Down
18 changes: 9 additions & 9 deletions dev/loadgen/cmd/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ var benchmarkCommand = &cobra.Command{
}
},
Termination: func(executor loadgen.Executor) error {
return handleWorkspaceDeletion(scenario.StoppingTimeout, executor)
return handleWorkspaceDeletion(scenario.StoppingTimeout, executor, false)
},
}

Expand All @@ -165,7 +165,7 @@ var benchmarkCommand = &cobra.Command{
// cancel workspace creation so that no new workspaces are created while we are deleting them
scancel()

if err := handleWorkspaceDeletion(scenario.StoppingTimeout, session.Executor); err != nil {
if err := handleWorkspaceDeletion(scenario.StoppingTimeout, session.Executor, true); err != nil {
log.Warnf("could not delete workspaces: %v", err)
os.Exit(1)
}
Expand Down Expand Up @@ -198,21 +198,21 @@ type BenchmarkScenario struct {
WorkspaceClass string `json:"workspaceClass"`
}

func handleWorkspaceDeletion(timeout string, executor loadgen.Executor) error {
func handleWorkspaceDeletion(timeout string, executor loadgen.Executor, canceled bool) error {
if runOpts.Interactive {
if !confirmDeletion() {
return nil
}

if err := stopWorkspaces(timeout, executor); err != nil {
return err
}
return stopWorkspaces(timeout, executor)
} else {
if err := stopWorkspaces(timeout, executor); err != nil {
return err
if !canceled {
fmt.Println("Waiting for 2 minutes before deleting workspaces")
time.Sleep(2 * time.Minute)
}

return stopWorkspaces(timeout, executor)
}
return nil
}

func confirmDeletion() bool {
Expand Down