tmatilai / vagrant-proxyconf

Vagrant plugin that configures the virtual machine to use proxies
MIT License
531 stars 74 forks source link

BUG: On Ubuntu 18.04 vagrant-proxyconf 2.0.1 when docker-ce-cli is installed it tries to configure systemd even though the docker daemon service is not there. #192

Open codylane opened 5 years ago

codylane commented 5 years ago

OS: Ubuntu 18.04 amd64 Vagrant version: 2.2.4 vagrant-proxyconf version: 2.0.1

How to reproduce:

When following this guide: https://docs.docker.com/install/linux/docker-ce/ubuntu/

And only installing docker-ce-cli on the host, and then running vagrant provision the vagrant-proxyconf plugin will attempt to configure the docker systemd service.

With the following error:

$ vagrant provision
==> default: Configuring proxy for Apt...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

sed -e 's/\[Service\]/[Service]\nEnvironmentFile=-\/etc\/default\/docker/g' /lib/systemd/system/docker.service > /tmp/docker.service

Stdout from the command:
Stderr from the command:

sed: can't read /lib/systemd/system/docker.service: No such file or directory
vagrant@devenv:~$ dpkg -l | grep -i docker
ii  docker-ce-cli                         5:18.09.5~3-0~ubuntu-bionic       amd64        Docker CLI: the open-source application container engine

Potential solution:

codylane commented 5 years ago

Interesting, I didn't notice this before but it looks as though this plugin attempted to support configuring the docker daemon with proxy configuration but it was done so in the cap directories. The cap directories have a few additional flaws that need to be addressed and need to be cleaned up.

If 2.0.2, addresses the docker daemon setup, then I feel like it's also a good idea to remove whatever implementation exists in the cap implementations. The bug we are seeing above is caused by the capability file thinking systemd is working but that's not always the case especially if you are inside a docker container or the system doesn't have the full systemd integration installed.

Places where this is defined in the capabilities

zicklag commented 4 years ago

Looks like you may already be fixing this but, just in case it is useful, this also happened to me when I installed the Docker snap package in the vagrant machine manually and then I did a vagrant halt and a vagrant up later. Looks like it is because the snap installs Docker differently than apt and doesn't have the same systemd files created.

codylane commented 4 years ago

Hi @zicklag - Thank you for the report and for notifying us that this behavior also affects other types of docker installs. This does seem to be one of those edge cases that will be challenging to fix.

Due to time constraints and how this code base is currently architected I'd say we probably won't be trying to support every type of docker-ce install and will probably only support the package manager install (in this case apt) instead of snap.

I'm still attempting to solve this issue, although I see this one as a minor compared to other bugs/features that need to be addressed. I do appreciate you taking the time to help report this issue and it is validating to know that others are also experiencing this problem.

If you feel that this issue issues needs faster resolution and if others feel the same way, please help me prioritize this by thumbs upping this message. Otherwise, if you feel comfortable and have some free time and willing to help we will accept pull requests.

zicklag commented 4 years ago

I don't have a large need for it and I think it is reasonable that you would not be able to universally set the Docker proxy for every installation method. If you can't manage to fix it, no big deal. We would just want to log that the Docker proxy could not be set so that the user knows what is happening and can respond accordingly.

codylane commented 4 years ago

I don't have a large need for it and I think it is reasonable that you would not be able to universally set the Docker proxy for every installation method. If you can't manage to fix it, no big deal. We would just want to log that the Docker proxy could not be set so that the user knows what is happening and can respond accordingly.

Just curious, would you be able to share a gist or paste in the errors/issues that you are seeing in code block here in this thread? I'd love to have that for my own reference just to make sure I'm seeing the same error or if it's a little different.

I agree, I want to squelch un-handled exceptions as best as I can with more helpful error messages. Hopefully, this will be an easy fix which I hope to have some free time next week.

Thanks again and looking forward to hearing from you. Also hope your week is going well.

zicklag commented 4 years ago

I'm pretty sure that it was exactly the same, but I'll try it again when I get the chance to make sure.

zicklag commented 4 years ago

Here is the error I get:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

sed -e 's/\[Service\]/[Service]\nEnvironmentFile=-\/etc\/default\/docker/g' /lib/systemd/system/docker.service > /tmp/docker.service

Stdout from the command:

Stderr from the command:

sed: can't read /lib/systemd/system/docker.service: No such file or directory
codylane commented 4 years ago

Excellent, thank you @zicklag, this will help ensure that I update the right place(s).