Systemd service support for LXC containers (OD-1936)
Arthur L opened 2 weeks ago


I'm trying to add an agent on Ubuntu 18 to execute local commands.

I've installed the systemd service by

./ install

But when started, it just timeouts

root@ldex1-manage1:/opt/onedev-agent/bin# ./ start
Starting OneDev Agent with systemd...

Logs saying its just timed out

Jun 04 15:49:25 hostname systemd[1]: Starting OneDev Agent...
Jun 04 15:49:25 hostname[22002]: Starting OneDev Agent...
Jun 04 15:50:56 hostname  systemd[1]: onedevagent.service: Start operation timed out. Terminating.
Jun 04 15:50:56 hostname  systemd[1]: onedevagent.service: Failed with result 'timeout'.
Jun 04 15:50:56 hostname[22002]: Waiting for OneDev Agent..........................................................................
Jun 04 15:50:56 hostname  systemd[1]: Failed to start OneDev Agent.

I've tried to strace the process and it end loop on this part:

--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=23259, si_uid=1006, si_status=0, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]})                 = 0
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 23259
stat("/opt/onedev-agent/bin/", {st_mode=S_IFREG|0644, st_size=11, ...}) = 0
faccessat(AT_FDCWD, "/opt/onedev-agent/bin/", R_OK) = 0
pipe([3, 4])                            = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f3949c8c810) = 23260
close(4)                                = 0
read(3, "DOWN_CLEAN\n", 128)            = 11
read(3, "", 128)                        = 0
cat /opt/onedev-agent/bin/

I see no problem connecting agent by using

./ console

Need help to sort this, please.

Robin Shen commented 2 weeks ago

Just tested on a new Ubuntu 18 machine, and it works. Please make sure that:

  1. Property RUN_AS_USER is specified in bin/ as the user owning the agent directory
  2. Install agent as root by running sudo install
Arthur L commented 2 weeks ago

Hello @robin and thank you for checking this.

Indeed, I've launched fresh Ubuntu 18 KVM, did the same steps and it worked there. The only difference that original Ubuntu 18 is running as LXC container. so it might be related.

Do you have any ideas what can make it unhappy?

Robin Shen commented 2 weeks ago

Never tested on LXC containers. Converted as an improvement request.

Robin Shen changed fields 2 weeks ago
Name Previous Value Current Value
Robin Shen changed title 2 weeks ago
Previous Value Current Value
Ubuntu 18 bare metal agent as service not working
Systemd service support for LXC containers
Robin Shen commented 2 weeks ago

Tested with LXC container and it works at my side. This is what I have done:

  1. Start a new EC2 instance with Ubuntu 24.04 image

  2. Run below commands to start a LXC container:

    sudo apt update
    sudo apt install -y lxc
    sudo lxc-create -t download -n test --dist ubuntu --release bionic --arch amd64
    sudo lxc-start -n test
  3. Run sudo lxc-attach -n test to open a shell to container, and inside the container run below command to start OneDev:

    apt update
    apt install -y openjdk-11-jdk wget unzip
    cd onedev-latest/bin
    ./ install
    service onedev start
Robin Shen changed state to 'Closed' 14 hours ago
Previous Value Current Value
issue 1 of 1
No labels
Issue Votes (0)
Watchers (2)
Please wait...
Page is in error, reload to recover