balena-engine icon indicating copy to clipboard operation
balena-engine copied to clipboard

Installation not working. Update to #55

Open ofirule opened this issue 6 years ago • 10 comments

Installation process I went through on ubuntu 16.04 arch: arm64

Based on: https://github.com/balena-os/balena-engine/issues/55#issuecomment-423890806

1 run install script curl -sfL https://balena.io/engine/install.sh | sh

2 copy balena.service balena.socket from : https://github.com/balena-os/balena-engine/tree/17.06-resin/contrib/init/systemd to directory: /etc/systemd/system

3 create group balena-engine sudo groupadd balena-engine

4 update /etc/systemd/system/balena.service

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service
Wants=network-online.target
Requires=balena-engine.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/local/bin/balena-engine-daemon
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
#TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

changes: ExecStart - 1) change executable path since install.sh puts it in different path 2) remove -H flag since it causes an error TasksMax - Uncommented TimeoutStartSec - Commented, it causes an error

Please update install.sh and or service configuration

ofirule avatar Jan 16 '19 11:01 ofirule

Thanks for this detailed report.

I have started working on a PR that fixes this and clears up some other things here #129

robertgzr avatar Jan 16 '19 12:01 robertgzr

Actually @ofirule can you send a PR with the service tweaks you did? I would like to restrict my PR to only changes to the install script itself...

robertgzr avatar Jan 16 '19 12:01 robertgzr

Creating PR :+1:

ofirule avatar Jan 16 '19 12:01 ofirule

FYI this is still not up to date with what's provided in install.sh.

Here's a configuration that works now, on raspbian 2021-05-07:

curl -sfL https://balena.io/engine/install.sh | sh
sudo groupadd balena-engine
# Add files listed bellow
sudo systemctl daemon-reload
sudo systemctl start balena
sudo systemctl enable balena  # start on boot
sudo usermod -aG balena-engine pi  # (or whatever user) to enable non-root balena mgmt

/etc/systemd/system/balena.service

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service
Wants=network-online.target
Requires=balena.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/local/bin/balena-engine-daemon
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
#TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

/etc/systemd/system/balena.socket

[Unit]
Description=Docker Socket for the API
PartOf=balena.service

[Socket]
ListenStream=/var/run/balena-engine.sock
SocketMode=0660
SocketUser=root
SocketGroup=balena-engine

[Install]
WantedBy=sockets.target

rgaudin avatar Oct 20 '21 12:10 rgaudin

Hello @rgaudin, I'm trying to install the balena-engine in a Raspberry Pi Zero with Raspbian and for this, I've used the steps described above by you, but it does not work. Checking logs wth journalctl -u balena -f if was found this information:

May 11 10:04:11 anna systemd[1]: balena.service: Scheduled restart job, restart counter is at 1.
May 11 10:04:11 anna systemd[1]: Stopped Docker Application Container Engine.
May 11 10:04:11 anna systemd[1]: Starting Docker Application Container Engine...
May 11 10:04:11 anna systemd[1]: balena.service: Main process exited, code=dumped, status=4/ILL
May 11 10:04:11 anna systemd[1]: balena.service: Failed with result 'core-dump'.
May 11 10:04:11 anna systemd[1]: Failed to start Docker Application Container Engine.
May 11 10:04:12 anna systemd[1]: balena.service: Scheduled restart job, restart counter is at 2.
May 11 10:04:12 anna systemd[1]: Stopped Docker Application Container Engine.
May 11 10:04:12 anna systemd[1]: Starting Docker Application Container Engine...
May 11 10:04:12 anna systemd[1]: balena.service: Main process exited, code=dumped, status=4/ILL
May 11 10:04:12 anna systemd[1]: balena.service: Failed with result 'core-dump'.
May 11 10:04:12 anna systemd[1]: Failed to start Docker Application Container Engine.
May 11 10:04:12 anna systemd[1]: balena.service: Scheduled restart job, restart counter is at 3.

bergpb avatar May 11 '22 13:05 bergpb

@bergpb my working code is at https://github.com/rgaudin/bard-image/blob/main/prepare-system.sh#L53 There are a few things (that I forgot) to care about. Like the docker path symlink (I think it was for compose) or the binary name (what the binary does is switched based on called name).

rgaudin avatar May 11 '22 13:05 rgaudin

Nice thanks @rgaudin, after following your installation steps I was found another error on the start balena service:

May 11 11:02:07 anna balena-engine-daemon[6972]: Error starting daemon: Devices cgroup isn't mounted

Do I need to add anything in boot.txt to make it works?

bergpb avatar May 11 '22 14:05 bergpb

There's been a change in cgroups layout in debian buster and balena hasn't been updated to support it so you'd need to stick to 2021-12-02-raspios-buster-armhf-lite until this is handled. I suppose raspian docker is up to date but haven't used it

rgaudin avatar May 11 '22 14:05 rgaudin

Checking I already have the cgroup mounted as expected:

pi@anna:~ $ mount | grep cgroup
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)

But looks like the installation only supports the cgroups v1: https://github.com/balena-os/balena-engine/issues/284

Very appreciate your help @rgaudin I will try to downgrade to the version 2021-12-02-raspios-buster-armhf-lite and use it, until wait for a new release for balena-engine with support to cgroups2

bergpb avatar May 11 '22 14:05 bergpb

Thanks @rgaudin, after install raspbian version 2021-12-02-raspios-buster-armhf-lite and made some adaptations with your install script works fine. Also posting gist here, can help another person in the future: https://gist.github.com/bergpb/50340bcb1599079a23d17fd9d7237e9d

bergpb avatar May 12 '22 00:05 bergpb