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

Progress indicator for just update #698

Closed
bmp opened this issue Dec 1, 2023 · 18 comments
Closed

Progress indicator for just update #698

bmp opened this issue Dec 1, 2023 · 18 comments

Comments

@bmp
Copy link

bmp commented Dec 1, 2023

Describe the bug

Not really a bug, but couldn't find the appropriate category for this. When using just update`, currently, there is no progress indicator, it just asks for the sudo password and waits until everything is done.

What did you expect to happen?

Can we get a a progress indicator for just update? It could just be in the form of running X, running Y rather than a percentage or a progress bar.

Output of rpm-ostree status

● ostree-image-signed:docker://ghcr.io/ublue-os/bluefin-dx-framework:39
                   Digest: sha256:a3703cb7b79f453406609416049e0e6d99bb5cda948dbf417af0a0f569837d66
                  Version: 39.20231129.0 (2023-11-29T18:04:31Z)
          LayeredPackages: gparted keychain neofetch pinentry-emacs pinentry-gtk pinentry-qt

  ostree-image-signed:docker://ghcr.io/ublue-os/bluefin-dx-framework:38
                   Digest: sha256:c3b221f773fe3c6ddc61f454b954f0d5b301288ee5a71d5bec0e623d60412dd2
                  Version: 38.20231128.0 (2023-11-29T18:05:26Z)
          LayeredPackages: gparted keychain neofetch pinentry-emacs pinentry-gtk pinentry-qt wl-clipboard
                   Pinned: yes

Extra information or context

No response

@bobslept
Copy link
Contributor

bobslept commented Dec 1, 2023

I don't think it is possible in the current setup. I agree it is not very good user experience. It is starting ublue-update, which normally runs in the background. Currently the just update will force the start of the service.

However you can monitor the service to see what is happing if you run a just update with the following command:

journalctl -fexu 'ublue-update.service'

@castrojo
Copy link
Member

castrojo commented Dec 2, 2023

Maybe adding an echo with that snippet might be useful in the meantime?

Just for backstory for the people who might have not been around when we did this: we had to move to a service base approach to ensure the installation could be rebased to a signed image since we can't install a signed image directly at the moment.

We have a just update-ng which switches to bootc and assemble, maybe we should consider an alternative verb with the usual update commands with output in the terminal? IMO we still need to keep just update service based since rebasing to the signed image should be the most important thing.

Thoughts on this?

@bmp
Copy link
Author

bmp commented Dec 3, 2023

@bobslept & @castrojo Can echo messages be useful for now? The script (https://github.com/ublue-os/config/blob/main/build/ublue-os-just/10-update.just) seems to suggest that it just runs all three (rpm-ostree, flatpak and distrobox) updates in case ublue updater is not enabled. Or maybe a verbose version of just update without modifying the current update command as it seems to be tied to other things?

@castrojo
Copy link
Member

castrojo commented Dec 3, 2023

We could do just update-verbose with the three commands in the meantime?

@bmp
Copy link
Author

bmp commented Dec 4, 2023

This is the script I have been using, does this make sense?

#!/usr/bin/env bash

if [ "$#" -ne 1 ] || [ "$1" = "help" ]; then
    echo "Usage: $0 <level>"
    echo "  <level>: Specify the verbosity level - 'full', 'minimal', or 'prompt'"
    echo "  Use 'full' to show full output of each command."
    echo "  Use 'minimal' to show minimal output and indicate success or failure."
    echo "  Use 'prompt' to prompt the user before running each command."
    exit 1
fi

level=$1

# Function to run commands with appropriate verbosity and approval check
update_command() {
    command=$1
    case "$level" in
        full)
            echo "Running $command..."
            $command
            echo "Completed $command"
            ;;
        minimal)
            echo "Running $command..."
            $command > /dev/null 2>&1
            if [ $? -eq 0 ]; then
                echo "Completed $command"
            else
                echo "Failed to complete $command"
                exit 1
            fi
            ;;
        prompt)
            printf "Do you want to run %s? [Y/n]: " "$command"
            read user_input
            user_input=${user_input:-Y}  # Default to Y if Enter is pressed
            if [ "$user_input" = "Y" ] || [ "$user_input" = "y" ]; then
                echo "Running $command..."
                $command
                echo "Completed $command"
            else
                echo "Skipped $command"
            fi
            ;;
        *)
            echo "Invalid level: $level. Please use 'full', 'minimal', 'prompt' or 'help' for usage."
            exit 1
            ;;
    esac
}

# Run rpm-ostree update
update_command "rpm-ostree update"

# Run flatpak update
update_command "flatpak update -y"

# Run distrobox upgrade
update_command "distrobox upgrade -a"

In case the just script is a shell script, I can try and add this to the just update script as the case for update-verbose.

@bobslept
Copy link
Contributor

bobslept commented Dec 4, 2023

Alright, well if we go the route of just update-verbose you could add something like this to the just file you linked. No need for that big script in there.

# some nice title to show when user types `just`
update-verbose:
    rpm-ostree update
    flatpak update -y
    distrobox upgrade -a

There is one situation, which would fail, and that is a fresh install from the bluefin iso. Because the service will correct the deployment path /var/ublue-os/image but that is already pointed out in the release notes. So I think that would not be a problem.

Adding an echo to the just update command after starting the service echo one with something like: "To see what is happening use journalctl -fexu 'ublue-update.service'"

@bmp
Copy link
Author

bmp commented Dec 5, 2023

@bobslept I understand the use of journalctl -fexu 'ublue-update.service' to see what is happening, but wouldn't it be better if it were self contained here rather than running another additional command?

I use this script personally in order to see what is being updated when I want to check if it is happening over slower connectioned when I am travelling or when I see a specific security update for the arch distrobox or flatpak.

Given my usage, I tend to have auto updates turned off and hence this method.

@bobslept
Copy link
Contributor

bobslept commented Dec 5, 2023

Sorry I think I don't understand it anymore. Recap

  • Question: Can we have more verbose output?
  • Anwser: Not in current setup, and we need that setup at this moment because of limitations in other places.
  • Proposal: Add just update-verbose that gives a variant with output. And for the just update inform users about journalctl

No need for scripts to reach that goal. If you already disable the ublue-update service, the just update should behave like we propose to do with just update-verbose. If it doesn't it, then we need to look in that, because that is how it should behave.

For me it does behave like it:

~ ❯ just disable-updates 
[sudo] password for user: 
Removed "/etc/systemd/system/timers.target.wants/ublue-update.timer".

~ ❯ just update
note: automatic updates (stage) are enabled
Pulling manifest: ostree-image-signed:docker://ghcr.io/ublue-os/bluefin-dx:39
No upgrade available.
Looking for updates…

Nothing to do.

~ ❯ just enable-updates 
Created symlink /etc/systemd/system/timers.target.wants/ublue-update.timer → /usr/lib/systemd/system/ublue-update.timer.

~ ❯ just update
Starting the ublue-update service

Or did you want more verbose out in the case of a situation where you already did just disable-updates

@bmp
Copy link
Author

bmp commented Dec 5, 2023

Apologies if I wasn't clear in my response, but this is what I was referring to.

Or did you want more verbose out in the case of a situation where you already did just disable-updates

@bobslept
Copy link
Contributor

bobslept commented Dec 5, 2023

Alright now I understand! Glad we sorted that part out 😄

So i did a little bit of fiddling with you script to incorporate it into the just file, so people can try it out. Defaults to full if no argument is given.

# Update system, flatpaks, and containers all at once
update VERB_LEVEL="full":
    #!/usr/bin/env bash
    if systemctl is-enabled ublue-update.timer | grep -q enabled;
    then
      echo "Starting the ublue-update service"
      sudo systemctl start ublue-update.service
    else
      if [ {{ VERB_LEVEL }} = "help" ]; then
          echo "Usage: just update <level>"
          echo "  <level>: Specify the verbosity level - 'full', 'minimal', or 'prompt'"
          echo "  Use 'full' to show full output of each command."
          echo "  Use 'minimal' to show minimal output and indicate success or failure."
          echo "  Use 'prompt' to prompt the user before running each command."
          exit 0
      fi

      # Function to run commands with appropriate verbosity and approval check
      update_command() {
          command=$1
          case "{{ VERB_LEVEL }}" in
              full)
                  echo "Running $command..."
                  $command
                  echo "Completed $command"
                  ;;
              minimal)
                  echo "Running $command..."
                  $command > /dev/null 2>&1
                  if [ $? -eq 0 ]; then
                      echo "Completed $command"
                  else
                      echo "Failed to complete $command"
                      exit 1
                  fi
                  ;;
              prompt)
                  printf "Do you want to run %s? [Y/n]: " "$command"
                  read user_input
                  user_input=${user_input:-Y}  # Default to Y if Enter is pressed
                  if [ "$user_input" = "Y" ] || [ "$user_input" = "y" ]; then
                      echo "Running $command..."
                      $command
                      echo "Completed $command"
                  else
                      echo "Skipped $command"
                  fi
                  ;;
              *)
                  echo "Invalid level: {{ VERB_LEVEL }}. Please use 'full', 'minimal', 'prompt' or 'help' for usage."
                  exit 1
                  ;;
          esac
      }

      # Run rpm-ostree update
      update_command "rpm-ostree update"

      # Run flatpak update
      update_command "flatpak update -y"

      # Run distrobox upgrade
      update_command "distrobox upgrade -a"

    fi

Outputs:

~ ❯ just -f update.just update help
Usage: just update <level>
  <level>: Specify the verbosity level - 'full', 'minimal', or 'prompt'
  Use 'full' to show full output of each command.
  Use 'minimal' to show minimal output and indicate success or failure.
  Use 'prompt' to prompt the user before running each command.

~ ❯ just -f update.just update
Running rpm-ostree update...
note: automatic updates (stage) are enabled
Pulling manifest: ostree-image-signed:docker://ghcr.io/ublue-os/bluefin-dx:39
No upgrade available.
Completed rpm-ostree update
Running flatpak update -y...
Looking for updates…

Nothing to do.
Completed flatpak update -y
Running distrobox upgrade -a...
Completed distrobox upgrade -a

~ ❯ just -f update.just update minimal
Running rpm-ostree update...
Completed rpm-ostree update
Running flatpak update -y...
Completed flatpak update -y
Running distrobox upgrade -a...
Completed distrobox upgrade -a

~ ❯ just -f update.just update prompt
Do you want to run rpm-ostree update? [Y/n]: n
Skipped rpm-ostree update
Do you want to run flatpak update -y? [Y/n]: n
Skipped flatpak update -y
Do you want to run distrobox upgrade -a? [Y/n]: y
Running distrobox upgrade -a...
Completed distrobox upgrade -a

~ ❯ 

So this applies only to the just update where ublue-update is turned off. @castrojo what do you think about this?

@bmp
Copy link
Author

bmp commented Dec 5, 2023

This makes complete sense! Hope it gets included now :-)

@bobslept
Copy link
Contributor

bobslept commented Dec 5, 2023

This makes complete sense! Hope it gets included now :-)

Well if you want and able to make a PR, feel free to do! Not sure how comfortable you are with git?
The just file that need to be edited is https://github.com/ublue-os/config/blob/main/build/ublue-os-just/10-update.just and the repo is config

fork the config repo, edit 10-update.just file, commit it to your fork with a commit msg something like feat(just): verbose update messages or whatever you come up with. And after that create pull request! If it gets accepted it will end up in all images that incorporate just update!

@bmp
Copy link
Author

bmp commented Dec 5, 2023

Tried my first PR on this repo: ublue-os/config#167, but it requires review I guess. Sorry, haven't ever used this before!

@bobslept
Copy link
Contributor

bobslept commented Dec 5, 2023

Tried my first PR on this repo: ublue-os/config#167, but it requires review I guess. Sorry, haven't ever used this before!

Awesome! seems to have worked fine. I've added a comment there, let see what the others think of this!

@bmp
Copy link
Author

bmp commented Dec 5, 2023

@bobslept Thank you for the encouragement :-)

@bobslept
Copy link
Contributor

bobslept commented Dec 7, 2023

Your PR has been merged!! 🥳

It should be available for everyone when the next image rebuilds.

Congrats @bmp, awesome job!

@bobslept bobslept closed this as completed Dec 7, 2023
@bmp
Copy link
Author

bmp commented Dec 7, 2023

@bobslept Thank you for all the help and encouragement :-)

@castrojo
Copy link
Member

castrojo commented Dec 7, 2023

This is really nice, well done team!

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

No branches or pull requests

3 participants