Skip to content

Commit

Permalink
Merge pull request #12 from latchbio/rahuldesai1/restart-sysbox-mgr
Browse files Browse the repository at this point in the history
Restart Sysbox Services on Failure
  • Loading branch information
rahuldesai1 authored Mar 26, 2024
2 parents c443569 + f9ea8b0 commit 9da1068
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
15 changes: 15 additions & 0 deletions sysbox-eks.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,21 @@ build {
]
}

provisioner "file" {
source = "systemd"
destination = "/home/ubuntu"
}

provisioner "shell" {
inline_shebang = "/usr/bin/env bash"
inline = [
"echo '>>> Configuring Systemd for Sysbox'",
"sudo mv /home/ubuntu/systemd/system/sysbox-mgr.service /lib/systemd/system/sysbox-mgr.service",
"sudo mv /home/ubuntu/systemd/system/sysbox-fs.service /lib/systemd/system/sysbox-fs.service",
"sudo mv /home/ubuntu/systemd/system/sysbox.service /lib/systemd/system/sysbox.service",
]
}

provisioner "shell" {
inline_shebang = "/usr/bin/env bash"
inline = [
Expand Down
24 changes: 24 additions & 0 deletions systemd/system/sysbox-fs.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[Unit]
Description=sysbox-fs (part of the Sysbox container runtime)
PartOf=sysbox.service
After=sysbox-mgr.service

[Service]
Type=simple
Type=notify
ExecStart=/usr/bin/sysbox-fs
Restart=always
TimeoutStartSec=10
TimeoutStopSec=10
StartLimitInterval=0
NotifyAccess=main
OOMScoreAdjust=-500

# The number of files opened by sysbox-fs is a function of the number of
# containers and the workloads within them. Thus we set the limit to
# infinite so to prevent "too many open files" errors.
LimitNOFILE=infinity
LimitNPROC=infinity

[Install]
WantedBy=sysbox.service
23 changes: 23 additions & 0 deletions systemd/system/sysbox-mgr.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Unit]
Description=sysbox-mgr (part of the Sysbox container runtime)
PartOf=sysbox.service

[Service]
Type=simple
Type=notify
ExecStart=/usr/bin/sysbox-mgr
Restart=always
TimeoutStartSec=45
TimeoutStopSec=90
StartLimitInterval=0
NotifyAccess=main
OOMScoreAdjust=-500

# The number of files opened by sysbox-mgr is a function of the number of
# containers and the size of the rootfs within them. Thus we set the limit to
# infinite so to prevent "too many open files" errors.
LimitNOFILE=infinity
LimitNPROC=infinity

[Install]
WantedBy=sysbox.service
26 changes: 26 additions & 0 deletions systemd/system/sysbox.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Sysbox unit to act as a wrapper of sysbox's inner components/daemons:
# sysbox-mgr and sysbox-fs.

[Unit]
Description=Sysbox container runtime
Documentation=https://github.com/nestybox/sysbox
# rahul: using BindsTo + PartOf prevents the services that are bound
# from restarting on failure. For example, if sysbox-mgr.service is
# killed, sysbox.service will stop because of the 'BindsTo' constraint.
# However, because sysbox-mgr.service is 'PartOf' sysbox.service,
# sysbox-mgr.service will not restart until sysbox.service has started
# BindsTo=sysbox-mgr.service sysbox-fs.service
After=sysbox-mgr.service sysbox-fs.service

# Must start before Docker/containerd to ensure "docker --restart" works
# properly with Sysbox.
Before=docker.service containerd.service

[Service]
Type=exec
ExecStart=/bin/sh -c "/usr/bin/sysbox-runc --version && /usr/bin/sysbox-mgr --version && /usr/bin/sysbox-fs --version && /bin/sleep infinity"
Restart=always

[Install]
# Components of this application should be started at boot time
WantedBy=multi-user.target

0 comments on commit 9da1068

Please sign in to comment.