File tree Expand file tree Collapse file tree 8 files changed +30
-10
lines changed Expand file tree Collapse file tree 8 files changed +30
-10
lines changed Original file line number Diff line number Diff line change 1212 - uses : actions/checkout@v2
1313 - name : Run containerd-driver integration tests
1414 run : |
15+ sudo modprobe bridge
1516 mkdir -p /home/runner/go/src/github.com/hashistack4u
1617 ln -s /home/runner/work/nomad-driver-containerd/nomad-driver-containerd /home/runner/go/src/github.com/hashistack4u/nomad-driver-containerd
1718 cd /home/runner/go/src/github.com/hashistack4u/nomad-driver-containerd
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ Vagrant.configure("2") do |config|
2323 apt-get install -y unzip gcc runc jq make
2424 echo "export GOPATH=/home/vagrant/go" >> /home/vagrant/.bashrc
2525 echo "export PATH=$PATH:/usr/local/go/bin" >> /home/vagrant/.bashrc
26- echo "export CONTAINERD_NAMESPACE=nomad" >> /home/vagrant/.bashrc
26+ echo "export CONTAINERD_NAMESPACE=nomad.slice " >> /home/vagrant/.bashrc
2727 source /home/vagrant/.bashrc
2828 # without keeping HOME env, 'sudo make test' will try to find files under /root/go/
2929 echo "Defaults env_keep += HOME" | sudo tee /etc/sudoers.d/keep_home
Original file line number Diff line number Diff line change 11log_level = " INFO"
22data_dir = " /tmp/nomad"
33
4+ advertise {
5+ http = " 127.0.0.1"
6+ rpc = " 127.0.0.1"
7+ serf = " 127.0.0.1"
8+ }
9+
410plugin "containerd-driver" {
511 config {
612 enabled = true
713 containerd_runtime = " io.containerd.runc.v2"
814 stats_interval = " 5s"
15+ allow_privileged = true
916 }
1017}
1118
@@ -30,4 +37,7 @@ client {
3037 path = " /tmp/host_volume/s1"
3138 read_only = false
3239 }
40+ options {
41+ " driver.allowlist" = " containerd-driver"
42+ }
3343}
Original file line number Diff line number Diff line change @@ -50,13 +50,13 @@ test_redis_nomad_job() {
5050 fi
5151
5252 echo " INFO: Check if memory and memory_max are set correctly in the cgroup filesystem."
53- task_name=$( sudo CONTAINERD_NAMESPACE=nomad ctr containers ls| awk ' NR!=1' | cut -d' ' -f1)
54- memory_soft_limit=$( sudo cat /sys/fs/cgroup/memory/ nomad/$task_name /memory.soft_limit_in_bytes )
53+ task_name=$( sudo CONTAINERD_NAMESPACE=nomad.slice ctr containers ls| awk ' NR!=1' | cut -d' ' -f1)
54+ memory_soft_limit=$( sudo cat /sys/fs/cgroup/nomad.slice /$task_name /memory.low )
5555 if [ $memory_soft_limit != " $(( 256 * 1024 * 1024 )) " ]; then
5656 echo " ERROR: memory should be 256 MB. Found ${memory_soft_limit} ."
5757 exit 1
5858 fi
59- memory_hard_limit=$( sudo cat /sys/fs/cgroup/memory/ nomad/$task_name /memory.limit_in_bytes )
59+ memory_hard_limit=$( sudo cat /sys/fs/cgroup/nomad.slice /$task_name /memory.max )
6060 if [ $memory_hard_limit != " $(( 512 * 1024 * 1024 )) " ]; then
6161 echo " ERROR: memory_max should be 512 MB. Found ${memory_hard_limit} ."
6262 exit 1
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ test_signal_handler_nomad_job() {
3232 alloc_id=$( nomad job status signal| awk ' END{print}' | cut -d ' ' -f 1)
3333 local outfile=$( mktemp /tmp/signal.XXXXXX)
3434 nomad alloc signal -s INVALID $alloc_id >> $outfile 2>&1
35- if ! grep -q " Invalid signal" $outfile ; then
35+ if ! grep -q " invalid signal" $outfile ; then
3636 echo " ERROR: Invalid signal didn't error out."
3737 cleanup " $outfile "
3838 exit 1
Original file line number Diff line number Diff line change @@ -7,10 +7,13 @@ job_name=privileged-not-allowed
77test_allow_privileged () {
88 pushd ~ /go/src/github.com/hashistack4u/nomad-driver-containerd/example
99
10+ sudo systemctl stop nomad
11+ sleep 10s
1012 cp agent.hcl agent.hcl.bkp
1113
12- sed -i ' 9 i \ allow_privileged = false' agent.hcl
13- sudo systemctl restart nomad
14+ sed -i -e ' s/allow_privileged = true/allow_privileged = false/' agent.hcl
15+ sudo systemctl start nomad
16+ sleep 10s
1417 is_systemd_service_active " nomad.service" true
1518
1619 echo " INFO: Starting nomad ${job_name} job using nomad-driver-containerd."
@@ -21,7 +24,7 @@ test_allow_privileged() {
2124 echo " INFO: Checking status of ${job_name} job."
2225 alloc_id=$( nomad job status ${job_name} | grep failed| awk ' NR==1' | cut -d ' ' -f 1)
2326 output=$( nomad alloc status $alloc_id )
24- echo -e " $output " | grep " Running privileged jobs are not allowed" & > /dev/null
27+ echo -e " $output " | grep " running privileged jobs are not allowed" & > /dev/null
2528 if [ $? -ne 0 ]; then
2629 echo " ERROR: ${job_name} should have failed to run."
2730 return 1
Original file line number Diff line number Diff line change 22
33set -eo pipefail
44
5- export NOMAD_VERSION=1.9.5
5+ export NOMAD_VERSION=1.9.6
66export CONTAINERD_VERSION=1.7.25
7+ export RUNC_VERSION=1.2.4
78export PATH=$PATH :/usr/local/go/bin
89export PATH=$PATH :/usr/local/bin
910if [ -e /home/runner ]; then
@@ -89,6 +90,11 @@ setup() {
8990 sudo tar -C /usr/local -xzf containerd-${CONTAINERD_VERSION} -linux-amd64.tar.gz
9091 rm -f containerd-${CONTAINERD_VERSION} -linux-amd64.tar.gz
9192
93+ # Install runc
94+ curl -L -o runc https://github.com/opencontainers/runc/releases/download/v${RUNC_VERSION} /runc.amd64
95+ chmod 0755 runc
96+ sudo mv runc /usr/local/bin/
97+
9298 # Drop containerd systemd unit file into /lib/systemd/system.
9399 cat << EOF > containerd.service
94100# /lib/systemd/system/containerd.service
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ is_container_active() {
2626 i=" 0"
2727 while test $i -lt 5
2828 do
29- sudo CONTAINERD_NAMESPACE=nomad ctr task ls| grep -q RUNNING
29+ sudo CONTAINERD_NAMESPACE=nomad.slice ctr task ls| grep -q RUNNING
3030 if [ $? -eq 0 ]; then
3131 echo " INFO: ${job_name} container is up and running"
3232 if [ " $is_sleep " = true ]; then
You can’t perform that action at this time.
0 commit comments