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

fix: Fix deleting multiple experiments when specifying uid. #114

Merged
merged 1 commit into from
Jun 14, 2022

Conversation

Super-long
Copy link
Contributor

Signed-off-by: Super-long 0x4f4f4f4f@gmail.com

Describe what this PR does / why we need it

Take the generated expblade create cpu fullload --cpu-count 1 as an example.

When we execute the blend destroy uid, chaosblade is actually chaos_os destroy cpu fullload --cpu-count=1 --uid=e39ebc941a451b15 sent to exec-os first

The behavior at this point is that chaosblade destroys all chaos-related experiences. The root of the problem comes from Destroy, which lacks a judgment on the suid when looking for the pid to be deleted.

So even if we specify the uid in destroy, all chaos-related experiments will actually be deleted.

Translated with www.DeepL.com/Translator (free version)

Does this pull request fix one issue?

chaosblade-io/chaosblade#46

Describe how you did it

Add suid support for Destroy function.

Special notes for reviews

One of the judgments in the added code is ”spec.UnknownUid“, which occurs when executing something like blade destroy cpu fullload, the uid will be set to "spec.UnknownUid" and we don't want to execute GetPidsByProcessName with "spec.UnknownUid".

Signed-off-by: Super-long <0x4f4f4f4f@gmail.com>
@tiny-x tiny-x added the type/enhancement New feature or request label Jun 14, 2022
@tiny-x tiny-x added this to the v1.6.1 milestone Jun 14, 2022
@tiny-x tiny-x merged commit 039ce64 into chaosblade-io:master Jun 14, 2022
@@ -29,13 +29,23 @@ var cl = channel.NewLocalChannel()

// stop hang process
func Destroy(ctx context.Context, c spec.Channel, action string) *spec.Response {
ctx = context.WithValue(ctx, channel.ProcessKey, action)
suid := ctx.Value(spec.Uid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, @Super-long , maybe this uid can't be nil? Because there is code in main.go

		uid := expModel.ActionFlags[model.UidFlag.Name]
		if uid == "" {
			uid, _ = util.GenerateUid()
		}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants