Skip to content

Commit c90db02

Browse files
committed
Make CI working with latest Nomad version
1 parent 0edd906 commit c90db02

File tree

8 files changed

+29
-9
lines changed

8 files changed

+29
-9
lines changed

.github/workflows/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
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

Vagrantfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

example/agent.hcl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
log_level = "INFO"
22
data_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+
410
plugin "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
}

tests/001-test-redis.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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

tests/002-test-signal-handler.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

tests/011-test-allow-privileged.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ job_name=privileged-not-allowed
77
test_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."

tests/run_tests.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
set -eo pipefail
44

5-
export NOMAD_VERSION=1.9.5
5+
export NOMAD_VERSION=1.9.6
66
export CONTAINERD_VERSION=1.7.25
7+
export RUNC_VERSION=1.2.4
78
export PATH=$PATH:/usr/local/go/bin
89
export PATH=$PATH:/usr/local/bin
910
if [ -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

tests/utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)