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

roachprod: implement --dry-run and --verbose #137874

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

srosenberg
Copy link
Member

@srosenberg srosenberg commented Dec 21, 2024

Debugging roachprod in a remote (user) environment can be challenging.
On several occassions, simply printing all executed (cloud) commands
was sufficient to reproduce and root cause an issue.

This change implements two mutually exclusive
modes, namely dry-run and verbose. The latter
merely logs every command before it's executed.
The former suppresses execution of any command
which can modify the (cloud) infrastructure;
i.e., dry-run executes read-only commands; it logs
every command, executed or not. Also note that
dry-run leaves temporary files like VM startup
scripts on disk, so that they can be readily examined.

Thus, dry-run is primarily for dumping all
commands without the risk of modifying anything;
verbose is primarily for live debugging.

Release note: None
Epic: none
Fixes: #99091

Copy link

blathers-crl bot commented Dec 21, 2024

Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@srosenberg srosenberg requested a review from golgeek December 21, 2024 02:00
@srosenberg
Copy link
Member Author

srosenberg commented Dec 21, 2024

SELECT_PROBABILITY=0.25 runs,

@srosenberg srosenberg marked this pull request as ready for review December 21, 2024 22:37
@srosenberg srosenberg requested review from a team as code owners December 21, 2024 22:37
@srosenberg srosenberg requested review from csgourav, DarrylWong and shailendra-patel and removed request for a team and csgourav December 21, 2024 22:37
@srosenberg
Copy link
Member Author

srosenberg commented Dec 21, 2024

I'll do a bit more smoke testing, but it's ready for review now. Apologies for a fairly large PR. Most of the changes are fairly shallow and hopefully quick to review; e.g., we need to thread the logger through every func. which may invoke a command. The rest is refactoring, by moving command invocation logic into its own package (see cli.go), and consolidating dry-run and verbose logic.

Copy link
Contributor

@golgeek golgeek left a comment

Choose a reason for hiding this comment

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

This looks great! Both options will be very helpful, and the cli package is the cherry on the cake!

Copy link
Contributor

@DarrylWong DarrylWong left a comment

Choose a reason for hiding this comment

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

Couple of commands that don't fully work (e.g. destroy errors out trying to unmarshal DNS records, create errors out setting up SSH), but the approach SGTM and I think it's fine since it's just an "experimental" feature.

@srosenberg
Copy link
Member Author

Couple of commands that don't fully work (e.g. destroy errors out trying to unmarshal DNS records, create errors out setting up SSH), but the approach SGTM and I think it's fine since it's just an "experimental" feature.

Thanks, I'll have a look at those. Not everything is going to work since some commands may require changes (or side-effects), but methinks destroy should be doable.

@srosenberg
Copy link
Member Author

Couple of commands that don't fully work (e.g. destroy errors out trying to unmarshal DNS records, create errors out setting up SSH), but the approach SGTM and I think it's fine since it's just an "experimental" feature.

Thanks, I'll have a look at those. Not everything is going to work since some commands may require changes (or side-effects), but methinks destroy should be doable.

So, create does print the commands which would have been executed; it fails upon trying to List the cluster; that's as far as --dry-run can go. As for destroy, it was missing cli.AlwaysExecute() in listSRVRecords; works now without an error.

Debugging roachprod in a remote (user) environment
can be challenging. On several occassions, simply
printing all executed (cloud) commands was sufficient
to reproduce and root cause an issue.

This change implements two mutually exclusive
modes, namely `dry-run` and `verbose`. The latter
merely logs every command before it's executed.
The former suppresses execution of any command
which can modify the (cloud) infrastructure; i.e.,
`dry-run` executes read-only commands; it logs
every command, executed or not. Also note that
`dry-run` leaves temporary files like VM startup
scripts on disk, so that they can be readily examined.

Thus, `dry-run` is primarily for dumping _all_
commands without the risk of modifying anything;
`verbose` is primarily for live debugging.

Release note: None
Epic: none
Fixes: cockroachdb#99091
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

roachprod: implement --dry-run and --verbose
4 participants