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

cluster/audit: audit log in seconds maybe leads to file overwriten #879

Merged
merged 2 commits into from
Nov 3, 2020

Conversation

9547
Copy link
Contributor

@9547 9547 commented Nov 2, 2020

What problem does this PR solve?

In my local dev's env, I've found the audit log file was base52 encoded with time.Now().Unix(), while at the same time, if the command is run fast enough, then the later file with the same name will cover the previous one.

In my local dev, I'm running tiup-dm test-cmd

bash /tiup-cluster/tests/tiup-dm/run.sh --native-ssh --do-cases test_cmd
# ... wait for this case finished
exit 1

the below case maybe(occasional) failed of this line

tiup-dm audit | grep "deploy $name $version"

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release notes:

Fix the issue which leads the audit log file be overwritten.

@codecov-io
Copy link

codecov-io commented Nov 2, 2020

Codecov Report

Merging #879 into master will decrease coverage by 41.39%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #879       +/-   ##
===========================================
- Coverage   52.17%   10.78%   -41.40%     
===========================================
  Files         263      130      -133     
  Lines       19030     9888     -9142     
===========================================
- Hits         9929     1066     -8863     
- Misses       7562     8583     +1021     
+ Partials     1539      239     -1300     
Flag Coverage Δ
cluster ?
dm ?
integrate 10.78% <ø> (-36.19%) ⬇️
playground ?
tiup 10.78% <ø> (ø)
unittest ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/meta/paths.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/utils/utils.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/utils/semver.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/logger/log/log.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/cluster/template/config/config.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/cluster/template/scripts/scripts.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/cluster/spec/validate.go 0.00% <0.00%> (-93.54%) ⬇️
pkg/utils/diff.go 0.00% <0.00%> (-89.84%) ⬇️
pkg/cluster/spec/spec.go 0.00% <0.00%> (-88.10%) ⬇️
pkg/telemetry/scrub.go 0.00% <0.00%> (-86.67%) ⬇️
... and 218 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 11535d2...887f4c0. Read the comment docs.

@9547 9547 force-pushed the fix/audit-log-overwrite branch from 887f4c0 to 3344d2f Compare November 2, 2020 23:05
@9547
Copy link
Contributor Author

9547 commented Nov 3, 2020

@lucklove PTAL

Copy link
Contributor

@AstroProfundis AstroProfundis left a comment

Choose a reason for hiding this comment

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

LGTM, brilliant!

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 3, 2020
@lucklove
Copy link
Member

lucklove commented Nov 3, 2020

Awesome!!! I think this is what bother us for a very long time: #666 (I closed that because it didn't reproduce these days, but I'm sure your PR finally fixed that)

@lucklove lucklove merged commit 1a295b4 into pingcap:master Nov 3, 2020
@@ -103,7 +103,7 @@ func ShowAuditLog(dir string, auditID string) error {
return errors.Trace(err)
}

t := time.Unix(ts, 0)
t := time.Unix(ts/1e9, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not compatible with the existing audit files ?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for my careless, @9547 can your please open another PR to fix this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I was inconsiderate, I'll fix in another PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in #882 @lucklove @july2993 PTAL

@9547 9547 deleted the fix/audit-log-overwrite branch November 3, 2020 11:57
@lucklove lucklove added this to the v1.2.4 milestone Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants