Skip to content

Commit efb45d9

Browse files
committed
Cleanup and workaround docker bug
Cleanup unused items and add workaround when docker get stuck due orphaned (not really) network. Signed-off-by: Denys Fedoryshchenko <[email protected]>
1 parent 942da0b commit efb45d9

File tree

1 file changed

+10
-192
lines changed

1 file changed

+10
-192
lines changed

staging.kernelci.org

Lines changed: 10 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -44,43 +44,6 @@ cmd_pull() {
4444
git pull --ff-only
4545
}
4646

47-
cmd_jenkins() {
48-
echo "Updating Jenkins jobs"
49-
./pending.py kernelci-jenkins --push
50-
51-
[ -d checkout/kernelci-jenkins/data ] || {
52-
# To set this up:
53-
# git clone https://github.com/kernelci/kernelci-jenkins-data.git data
54-
# cd data; git-crypt unlock
55-
# cd ..; ln -s data/bot.staging.kernelci.org/env .env
56-
57-
echo "Encrypted kernelci-jenkins-data repository not set up"
58-
return 1
59-
}
60-
61-
echo "Updating encrypted data checkout"
62-
topdir=$(pwd)
63-
cd checkout/kernelci-jenkins/data
64-
git prune
65-
git remote update origin
66-
data_diff=$(git diff origin/main)
67-
if [ -n "$data_diff" ]; then
68-
git checkout origin/main
69-
cd "$topdir/checkout/kernelci-jenkins"
70-
echo "Recreating Jenkins container"
71-
docker-compose down
72-
docker-compose up --build -d
73-
sleep 60 # magic - another way to do this would be to poll something
74-
else
75-
cd "$topdir/checkout/kernelci-jenkins"
76-
# ToDo: restart the container but only when there were some changes in
77-
# kernelci-jenkins to avoid aborting running jobs unnecessarily
78-
fi
79-
cd "$topdir"
80-
81-
echo "Triggering Jenkins seed job"
82-
python3 job.py --no-params trigger job-dsl
83-
}
8447

8548
cmd_core() {
8649
echo "Updating kernelci-core"
@@ -113,46 +76,6 @@ cmd_test_definitions() {
11376
./pending.py iec-security --push --main=master
11477
}
11578

116-
cmd_kcidb() {
117-
echo "Updating KCIDB"
118-
./pending.py kcidb --push
119-
}
120-
121-
cmd_backend() {
122-
opt="$1"
123-
124-
echo "Checking for missing indexes by finding COLLSCAN events"
125-
echo "db.system.profile.aggregate([{\$match: {ns: {\$in: ['kernel-ci.test_case', 'kernel-ci.test_group', 'kernel-ci.test_regression', 'kernel-ci.build']}, planSummary: 'COLLSCAN'}}, {\$group: {_id: {ns: '\$ns', planSummary: '\$planSummary'}}}])" | mongo kernel-ci
126-
127-
if [ "$opt" = "indexes" ]; then
128-
echo "Dropping Mongo DB indexes"
129-
echo "db.test_case.dropIndexes(); db.test_group.dropIndexes(); db.test_regression.dropIndexes(); db.build.dropIndexes();" | mongo kernel-ci
130-
fi
131-
132-
echo "Updating kernelci-backend"
133-
134-
if ./pending.py kernelci-backend --diff-only; then
135-
./pending.py kernelci-backend --push
136-
./ansible kernelci-backend api.staging.kernelci.org
137-
else
138-
echo "No changes, skipping Ansible"
139-
fi
140-
141-
echo "Resetting and enabling the Mongo DB profiler"
142-
echo "db.setProfilingLevel(0); db.system.profile.drop(); db.setProfilingLevel(2);" | mongo kernel-ci
143-
}
144-
145-
cmd_frontend() {
146-
echo "Updating kernelci-frontend"
147-
148-
if ./pending.py kernelci-frontend --diff-only; then
149-
./pending.py kernelci-frontend --push
150-
./ansible kernelci-frontend staging.kernelci.org
151-
else
152-
echo "No changes, skipping Ansible"
153-
fi
154-
}
155-
15679
cmd_kernel() {
15780
tree="${1:-next}"
15881

@@ -194,121 +117,6 @@ cmd_kernel() {
194117
--tag-prefix=staging-"$tree"-
195118
}
196119

197-
cmd_docker() {
198-
echo "Updating Docker images"
199-
200-
# Build without cache if flag file doesn't exist or older than x days
201-
purge_flag_file=".last_docker_purge"
202-
rust_flag_file=".build_rust"
203-
if [ -f "$purge_flag_file" ]; then
204-
flag_time=$(date -r "$purge_flag_file" +%s)
205-
week_ago=$(date -d 'now - 7 days' +%s)
206-
fi
207-
if [ ! -f "$purge_flag_file" ] || [ $flag_time -le $week_ago ]; then
208-
echo "Building without cache"
209-
cache_arg="--no-cache"
210-
touch "$purge_flag_file"
211-
else
212-
cache_arg=""
213-
fi
214-
215-
# Get API revision to tag the image
216-
cd checkout/kernelci-api
217-
api_rev=$(git show --pretty=format:%H -s origin/staging.kernelci.org)
218-
cd -
219-
220-
# Get pipeline revision to tag the image
221-
cd checkout/kernelci-pipeline
222-
pipeline_rev=$(git show --pretty=format:%H -s origin/staging.kernelci.org)
223-
cd -
224-
225-
# Build the images with kci docker
226-
cd checkout/kernelci-core
227-
git prune
228-
229-
core_rev=$(git show --pretty=format:%H -s origin/staging.kernelci.org)
230-
rev_arg="--build-arg core_rev=$core_rev --build-arg api_rev=$api_rev --build-arg pipeline_rev=$pipeline_rev"
231-
px_arg='--prefix=kernelci/staging-'
232-
args="build --push $px_arg $cache_arg $rev_arg"
233-
234-
# KernelCI tools
235-
./kci docker $args kernelci
236-
./kci docker $args k8s kernelci
237-
238-
./kci docker $args kernelci api --version="$api_rev"
239-
# TODO - add this functionality to kci docker
240-
docker tag kernelci/staging-kernelci:api-$api_rev kernelci/staging-kernelci:api
241-
docker push kernelci/staging-kernelci:api
242-
243-
./kci docker $args kernelci pipeline --version="$pipeline_rev"
244-
# TODO - add this functionality to kci docker
245-
docker tag kernelci/staging-kernelci:pipeline-$pipeline_rev kernelci/staging-kernelci:pipeline
246-
docker push kernelci/staging-kernelci:pipeline
247-
248-
./kci docker $args kernelci lava-callback --version="$pipeline_rev"
249-
# lava-callback fragment
250-
docker tag kernelci/staging-kernelci:lava-callback-$pipeline_rev kernelci/staging-kernelci:lava-callback
251-
docker push kernelci/staging-kernelci:lava-callback
252-
253-
# Compiler toolchains
254-
255-
# clang-17 for linux-next (including weekly full build)
256-
./kci docker $args clang-17 kselftest kernelci
257-
for arch in arm arm64 mips riscv64 x86; do
258-
./kci docker $args clang-17 kselftest kernelci --arch $arch
259-
# temporary push to ghcr.io to solve docker hub limits
260-
docker tag kernelci/staging-clang-17:$arch-kselftest-kernelci ghcr.io/kernelci/staging-clang-17:$arch-kselftest-kernelci
261-
docker push ghcr.io/kernelci/staging-clang-17:$arch-kselftest-kernelci
262-
done
263-
# clang-15 for chromeos
264-
./kci docker $args clang-15 kselftest kernelci
265-
for arch in arm64 x86; do
266-
./kci docker $args clang-15 kselftest kernelci --arch $arch
267-
done
268-
# gcc-12 for everything (including weekly linux-next full build)
269-
for arch in arc arm armv5 arm64 mips riscv64 x86; do
270-
./kci docker $args gcc-12 kselftest kernelci --arch $arch
271-
# temporary push to ghcr.io to solve docker hub limits
272-
docker tag kernelci/staging-gcc-12:$arch-kselftest-kernelci ghcr.io/kernelci/staging-gcc-12:$arch-kselftest-kernelci
273-
docker push ghcr.io/kernelci/staging-gcc-12:$arch-kselftest-kernelci
274-
done
275-
# missing -dev packages for sparc64
276-
./kci docker $args gcc-12 kernelci --arch sparc
277-
# only x86 is useful for KUnit (for now)
278-
./kci docker $args gcc-12 kunit kernelci --arch x86
279-
# additional images for Rust
280-
if [ -f "$rust_flag_file" ]; then
281-
for rustc in rustc-1.74 rustc-1.75; do
282-
./kci docker $args $rustc kselftest kernelci
283-
for arch in x86; do
284-
./kci docker $args $rustc kselftest kernelci --arch $arch
285-
done
286-
done
287-
echo "Rust images not built, please touch .build_rust file to build them"
288-
fi
289-
290-
# rootfs
291-
./kci docker $args buildroot kernelci
292-
./kci docker $args debos kernelci
293-
294-
# QEMU
295-
./kci docker $args qemu
296-
297-
# Other tools
298-
./kci docker $args cvehound kernelci
299-
./kci docker $args dt-validation # kernelci (PyYAML conflict)
300-
cd -
301-
}
302-
303-
cmd_monitor() {
304-
echo "Triggering Jenkins kernel-tree-monitor job"
305-
python3 \
306-
job.py \
307-
--json=data/staging-monitor.json \
308-
trigger \
309-
kernel-tree-monitor
310-
}
311-
312120
cmd_rotate_tree() {
313121
if [ -e .tree ]; then
314122
last=$(cat .tree)
@@ -351,6 +159,16 @@ cmd_api_pipeline() {
351159
echo "Pulling pipeline containers"
352160
docker-compose $compose_files pull
353161
docker-compose $compose_files down --remove-orphans
162+
# verify if it failed due orphaned network bug
163+
if [ $? -ne 0 ]; then
164+
echo "Failed to stop pipeline containers, restarting containerd and docker"
165+
sudo systemctl restart containerd docker
166+
echo "Waiting 5 seconds for services to restart"
167+
sleep 5
168+
~/run-dozzle
169+
echo "Attempting to restart pipeline containers again"
170+
docker-compose $compose_files down --remove-orphans
171+
fi
354172
cd -
355173

356174
#./pending.py kernelci-api --push

0 commit comments

Comments
 (0)