Skip to content

FEAT: Disable APT-Cacher by default #249

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

Closed
wants to merge 1 commit into from

Conversation

micaelmalta
Copy link

@micaelmalta micaelmalta commented Jul 11, 2021

CONTEXT

apt-cacher is not working with all OS (ex: MacOS)

PROPOSAL

Option to enable apt-cacher in a docker container
Use docker network host to access it

OTHER FIX

Ubuntu ESM Infra is not available, delete it from sources_list

@micaelmalta micaelmalta requested a review from devrandom as a code owner July 11, 2021 01:10
@micaelmalta micaelmalta force-pushed the docker branch 2 times, most recently from f9eaa91 to 4c31f58 Compare July 11, 2021 02:51
Copy link
Owner

@devrandom devrandom left a comment

Choose a reason for hiding this comment

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

Looks good overall - but I'm seeking feedback from others whether this should be feature gated in case people have a reason to use the system apt-cacher-ng

@achow101
Copy link
Contributor

I think it would be better to have the apt-cacher container run when it is explicitly asked for. I don't think it should be on enabled by default.

Additionally, the changes made here are in make-base-vm, but this script is typically run once. The apt-cacher is still used by gbuild when it installs the packages specified for the current build. So you would need to have it start it there too.

In general, I don't really like this approach. It is already possible to specify the host running apt-cacher using MIRROR_HOST. If it is not possible to run apt-cacher in a docker container and set MIRROR_HOST to point to that, then I would prefer changes be made to allow that to work rather than having gitian run another container.

@micaelmalta
Copy link
Author

micaelmalta commented Jul 11, 2021

I think it would be better to have the apt-cacher container run when it is explicitly asked for. I don't think it should be on enabled by default.

Additionally, the changes made here are in make-base-vm, but this script is typically run once. The apt-cacher is still used by gbuild when it installs the packages specified for the current build. So you would need to have it start it there too.

In general, I don't really like this approach. It is already possible to specify the host running apt-cacher using MIRROR_HOST. If it is not possible to run apt-cacher in a docker container and set MIRROR_HOST to point to that, then I would prefer changes be made to allow that to work rather than having gitian run another container.

That's fair. I removed apt-cacher and just let the fix for ESM and also to plug with the network host

As we are now using docker network host, we dont need to change the MIRROR_DEFAULT in case of Docker

@devrandom
Copy link
Owner

That's fair. I removed apt-cacher and just let the fix for ESM and also to plug with the network host

@achow101 makes a good point. However, it would still be nice to have a Dockerfile / startup script for a apt-cacher-ng container, perhaps in a contrib/ directory. What do you think?

@devrandom
Copy link
Owner

Or if you don't feel like that should go into this PR, could you change the PR title / description to reflect the new scope?

Copy link
Contributor

@AbcSxyZ AbcSxyZ left a comment

Choose a reason for hiding this comment

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

Usage not updated, open --disable-apt-cacher should be added.

@micaelmalta micaelmalta force-pushed the docker branch 3 times, most recently from 21d345b to 54ccd5a Compare July 12, 2021 16:41
@micaelmalta micaelmalta changed the title FEAT: use docker cross OS FEAT: Disable APT-Cacher by default Jul 12, 2021
@micaelmalta
Copy link
Author

Usage not updated, open --disable-apt-cacher should be added.

Based on this comment, #249 (comment), I change to disable apt-cacher by default

@micaelmalta
Copy link
Author

micaelmalta commented Jul 14, 2021

Hello!

So the whole purpose of this fix was to be able to easily launch a GITIAN build either locally or on a CI.
The original idea was to have as many DOGECOIN developers to use it easily

Here is my work: https://github.com/micaelmalta/gitian-builder-dogecoin

You can have here a DEMO of a working CI: https://cirrus-ci.com/build/4704793919750144

@devrandom
Copy link
Owner

Sorry for the delay reviewing.

I would prefer not to change the default, since I believe most existing users of Gitian do use apt-cacher. Let's have it continue to be on by default and the flag would be to disable.

@AbcSxyZ
Copy link
Contributor

AbcSxyZ commented Jul 28, 2021

[I don't have important usage/knowledge of the soft, used with dogecoin only.]

At first, without thinking about existing users, what would be the best between enable or disable apt-cacher by default ? Did you get user feedbacks ?
Look like if you use it for a single crypto once, it may be overkill, but maybe when a user release regularly versions or different cryptos it has an interest.

In the scenario apt-cacher isn't really required by default, you would prefer to conserve backward compatibility over simpler interface ?
Because you're in Alpha version, you may be able to do those change between the 0.2 and 0.3 release. In the worst case, the problem would be to download source instead of using cache.

In case if apt-cacher is an advantage by default, life is easier :)

@devrandom
Copy link
Owner

The main use-case for Gitian has been developers that do regular releases.

Also, in the case of CI, I believe that caching should be on (with persistent storage), so as to not abuse the OS repositories.

@cculianu
Copy link
Contributor

I'm a fan of this feature.

Whatever the default is (on or off), I'm ok with, so long as it can be turned on/off at will. The ability to turn it off is important for macOS. My modest PR here: #252, which is related, just turns it off unconditionally for the macOS case....

@AbcSxyZ
Copy link
Contributor

AbcSxyZ commented Sep 16, 2021

Regarding #227 (comment), I suspect a communication issue where everyone was waiting on each other :)

I suggested some changes to his code to have apt cacher used by default, see micaelmalta#1.

@@ -208,7 +219,7 @@ WORKDIR /home/$DISTRO
CMD ["sleep", "infinity"]
EOF

docker build --pull -f $OUT.Dockerfile -t $OUT .
docker build --network host --pull -f $OUT.Dockerfile -t $OUT .
Copy link
Owner

Choose a reason for hiding this comment

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

unfortunately, this only works on Linux. if this is desired, it has to be behind a flag or a conditional based on the host OS.

(this also relates to the change above, which points to 127.0.0.1 unconditionally)

Copy link
Contributor

Choose a reason for hiding this comment

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

I will try to investigate the purpose of this, why he had to specify the host network and the relation with apt-cacher. Try to understand why he had to play with MIRROR_DEFAULT.

Copy link
Contributor

@AbcSxyZ AbcSxyZ Sep 16, 2021

Choose a reason for hiding this comment

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

For now, if I'm right, it's related to the configuration of apt-cacher when you're using docker.

He's just using adding conditionally the following line in make-base-vm :

RUN echo 'Acquire::http { Proxy "$MIRROR_BASE"; };' > /etc/apt/apt.conf.d/50cacher

So, I guess if mirrors configurations were working with apt-cacher before, not touching to those configurations when disabling apt-cacher shouldn't be a problem ?

Would keeping MIRROR_DEFAULT and docker network like it was be a solution ?

@@ -37,6 +37,6 @@ case $VMSW in
echo "Gitian-${2}" > var/target.vmname
;;
DOCKER)
docker run -d --name gitian-target base-$SUFFIX:latest > /dev/null
docker run --network host -d --name gitian-target base-$SUFFIX:latest > /dev/null
Copy link
Owner

Choose a reason for hiding this comment

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

see comment above regarding this being Linux only

@AbcSxyZ
Copy link
Contributor

AbcSxyZ commented Sep 16, 2021

I guess lxc & kvm are using cacher ? In the current state, isn't it used for them even with --disable-apt-cacher ?

@AbcSxyZ
Copy link
Contributor

AbcSxyZ commented Sep 16, 2021

Yes, lxc & kvm were using apt-cacher. Added this commit https://github.com/AbcSxyZ/gitian-builder/commit/f9a993ec2b28dc1a55382542e41c60e5c793b0b9 to disable apt cacher for them to my PR on @micaelmalta's repo.

I'm wondering if leaving MIRROR* variables like it was may do the job to enable this option, it may look good after this change.

@@ -193,12 +197,19 @@ if [ $DOCKER = "1" ]; then
base_image="$DISTRO:$SUITE"
fi

apt_cacher=""
if [ "$APT_CACHER" = 1 ]; then
apt_cacher="RUN echo 'Acquire::http { Proxy "$MIRROR_BASE"; };' > /etc/apt/apt.conf.d/50cacher"
Copy link
Contributor

Choose a reason for hiding this comment

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

This line introduces a syntax error when using apt-cacher.

Within the 50cacher file of the Dockerfile, will render :

Acquire::http { Proxy http://172.17.0.1:3142; };

instead of

Acquire::http { Proxy "http://172.17.0.1:3142"; };

Need to escape quotes : { Proxy \"$MIRROR_BASE\"; }.

Fixed in 525e33a

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.

5 participants