Skip to content

Commit

Permalink
cluster/audit: audit log in seconds maybe leads to file overwriten
Browse files Browse the repository at this point in the history
  • Loading branch information
9547 committed Nov 2, 2020
1 parent 11535d2 commit 4934f34
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/cluster/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func ShowAuditList(dir string) error {
if err != nil {
continue
}
t := time.Unix(ts, 0)
t := time.Unix(ts/1e9, 0)
cmd, err := firstLine(fi.Name())
if err != nil {
continue
Expand All @@ -82,7 +82,7 @@ func ShowAuditList(dir string) error {

// OutputAuditLog outputs audit log.
func OutputAuditLog(dir string, data []byte) error {
fname := filepath.Join(dir, base52.Encode(time.Now().Unix()))
fname := filepath.Join(dir, base52.Encode(time.Now().UnixNano()))
return ioutil.WriteFile(fname, data, 0644)
}

Expand All @@ -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)
hint := fmt.Sprintf("- OPERATION TIME: %s -", t.Format("2006-01-02T15:04:05"))
line := strings.Repeat("-", len(hint))
_, _ = os.Stdout.WriteString(color.MagentaString("%s\n%s\n%s\n", line, hint, line))
Expand Down
2 changes: 1 addition & 1 deletion tests/tiup-dm/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function tiup-dm() {
mkdir -p ~/.tiup/bin && cp -f ./root.json ~/.tiup/bin/
# echo "in function"
if [ -f "./bin/tiup-dm.test" ]; then
./bin/tiup-dm.test -test.coverprofile=./cover/cov.itest-$(date +'%s')-$RANDOM.out __DEVEL--i-heard-you-like-tests "$@"
./bin/tiup-dm.test -test.coverprofile=./cover/cov.itest-$(date +'%s')-$RANDOM.out __DEVEL--i-heard-you-like-tests "$@"
else
../../bin/tiup-dm "$@"
fi
Expand Down

0 comments on commit 4934f34

Please sign in to comment.