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

feat: check metered connection before automatic updates #123

Merged
merged 5 commits into from
Oct 2, 2023
Merged

feat: check metered connection before automatic updates #123

merged 5 commits into from
Oct 2, 2023

Conversation

ArtikusHG
Copy link
Contributor

@ArtikusHG ArtikusHG commented Sep 25, 2023

This PR prevents automatic update services from running on a metered connection (see #113 for more details).

Explanation:

  • /bin/bash -c is needed because systemd runs binaries, not shell scripts
  • busctl get-property org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.NetworkManager Metered gets the value of the metered connection property
  • ...but it doesn't just return the number, also some symbols behind it, so we trim them with | cut -c 3-
  • == @(2|4) checks if the result is either 2 (NM_METERED_NO) or 4 (NM_METERED_GUESS_NO), as per documentation:

image

  • the service only runs if the above code returns a success code

Regarding DE app stores and such: GNOME software seems to already have support for not running updates on a metered connection, pretty sure KDE and others have the same thing.

Note: I did test this and it seems to work, but I would like at least a few more people to confirm this before we can get this merged.

Also includes just commands to disable/enable automatic updates at will, without marking the connection as metered.

@tunix
Copy link

tunix commented Sep 26, 2023

LGTM

@ArtikusHG
Copy link
Contributor Author

@tunix did you test it? If so, did you test both the metered connection check and the just commands? I know some people have issues with rpm-ostreed-automatic.timer re-enabling by itself, but according to the docs this shouldn't happen

@ArtikusHG
Copy link
Contributor Author

Also can someone from the maintainers please approve the build workflow? Ideally I want people to be able to rebase to this to test it, it's probably fine but I still wanna make sure this doesn't break anything for anyone

@KyleGospo
Copy link
Member

Also can someone from the maintainers please approve the build workflow? Ideally I want people to be able to rebase to this to test it, it's probably fine but I still wanna make sure this doesn't break anything for anyone

Done, sorry for the long wait.

@ArtikusHG
Copy link
Contributor Author

Thanks! No worries, we're all just regular people working on this in their free time, after all.

@castrojo castrojo enabled auto-merge September 30, 2023 18:42
@bsherman
Copy link
Contributor

bsherman commented Oct 1, 2023

Also can someone from the maintainers please approve the build workflow? Ideally I want people to be able to rebase to this to test it, it's probably fine but I still wanna make sure this doesn't break anything for anyone

I appreciate the desire to test before pushing this out to the world.

Building this workflow in PR is fine, but it won't create an image or RPM for you to test with.

What I do to test changes like this is:

  1. build the config image locally (eg, podman build -f Containerfile)
  2. access the RPMs using a temp container image
$ cat Tempfile
FROM registry.fedoraproject.org/fedora-toolbox:38
COPY --from=ghcr.io/ublue-os/config:latest /rpms /tmp/rpms

$ podman build -f Tempfile -t tmptoolbox
$ podman run --rm -it -v ./tmp/currentdir tmptoolbox 

Then I usually install the RPM inside that container, and if that's all I require, that's fine. Additionally, can copy the RPM to /tmp/currentdir and install locally on my real computer or a VM to make sure it works right.

@ArtikusHG
Copy link
Contributor Author

Oh, I was mislead by the fact that one of the checks was called "build-ublue", and thought it builds the image. Thanks!

@bsherman
Copy link
Contributor

bsherman commented Oct 1, 2023

one of the checks was called "build-ublue"

Good point. That is copy pasta 😂

But take a look at the actions tab and you see how the builds happen. When building for a PR we don't push images.

@ArtikusHG
Copy link
Contributor Author

Has anyone tested this yet?

Copy link
Contributor

@bsherman bsherman left a comment

Choose a reason for hiding this comment

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

One request then I'm ready to approve.

Will you please update the changelogs in the respective RPM spec files?

build/ublue-os-just/ublue-os-just.spec and rpmspec/ublue-os-update-services.spec

auto-merge was automatically disabled October 2, 2023 20:50

Head branch was pushed to by a user without write access

@ArtikusHG ArtikusHG requested a review from bsherman October 2, 2023 20:56
Copy link
Contributor

@bsherman bsherman left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

@bsherman bsherman added this pull request to the merge queue Oct 2, 2023
@bsherman
Copy link
Contributor

bsherman commented Oct 2, 2023

@ArtikusHG this is approved and queued to merge. Thank you for the contribution.

I'd never used the "metered connection" feature before, so I learned something new and I'm excited to use this!

Merged via the queue into ublue-os:main with commit 0823567 Oct 2, 2023
1 check passed
@ArtikusHG
Copy link
Contributor Author

Thanks a lot for helping! I'm happy to be part of this amazing project :)

@ArtikusHG ArtikusHG mentioned this pull request Oct 3, 2023
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.

4 participants