alibaba / alibaba/open-simulator

为什么Simulator的Close方法需要创建一个test Pod并且等待其调度结束

Open
#97 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
266
Forks
55
PR merge metrics
No merged PRs in 30d

Description

## Question

如果在[这一行](https://github.com/alibaba/open-simulator/blob/c11c72ed298fa8b2174fa94394fb32c5c5e03478/pkg/simulator/core.go#LL87C3-L87C3)报错了,defer的Close方法会阻塞,因为scheduler还没运行起来,test pod永远不会返回调度结果,因此会阻塞在sim.simulatorStop这个chan上。

复现方法:删除[这一行](https://github.com/alibaba/open-simulator/blob/main/pkg/test/pod.go#LL31C7-L31C7)之后,执行测试pkg/simulator/core_test.go,就会阻塞住。
![image](https://github.com/alibaba/open-simulator/assets/7202634/451d8c79-ce4f-4db8-b150-12a75403adf5)

如果要修复这个问题,可以在生成Pod之后再NewSimulator。这样如果生成失败,也不需要Close simulator了

但我的疑问是为什么Simulator的Close方法需要创建一个test Pod并且等待其调度结束?去掉test Pod的话会有什么问题?

Contributor guide

No contributing guide indexed for this repository

Research direction

Read pkg/simulator/core.go around line 87 and inspect how Close waits on sim.simulatorStop. Then review pkg/test/pod.go around line 31 and run pkg/simulator/core_test.go with that line removed to reproduce the block. Done means the lifecycle behavior is explained and the test no longer hangs when simulator startup fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
distributed-systems, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.