-
Notifications
You must be signed in to change notification settings - Fork 95
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
fix: Show in-progress spinner when creating VM #161
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I think we can merge it as it's definitely an improvement, but I'm not 100% sure if #157 can be closed by it as strictly speaking, we're not showing the "progress" (i.e., 30%, 50%, etc.). @ningziwen WDYT?
LGTM overall, just please fix the failed checks. You can ignore the e2e ones as those failures are likely caused by flakiness and are tracked in #140.
cmd/finch/virtual_machine_init.go
Outdated
iva.logger.Errorf("Finch virtual machine failed to start, debug logs: %s", logs) | ||
return err | ||
} | ||
s.Stop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've got this twice - consider using a defer s.Stop()
instead after s.Start()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, updated the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the logs are printed before the spinner stops, while we may want them to be printed after instead.
if err != nil {
iva.logger.Errorf("Finch virtual machine failed to start, debug logs: %s", logs)
return err
}
iva.logger.Info("Finch virtual machine started successfully")
As a result, could you wrap the following statements in a func (initVM
?) and print the logs above after calling that func? Thanks!
instanceName := fmt.Sprintf("--name=%v", limaInstanceName)
limaCmd := iva.creator.CreateWithoutStdio("start", instanceName, iva.baseYamlFilePath, "--tty=false")
iva.logger.Info("Initializing and starting Finch virtual machine...")
// Show spinner
s := spinner.New(spinner.CharSets[11], 100*time.Millisecond)
s.Suffix = "VM creation in progress"
s.Start()
defer s.Stop()
logs, err := limaCmd.CombinedOutput()
Issue: runfinch#157 Signed-off-by: Hari Ohm Prasth Rajagopal <[email protected]>
Thanks @davidhsingyuchen, I have taken care of the comments. Regarding the progress: I looked into this code and seems like |
@hariohmprasath Thanks for the investigation. I think the current form is good enough. We may not want to pipe the stdout from the creation progress as we cannot really control what's being printed out there, and it's sort of implementation details. /cc @ningziwen |
Issue: #157
Signed-off-by: Hari Ohm Prasth Rajagopal [email protected]
Issue #, if available:
#157
Description of changes:
Show spinner when VM creation is in progress
Testing done:
Ran local tests by building the code using make command and tested it by creating a new VM finch vm init command
License Acceptance
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.