Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

cmd,task: disable stray command line args, and log the command in LogArguments (#579) #588

Merged
merged 2 commits into from
Nov 10, 2020

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #579 to release-4.0


What problem does this PR solve?

  1. It was confusing that --checksum false does not actually disable checksum, because --checksum as a boolean flag already means --checksum=true. So --checksum false becomes --checksum=true false, and that extra false becomes a stray argument, which is ignored before this PR.

  2. LogArguments did not record whether it is a "backup" or "restore" making it a bit hard to determine the data direction when reading logs.

What is changed and how it works?

  1. Added Args: cobra.NoArgs to all leaf commands so using --checksum false will result in

    Error: unknown command "false" for "br backup full"
    

    rather than silently keeping checksum.

  2. Record the command being executed inside LogArguments.

    Note that I changed LogArguments from using VisitAll to Visit. Originally in add log for cmd arguments and duration for checksum #55 it was using VisitAll to print all args, however it was changed in Don't log secret of s3. #292 to condition on f.Changed, so perhaps let's just use Visit directly 🙃.

Check List

Tests

  • Manual test (add detailed scripts or steps below)
    • Run and check the log.

Code changes

Side effects

Related changes

  • Need to cherry-pick to the release branch

Release Note

  • BR no longer accepts --checksum false in command line, which did not disable checksum. The correct usage always include the = sign: --checksum=false.

@kennytm
Copy link
Collaborator

kennytm commented Nov 6, 2020

/rebuild

Copy link
Collaborator

@3pointer 3pointer left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-srebot ti-srebot added the status/LGT1 LGTM1 label Nov 8, 2020
@glorv
Copy link
Collaborator

glorv commented Nov 10, 2020

LGTM

@ti-srebot ti-srebot added status/LGT2 LGTM2 and removed status/LGT1 LGTM1 labels Nov 10, 2020
@glorv
Copy link
Collaborator

glorv commented Nov 10, 2020

/merge

@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot ti-srebot added status/LGT3 LGTM3. This PR looks very good to our bot. and removed status/LGT2 LGTM2 labels Nov 10, 2020
@overvenus overvenus merged commit 2ac49a4 into pingcap:release-4.0 Nov 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status/LGT3 LGTM3. This PR looks very good to our bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants