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

make clk id configurable #276

Merged
merged 9 commits into from
Feb 26, 2020
Merged

Conversation

YangKeao
Copy link
Member

Signed-off-by: Yang Keao [email protected]

What problem does this PR solve?

It makes the mask of affected clk_id configurable.

What is changed and how does it work?

Add a new variable in fake_clock_gettime function.

Check List

Tests

  • Unit test
  • Manual test

Code changes

  • Has Go code change

Signed-off-by: Yang Keao <[email protected]>
Signed-off-by: Yang Keao <[email protected]>
Signed-off-by: Yang Keao <[email protected]>
@codecov-io
Copy link

codecov-io commented Feb 24, 2020

Codecov Report

Merging #276 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #276   +/-   ##
=======================================
  Coverage   59.91%   59.91%           
=======================================
  Files          37       37           
  Lines        2018     2018           
=======================================
  Hits         1209     1209           
  Misses        714      714           
  Partials       95       95

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 83a4100...03f06aa. Read the comment docs.

@cwen0
Copy link
Member

cwen0 commented Feb 24, 2020

@ethercflow PTAL

@cwen0 cwen0 requested review from ethercflow and cwen0 February 24, 2020 14:20
api/v1alpha1/timechaos_types.go Outdated Show resolved Hide resolved
clkIds := strings.Split(clockIdsSlice, ",")
mask, err := utils.EncodeClkIds(clkIds)
if err != nil {
log.Error(err, "error while converting clock ids to mask")
Copy link
Member

Choose a reason for hiding this comment

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

Can we use one log pkg uniformly?

Copy link
Member Author

Choose a reason for hiding this comment

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

log from controller-runtime will bring in lots of flags about kubernetes, which is disappointing. And it uses zapr too, so literally using this log doesn't bring in any new dependency.

Copy link
Member

Choose a reason for hiding this comment

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

got

mask, err := utils.EncodeClkIds(clkIds)
if err != nil {
log.Error(err, "error while converting clock ids to mask")
return
Copy link
Member

Choose a reason for hiding this comment

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

os.Exit(1)

cmd/watchmaker/main_linux.go Outdated Show resolved Hide resolved
@@ -41,5 +41,4 @@ Description:

* Time modification will only be injected into the main process of container
* Time chaos has no effect on pure syscall `clock_gettime`
* Only `CLOCK_REALTIME` will be modified. This is intended because modification on other clock such as `CLOCK_REALTIME_COARSE` (which go program uses to `time.Sleep`) will cause serious and deterministic problem. We should make it configurable in the future.
Copy link
Member

Choose a reason for hiding this comment

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

we should update this description instead of deleting it 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.

Yes! I added description in former part

pkg/utils/time.go Outdated Show resolved Hide resolved
)

func initFlag() {
flag.IntVar(&pid, "pid", 0, "pid of target program")
flag.Int64Var(&secDelta, "sec_delta", 0, "delta time of sec field")
flag.Int64Var(&nsecDelta, "nsec_delta", 0, "delta time of nsec field")
flag.StringVar(&clockIdsSlice, "clk_ids", "CLOCK_REALTIME", "affected clock ids")
Copy link
Member

Choose a reason for hiding this comment

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

The fourth parameter may describe the split is ',' ?

@@ -137,14 +145,20 @@ func ModifyTime(pid int, deltaSec int64, deltaNsec int64) error {
}
fakeAddr := fakeEntry.StartAddress

// 115 is the index of TV_SEC_DELTA in fakeImage
err = program.WriteUint64ToAddr(fakeAddr+115, uint64(deltaSec))
// 139 is the index of CLOCK_IDS_MASK in fakeImage
Copy link
Member

@ethercflow ethercflow Feb 25, 2020

Choose a reason for hiding this comment

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

The order of the index does not match the 79 row's comment?

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 should modify 77-79 comments. They should follow the order of being used in program.

cwen0
cwen0 previously approved these changes Feb 25, 2020
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 Feb 25, 2020

@ethercflow PTAL

@cwen0
Copy link
Member

cwen0 commented Feb 25, 2020

@YangKeao Fix conflicts

Copy link
Member

@ethercflow ethercflow 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 Feb 26, 2020

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Feb 26, 2020

/run-all-tests

@sre-bot sre-bot merged commit e0a5d41 into chaos-mesh:master Feb 26, 2020
@oraluben oraluben mentioned this pull request Feb 26, 2020
@@ -19,7 +19,7 @@ controllerManager:
replicaCount: 1

image: pingcap/chaos-mesh:latest
imagePullPolicy: Always
imagePullPolicy: Never
Copy link
Contributor

Choose a reason for hiding this comment

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

Can I ask why this change to Never?

@YangKeao YangKeao deleted the configurable-clk-id branch August 3, 2020 03:43
sjwsl pushed a commit to sjwsl/chaos-mesh that referenced this pull request May 6, 2021
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.

6 participants