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

chaosctl add recover subcommand #3056

Merged
merged 33 commits into from
Apr 2, 2022

Conversation

Hexilee
Copy link
Member

@Hexilee Hexilee commented Mar 24, 2022

What problem does this PR solve?

Add recover subcommand for chaosctl. This is a part split from #2992.

What's changed and how it works?

Related changes

  • Need to update chaos-mesh/website
  • Need to update Dashboard UI
  • Need to cheery-pick to release branches
    • release-2.1
    • release-2.0

Checklist

Tests

  • Unit test
  • E2E test
  • No code
  • Manual test (add steps below)

Side effects

  • Breaking backward compatibility

Release note

Please add a release note.

You can safely ignore this section if you don't think this PR needs a release note.

DCO

If you find the DCO check fails, please run commands like below (Depends on the actual situations. For example, if the failed commit isn't the most recent) to fix it:

git commit --amend --signoff
git push --force

Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Mar 24, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • WangXiangUSTC
  • cwen0

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

Signed-off-by: xixi <i@hexilee.me>
@codecov
Copy link

codecov bot commented Mar 24, 2022

Codecov Report

Merging #3056 (cb6c897) into master (ad48499) will increase coverage by 0.16%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3056      +/-   ##
==========================================
+ Coverage   38.24%   38.41%   +0.16%     
==========================================
  Files         105      105              
  Lines        9182     9181       -1     
==========================================
+ Hits         3512     3527      +15     
+ Misses       5361     5346      -15     
+ Partials      309      308       -1     
Impacted Files Coverage Δ
pkg/selector/pod/selector.go 42.70% <0.00%> (+0.22%) ⬆️
pkg/selector/generic/mode.go 28.20% <0.00%> (+2.56%) ⬆️
.../workflow/controllers/workflow_entry_reconciler.go 52.91% <0.00%> (+6.87%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 187418f...cb6c897. Read the comment docs.

pkg/chaosctl/cmd/recover.go Show resolved Hide resolved
pkg/chaosctl/cmd/recover.go Outdated Show resolved Hide resolved
pkg/chaosctl/cmd/recover.go Outdated Show resolved Hide resolved
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Copy link
Contributor

@WangXiangUSTC WangXiangUSTC left a comment

Choose a reason for hiding this comment

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

rest LGTM

pkg/chaosctl/cmd/recover.go Outdated Show resolved Hide resolved
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Copy link
Contributor

@WangXiangUSTC WangXiangUSTC left a comment

Choose a reason for hiding this comment

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

LGTM

Currently unimplemented.

Examples:
# Recover network chaos from pods in namespace default
Copy link
Member

Choose a reason for hiding this comment

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

Does the feature support recover chaos experiment by specific chaos experiment name and namepsace?

Copy link
Member Author

@Hexilee Hexilee Mar 31, 2022

Choose a reason for hiding this comment

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

Doesn't support. It's designed to forcedly recover pods, we should not assume the Chaos Mesh still works as expected. Moreover, if multiple experiments affect the same pod, we cannot only recover one of them forcedly.

Copy link
Member

Choose a reason for hiding this comment

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

Why just default namespace here? Can we support recover on a specific namespace?


recoverCmd.PersistentFlags().StringVarP(&o.namespace, "namespace", "n", "default", "namespace to find pods")
o.labels = recoverCmd.PersistentFlags().StringSliceP("label", "l", nil, "labels to select pods")
err := recoverCmd.RegisterFlagCompletionFunc("namespace", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
Copy link
Member

Choose a reason for hiding this comment

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

When is the registered function will be called?

Copy link
Member Author

Choose a reason for hiding this comment

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

When you enter TAB (auto-completion).

selector.Pods = map[string][]string{o.namespace: names}
}

labelSelector := map[string]string{}
Copy link
Member

Choose a reason for hiding this comment

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

You can use pkg/label pkg to parse label directly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -54,8 +55,8 @@ func (d *networkDebugger) Collect(ctx context.Context, namespace, chaosName stri
Name string
Pod struct {
Ipset string
Copy link
Member

Choose a reason for hiding this comment

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

NetworkChaos experiment may use multiple IPSets. Here may need to use []string type.

Copy link
Member Author

Choose a reason for hiding this comment

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

IPSets are unnecessary in forced recovery, we don't need to parse it server-side in this PR. If it's necessary for other use-cases, we should parse it in another PR.

)

type CtrlClient struct {
QueryClient *graphql.Client
SubscriptionClient *graphql.SubscriptionClient
}

type PartialPod struct {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add some comments to descript what this struct is and when to use it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, now the PartialPod is moved to pkg/chaosctl/recover .

Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Signed-off-by: xixi <i@hexilee.me>
Copy link
Member

@Andrewmatilde Andrewmatilde left a comment

Choose a reason for hiding this comment

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

Rest LGTM, I think some of this PR may be changed in the following PR of recover in chaosctl.

pkg/chaosctl/cmd/recover.go Outdated Show resolved Hide resolved
pkg/chaosctl/cmd/recover.go Outdated Show resolved Hide resolved
Signed-off-by: xixi <i@hexilee.me>
@Hexilee
Copy link
Member Author

Hexilee commented Apr 2, 2022

@Andrewmatilde PTAL again!

Copy link
Member

@cwen0 cwen0 left a comment

Choose a reason for hiding this comment

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

LGTM

@cwen0
Copy link
Member

cwen0 commented Apr 2, 2022

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 81c02b1

@ti-chi-bot ti-chi-bot merged commit b4b3374 into chaos-mesh:master Apr 2, 2022
@Hexilee Hexilee mentioned this pull request Apr 29, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants