Skip to content

Commit 8dcddf4

Browse files
Furistoroboquat
authored andcommitted
[loadgen] Wait before workspace termination
1 parent 3a9d74f commit 8dcddf4

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

dev/loadgen/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You can find a short explanation of this tool in this [loom video](https://www.l
1313
`gpctl clusters get-tls-config`
1414
- Port-forward ws-manager
1515
`kubectl port-forward deployment/ws-manager 12001:8080`
16-
- 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.
16+
- 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.
1717
`loadgen benchmark [config-file] --host localhost:12001 --tls ./wsman-tls --interactive`
1818

1919
In order to configure the benchmark, you can use the configuration file

dev/loadgen/cmd/benchmark.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ var benchmarkCommand = &cobra.Command{
152152
}
153153
},
154154
Termination: func(executor loadgen.Executor) error {
155-
return handleWorkspaceDeletion(scenario.StoppingTimeout, executor)
155+
return handleWorkspaceDeletion(scenario.StoppingTimeout, executor, false)
156156
},
157157
}
158158

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

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

201-
func handleWorkspaceDeletion(timeout string, executor loadgen.Executor) error {
201+
func handleWorkspaceDeletion(timeout string, executor loadgen.Executor, canceled bool) error {
202202
if runOpts.Interactive {
203203
if !confirmDeletion() {
204204
return nil
205205
}
206206

207-
if err := stopWorkspaces(timeout, executor); err != nil {
208-
return err
209-
}
207+
return stopWorkspaces(timeout, executor)
210208
} else {
211-
if err := stopWorkspaces(timeout, executor); err != nil {
212-
return err
209+
if !canceled {
210+
fmt.Println("Waiting for 2 minutes before deleting workspaces")
211+
time.Sleep(2 * time.Minute)
213212
}
213+
214+
return stopWorkspaces(timeout, executor)
214215
}
215-
return nil
216216
}
217217

218218
func confirmDeletion() bool {

0 commit comments

Comments
 (0)