Skip to content

Commit

Permalink
day1 cleanup after the action (#1055)
Browse files Browse the repository at this point in the history
pull-kernel-module-image.service runs twice: once to pull all the images
and reboot the node, and the second time it just checks that everyting
has been pulled and exits. During the second time we want to remove
the tar of the loaded and saved kernel module image, so that it won't
interfere with the correct flow once the node is rebooted again
  • Loading branch information
yevgeny-shnaidman authored Mar 19, 2024
1 parent fd5f70a commit 237f77c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/mcproducer/templates/pull-image.gotmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

if [ -e {{.LocalFilePath}} ]; then
echo "File {{.LocalFilePath}} found.Nothing to do"
echo "File {{.LocalFilePath}} found.Nothing to do, the file was handled, removing it"
rm -f {{.LocalFilePath}}
else
podman pull --authfile /var/lib/kubelet/config.json {{.WorkerImage}}
if [ $? -eq 0 ]; then
Expand Down
2 changes: 1 addition & 1 deletion pkg/mcproducer/testdata/machineconfig-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ spec:
user:
name: "root"
contents:
source: "data:text/plain;base64,IyEvYmluL2Jhc2gKCmlmIFsgLWUgL3Zhci9saWIvaW1hZ2VfZmlsZV9kYXkxLnRhciBdOyB0aGVuCiAgICBlY2hvICJGaWxlIC92YXIvbGliL2ltYWdlX2ZpbGVfZGF5MS50YXIgZm91bmQuTm90aGluZyB0byBkbyIKZWxzZQogICAgcG9kbWFuIHB1bGwgLS1hdXRoZmlsZSAvdmFyL2xpYi9rdWJlbGV0L2NvbmZpZy5qc29uIHF1YXkuaW8vZWRnZS1pbmZyYXN0cnVjdHVyZS9rZXJuZWwtbW9kdWxlLW1hbmFnZW1lbnQtd29ya2VyOmxhdGVzdAogICAgaWYgWyAkPyAtZXEgMCBdOyB0aGVuCiAgICAgICAgZWNobyAiSW1hZ2UgcXVheS5pby9lZGdlLWluZnJhc3RydWN0dXJlL2tlcm5lbC1tb2R1bGUtb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HJlYm9vdAogICAgZWxzZQogICAgICAgIGVjaG8gIkZhaWxlZCB0byBzYXZlIGltYWdlIHF1YXkuaW8vcHJvamVjdC9yZXBvOnNvbWUtdGFnMTIgdG8gZmlsZSAvdmFyL2xpYi9pbWFnZV9maWxlX2RheTEudGFyIgogICAgZmkKZmkK"
- path: "/etc/kmm-worker-day1/config.yaml"
mode: 420
overwrite: true
Expand Down
3 changes: 2 additions & 1 deletion pkg/mcproducer/testdata/pull-image-test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

if [ -e /var/lib/image_file_day1.tar ]; then
echo "File /var/lib/image_file_day1.tar found.Nothing to do"
echo "File /var/lib/image_file_day1.tar found.Nothing to do, the file was handled, removing it"
rm -f /var/lib/image_file_day1.tar
else
podman pull --authfile /var/lib/kubelet/config.json quay.io/edge-infrastructure/kernel-module-management-worker:latest
if [ $? -eq 0 ]; then
Expand Down

0 comments on commit 237f77c

Please sign in to comment.