lima-vm / lima

Linux virtual machines, with a focus on running containers
https://lima-vm.io/
Apache License 2.0
15.24k stars 600 forks source link

Show more user-friendly output, from the `start` command #1311

Open afbjorklund opened 1 year ago

afbjorklund commented 1 year ago

Description

Currently, the limactl start defaults to dumping the log with the INFO level to the console.

Turning off the logging means that only the final message (if any), was showing to the user.

I was experimenting with a less verbose mode, that only showed the major progress steps...

There were only two events in the start, Booting and Running, so I wanted to add requirements.

Booting: INFO[0000] SSH Local Port: 60022

Running: INFO[0028] READY. Runlimato open the shell.

The log also has some internal info, like mounts and forwards.

INFO[0000] [hostagent] Waiting for the essential requirement 1 of 5: "ssh" 
INFO[0010] [hostagent] Waiting for the essential requirement 1 of 5: "ssh" 
INFO[0017] [hostagent] The essential requirement 1 of 5 is satisfied 
INFO[0017] [hostagent] Waiting for the essential requirement 2 of 5: "user session is ready for ssh" 
INFO[0027] [hostagent] Waiting for the essential requirement 2 of 5: "user session is ready for ssh" 
INFO[0028] [hostagent] The essential requirement 2 of 5 is satisfied 
INFO[0028] [hostagent] Waiting for the essential requirement 3 of 5: "sshfs binary to be installed" 
INFO[0028] [hostagent] The essential requirement 3 of 5 is satisfied 
INFO[0028] [hostagent] Waiting for the essential requirement 4 of 5: "/etc/fuse.conf (/etc/fuse3.conf) to contain \"user_allow_other\"" 
INFO[0028] [hostagent] The essential requirement 4 of 5 is satisfied 
INFO[0028] [hostagent] Waiting for the essential requirement 5 of 5: "the guest agent to be running" 
INFO[0028] [hostagent] The essential requirement 5 of 5 is satisfied 
INFO[0028] [hostagent] Mounting "/home/anders" on "/home/anders" 
INFO[0028] [hostagent] Mounting "/tmp/lima" on "/tmp/lima" 
INFO[0028] [hostagent] Forwarding "/run/lima-guestagent.sock" (guest) to "/home/anders/.lima/default/ga.sock" (host) 
INFO[0028] [hostagent] Waiting for the optional requirement 1 of 2: "systemd must be available" 
INFO[0028] [hostagent] Not forwarding TCP 127.0.0.53:53 
INFO[0028] [hostagent] Not forwarding TCP 127.0.0.54:53 
INFO[0028] [hostagent] The optional requirement 1 of 2 is satisfied 
INFO[0028] [hostagent] Not forwarding TCP [::]:22       
INFO[0028] [hostagent] Waiting for the optional requirement 2 of 2: "containerd binaries to be installed" 
INFO[0028] [hostagent] The optional requirement 2 of 2 is satisfied 
INFO[0028] [hostagent] Waiting for the final requirement 1 of 1: "boot scripts must have finished" 
INFO[0028] [hostagent] The final requirement 1 of 1 is satisfied 

Counted the total, and added a progress bar:

$ limactl --silent start --progress
Starting "default"
Waiting 1 / 8 [--->________________________]  "ssh" (essential 1/5)                                 
Waiting 2 / 8 [------>_____________________]  "user session is ready for ssh" (essential 2/5)       
Waiting 3 / 8 [---------->_________________]  "sshfs binary to be installed" (essential 3/5)        
Waiting 4 / 8 [------------->______________]  "fuse to \"allow_other\" as user" (essential 4/5)     
Waiting 5 / 8 [----------------->__________]  "the guest agent to be running" (essential 5/5)       
Waiting 6 / 8 [-------------------->_______]  "systemd must be available" (optional 1/2)            
Waiting 7 / 8 [------------------------>___]  "containerd binaries to be installed" (optional 2/2)  
Waiting 8 / 8 [----------------------------]  "boot scripts must have finished" (final 1/1)         
READY.

Found it less distracting, if the old steps remained.

By default, the new step information replaces the old.

afbjorklund commented 1 year ago

One thing that I noticed afterwards, was that the download progressbar didn't output any URL outside the log.

So should add that, as a separate line. When not showing the log, and actually having to download something.

verbose

INFO[0000] Using the existing instance "default"        
INFO[0000] Hint: To create another instance, run the following command: limactl start --name=NAME template://default 
INFO[0000] Attempting to download the nerdctl archive from "https://github.com/containerd/nerdctl/releases/download/v1.1.0/nerdctl-full-1.1.0-linux-amd64.tar.gz"  digest="sha256:5440c7b3af63df2ad2c98e185e06a27b4a21eea334b05408e84f8502251d9459"
18.72 MiB / 224.27 MiB [--->__________________________________] 8.35% 5.68 MiB/s

silent

https://github.com/containerd/nerdctl/releases/download/v1.1.0/nerdctl-full-1.1.0-linux-amd64.tar.gz
18.72 MiB / 224.27 MiB [--->__________________________________] 8.35% 5.68 MiB/s
afbjorklund commented 1 year ago

Made a small cosmetic change, so that the messages all fit within 100 characters: 2e030822e939f67f124d004ee41bf3847ee86836

Starting "default"
Waiting 1 / 8 [--->________________________]  "ssh" (essential 1/5)                                 
Waiting 2 / 8 [------>_____________________]  "user session is ready for ssh" (essential 2/5)       
Waiting 3 / 8 [---------->_________________]  "sshfs binary to be installed" (essential 3/5)        
Waiting 4 / 8 [------------->______________]  "fuse to \"allow_other\" as user" (essential 4/5)     
Waiting 5 / 8 [----------------->__________]  "the guest agent to be running" (essential 5/5)       
Waiting 6 / 8 [-------------------->_______]  "systemd must be available" (optional 1/2)            
Waiting 7 / 8 [------------------------>___]  "containerd binaries to be installed" (optional 2/2)  
Waiting 8 / 8 [----------------------------]  "boot scripts must have finished" (final 1/1)         
READY.