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

machine: Add a new command dvc machine status #6649

Merged
merged 9 commits into from
Oct 19, 2021

Conversation

karajan1001
Copy link
Contributor

@karajan1001 karajan1001 commented Sep 20, 2021

fix #6482

  1. add a new command dvc machine status
  2. add a unit test for the cli call.
  3. add a unit test for the shown result.

Thank you for the contribution - we'll try to review it as soon as possible. πŸ™

fix#6482
1. add a new command `dvc machien status`
2. add a unit test for the cli call.
3. add a unit test for the shown result.
@karajan1001 karajan1001 requested a review from a team as a code owner September 20, 2021 00:41
@karajan1001 karajan1001 requested a review from pared September 20, 2021 00:41
dvc/command/machine.py Outdated Show resolved Hide resolved
dvc/command/machine.py Outdated Show resolved Hide resolved
@dberenbaum
Copy link
Collaborator

@karajan1001 How much extra work would it take to add an asciinema or other video inside of these PRs as an example? It might also make it easier to demo the feature.

@pmrowla
Copy link
Contributor

pmrowla commented Sep 21, 2021

One thing we should consider is sanitizing auth/private data related fields in the CLI commands. In terraform show they remove things like SSH private keys and startup scripts from their CLI output (and just display something like <sensitive data removed>). They only include those fields when it's in an output format intended for machine/programmatic consumption (i.e. terraform show -json)

We should probably do the same thing and not display those fields by default (and include them with --show-json).

I'm not sure if there's a straightforward way to get the list of what fields terraform considers sensitive from their CLI, or if it's hard-coded in the provider settings somewhere (@iterative/cml team may know?)

@pmrowla pmrowla self-requested a review September 21, 2021 02:43
@casperdcl
Copy link
Contributor

casperdcl commented Sep 21, 2021

@pmrowla we hardcode a whitelist in CML https://github.com/iterative/cml/blob/2e9a21ddb4b4eb1261a75ba72f89b98b1972d063/bin/cml/runner.js#L191-L212 and also mark sensitive things in TPI.go (e.g. https://github.com/iterative/terraform-provider-iterative/blob/732d0919577867d40b7ff635dd0667caf19d3cb9/iterative/resource_machine.go#L106) for terraform show

@karajan1001
Copy link
Contributor Author

@pmrowla we hardcode a whitelist in CML https://github.com/iterative/cml/blob/2e9a21ddb4b4eb1261a75ba72f89b98b1972d063/bin/cml/runner.js#L191-L212 and also mark sensitive things in TPI.go (e.g. https://github.com/iterative/terraform-provider-iterative/blob/732d0919577867d40b7ff635dd0667caf19d3cb9/iterative/resource_machine.go#L106) for terraform show

Any way to read this white list? Looks like I need to hardcode it first and sync manually first.

@karajan1001
Copy link
Contributor Author

@karajan1001 How much extra work would it take to add an asciinema or other video inside of these PRs as an example? It might also make it easier to demo the feature.

asciicast

Copy link
Contributor

@casperdcl casperdcl left a comment

Choose a reason for hiding this comment

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

Any way to read this white list? Looks like I need to hardcode it first and sync manually first.

SENSITIVE_FIELDS = {"ssh_private", "startup_script"} seems enough

dvc/machine/__init__.py Outdated Show resolved Hide resolved
@karajan1001 karajan1001 linked an issue Sep 29, 2021 that may be closed by this pull request
1 task
@karajan1001
Copy link
Contributor Author

asciicast

@dberenbaum
Copy link
Collaborator

dberenbaum commented Sep 30, 2021

UI comments:

  • It's unclear whether this is intended to show a single machine/instance or all of them. It looks like it's set up to show multiple instances per machine if they exist, which sounds nice for the future. In that case, why not be able to show instances of all machines at once?
  • Terraform output doesn't conform with our UI guidelines. If we want to have raw terraform output as an option, I think we also need more typical DVC output to summarize the relevant info in a table or something that looks cleaner and easier to parse. We also probably need to consider which fields are actually relevant. For example, the ssh key info is probably too much detail, especially since DVC has a built-in dvc machine ssh command.

cc @skshetry

@casperdcl
Copy link
Contributor

@dberenbaum I think suppressing terraform's CLI output may be an upstream feature request related to https://github.com/iterative/tpi/blob/c7259a8fea023797058deaf487700645df5fe210/tpi/__init__.py#L60

@@ -143,6 +143,22 @@ def run(self):
return 0


class CmdMachineStatus(CmdBase):
SHOWN_FIELD = ["name", "cloud", "instance_hdd_size", "instance_ip"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we include instance_launch_time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed


all_status = self.repo.machine.status(self.args.name)
for i, status in enumerate(all_status, start=1):
ui.write(f"instance_num_{i}:")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be a table, more like dvc stage list, to make it easier to parse? We are trying to have default outputs that are both easy to read and parse if possible.

@dberenbaum
Copy link
Collaborator

dberenbaum commented Sep 30, 2021

@dberenbaum I think suppressing terraform's CLI output may be an upstream feature request related to https://github.com/iterative/tpi/blob/c7259a8fea023797058deaf487700645df5fe210/tpi/__init__.py#L60

Thanks, @casperdcl! Should I open an issue?

Also, is there a "local" option supported for tpi cloud? @karajan1001 @pmrowla Would that be helpful for integration tests and development generally?

@casperdcl
Copy link
Contributor

@dberenbaum were you intending to quote #6649 (comment) instead?

@dberenbaum
Copy link
Collaborator

@dberenbaum were you intending to quote #6649 (comment) instead?

Yup, thanks. I'll edit it to reference the correct quote.

@pmrowla
Copy link
Contributor

pmrowla commented Oct 1, 2021

@dberenbaum Regarding the terraform CLI output, we originally decided to leave it enabled by default (and not suppress it) since there is no other way for us to reflect status while terraform ... commands are running (and we expect them to be slow).

Since we can't hook into the terraform process itself to setup any kind of status callbacks, the only other option on the DVC UI side would be to just display something like a spinner (we can't provide any progressbar-like estimate of when the terraform command will complete).

@skshetry
Copy link
Member

skshetry commented Oct 1, 2021

Another way might be to only show the tail of the output limited to n lines, just like the progress bar (on how they clear up the screen), and dump whatever we have on failure.

@dberenbaum
Copy link
Collaborator

We don't want to fully suppress the output for commands where progress is important (like dvc machine add), but for dvc machine status, is it needed?

On the other hand, I can imagine some people might want the option to see the raw terraform output if they are familiar with that or want more granular info, so it might not be bad as an option (or maybe include in verbose logging?). If we do show it, it would be helpful to somehow tag it or separate it from output controlled by DVC.

@pmrowla
Copy link
Contributor

pmrowla commented Oct 19, 2021

Going to merge this as-is since it's been on hold for a bit. Suppressing the terraform CLI output should be handled upstream in TPI, and tabular formatting for the status output (and decisions on additional fields to display) can be handled in a follow-up PR

@pmrowla pmrowla merged commit 966dc8a into iterative:master Oct 19, 2021
@karajan1001 karajan1001 deleted the fix6482 branch October 19, 2021 08:50
@dberenbaum
Copy link
Collaborator

What about making name optional so all machines can be shown at once? I'll open a separate issue for this since it's already merged.

@efiop efiop added the feature is a feature label Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature is a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

machine: list status of created instances
7 participants