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

Add a Tasks manager in chaos daemon for time chaos #2812

Merged
merged 31 commits into from
Feb 21, 2022

Conversation

Andrewmatilde
Copy link
Member

@Andrewmatilde Andrewmatilde commented Jan 20, 2022

What problem does this PR solve?

I need a tasks manager to organize tasks on process in time chaos.

  1. Two tasks can inject a same process.
  2. When the last task on a process was recovered , I need to completely clear the chaos.

What's changed and how it works?

Nothing changes now , I just add a manager .
I will apply it on time chaos later.

Related changes

No related changes

Checklist

Tests

  • Unit test
  • 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: andrewmatilde <davis6813585853062@outlook.com>
Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jan 20, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • WangXiangUSTC
  • YangKeao

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: andrewmatilde <davis6813585853062@outlook.com>
Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
@codecov
Copy link

codecov bot commented Jan 20, 2022

Codecov Report

Merging #2812 (8cfb897) into master (68e6ccb) will decrease coverage by 0.47%.
The diff coverage is 37.74%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2812      +/-   ##
==========================================
- Coverage   40.74%   40.27%   -0.48%     
==========================================
  Files         147      148       +1     
  Lines       12047    12230     +183     
==========================================
+ Hits         4909     4926      +17     
- Misses       6769     6912     +143     
- Partials      369      392      +23     
Impacted Files Coverage Δ
pkg/chaosdaemon/dns_server.go 0.00% <0.00%> (ø)
pkg/chaosdaemon/jvm_server.go 0.00% <0.00%> (ø)
pkg/chaosdaemon/stress_server_linux.go 0.00% <0.00%> (ø)
pkg/chaosdaemon/tasks/process_group_handle.go 0.00% <0.00%> (ø)
pkg/chaosdaemon/tc_server.go 16.29% <0.00%> (ø)
pkg/chaosdaemon/iptables_server.go 65.92% <25.00%> (ø)
pkg/chaosdaemon/tasks/task_manager.go 43.79% <43.79%> (ø)
pkg/chaosdaemon/tasks/task_config_manager.go 52.32% <52.32%> (ø)
pkg/chaosdaemon/ipset_server.go 86.55% <80.00%> (ø)
pkg/chaosdaemon/server.go 37.50% <100.00%> (+1.22%) ⬆️
... and 5 more

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 68e6ccb...8cfb897. Read the comment docs.

@Andrewmatilde Andrewmatilde changed the title Tasks manager Add a Tasks manager for time chaos Jan 20, 2022
@Andrewmatilde Andrewmatilde changed the title Add a Tasks manager for time chaos Add a Tasks manager in chaos daemon for time chaos Jan 20, 2022
@Andrewmatilde
Copy link
Member Author

PTAL, @WangXiangUSTC @STRRL

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
YangKeao
YangKeao previously approved these changes Feb 10, 2022
Copy link
Member

@YangKeao YangKeao 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/chaoserr/common_errors.go Outdated Show resolved Hide resolved
pkg/chaoserr/common_errors.go Show resolved Hide resolved
Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
@YangKeao YangKeao dismissed their stale review February 15, 2022 08:18

New Comments

pkg/chaosdaemon/tasks/task_manager.go Show resolved Hide resolved
pkg/chaosdaemon/tasks/task_manager.go Show resolved Hide resolved
pkg/chaosdaemon/tasks/task_manager.go Show resolved Hide resolved
pkg/chaosdaemon/tasks/tasks_test.go Show resolved Hide resolved
pkg/chaosdaemon/tasks/task_manager.go Outdated Show resolved Hide resolved
…TaskConfig

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
…ge data inside the config manager.

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
…ge data inside the config manager.

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 54 to 57
childPids, err := util.GetChildProcesses(uint32(pid), gp.logger)
if err != nil {
gp.logger.Error(err, "failed to get child process")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

how about moving these codes after L58, and returning the error when getting child PID failed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree with you.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 95 to 98
childPids, err := util.GetChildProcesses(uint32(pid), gp.logger)
if err != nil {
gp.logger.Error(err, "failed to get child process")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree with you.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

}

// Addable introduces the data gathering ability.
type Addable interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

how about moving this interface after interface Object? It looks strange to put it in the TaskConfigManager

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

}
_, ok := m.TaskConfigMap[id]
if !ok {
return errors.Wrapf(ErrTaskConfigNotFound, "UID : %v", id)
Copy link
Contributor

Choose a reason for hiding this comment

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

L84 use %s for uid, and here use %v, how about unifying them?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree with you.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

if !ok {
return errors.New("task.Data here must implement TaskExecutor")
}
_ = tasker.Assign(process)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
_ = tasker.Assign(process)
err = tasker.Assign(process)

Copy link
Member Author

Choose a reason for hiding this comment

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

OK.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

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

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
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

@Andrewmatilde
Copy link
Member Author

/run-e2e-test

@Andrewmatilde
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 8cfb897

@ti-chi-bot ti-chi-bot merged commit bef9049 into chaos-mesh:master Feb 21, 2022
afzal442 pushed a commit to afzal442/chaos-mesh that referenced this pull request Mar 19, 2022
* Merge tasks manager

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Rollback time changes

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Format

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* some fix

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* fix license

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* fix fmt

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Add comments

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Add comments

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Fix Merge

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Fix logger

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Fix merge

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Fix merge fmt

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* minor fix

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* fix comment

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* fix data -> Data

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* fix Data -> data

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Change some name & add more comments

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* make name in common error exported

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* make NotFound.Name unexported & Add some global variable&XXXTask->XXXTaskConfig

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Add more test. & Fix a bug that user can give a config pointer & change data inside the config manager.

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Add more test. & Fix a bug that user can give a config pointer & change data inside the config manager.

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* make error not found just a func

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Fix comment.

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Fix comment.

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Fix merge.

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* fmt

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
zhqqqy pushed a commit to zhqqqy/chaos-mesh that referenced this pull request Apr 10, 2022
* Merge tasks manager

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Rollback time changes

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Format

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* some fix

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* fix license

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* fix fmt

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Add comments

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Add comments

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Fix Merge

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Fix logger

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Fix merge

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Fix merge fmt

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* minor fix

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* fix comment

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* fix data -> Data

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* fix Data -> data

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Change some name & add more comments

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* make name in common error exported

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* make NotFound.Name unexported & Add some global variable&XXXTask->XXXTaskConfig

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Add more test. & Fix a bug that user can give a config pointer & change data inside the config manager.

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Add more test. & Fix a bug that user can give a config pointer & change data inside the config manager.

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* make error not found just a func

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Fix comment.

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Fix comment.

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* Fix merge.

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>

* fmt

Signed-off-by: andrewmatilde <davis6813585853062@outlook.com>
Signed-off-by: zhqqqy <zhqqqy@163.com>
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

6 participants