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

Hi,

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

I've installed the systemd service by

./agent.sh install

But when started, it just timeouts

root@ldex1-manage1:/opt/onedev-agent/bin# ./agent.sh 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  agent.sh[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  agent.sh[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/onedevagent.java.status", {st_mode=S_IFREG|0644, st_size=11, ...}) = 0
faccessat(AT_FDCWD, "/opt/onedev-agent/bin/onedevagent.java.status", 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
close(3)                             
cat /opt/onedev-agent/bin/onedevagent.java.status
DOWN_CLEAN

I see no problem connecting agent by using

./agent.sh console

Need help to sort this, please.

Robin Shen commented 2 months 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/agent.sh as the user owning the agent directory
  2. Install agent as root by running sudo agent.sh install
Arthur L commented 2 months 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 months ago

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

Robin Shen changed fields 2 months ago
Name Previous Value Current Value
Type
Question
Improvement
Robin Shen changed title 2 months ago
Previous Value Current Value
Ubuntu 18 bare metal agent as service not working
Systemd service support for LXC containers
Robin Shen commented 2 months 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
    wget https://code.onedev.io/onedev/server/~site/onedev-latest.zip
    unzip onedev-latest.zip
    cd onedev-latest/bin
    ./server.sh install
    service onedev start
    
Robin Shen changed state to 'Closed' 1 month ago
Previous Value Current Value
Open
Closed
issue 1 of 1
Type
Improvement
Priority
Normal
Assignee
Labels
No labels
Issue Votes (0)
Watchers (2)
Reference
OD-1936
Please wait...
Page is in error, reload to recover