From 993fedb1b1f7f9469a8de868556b56877b09768d Mon Sep 17 00:00:00 2001 From: suvendhu Date: Fri, 28 Apr 2023 13:20:51 +0530 Subject: [PATCH] swmodd: added timeout to pull container image from registry --- swmodd/Makefile | 4 ++-- swmodd/files/etc/init.d/crun | 6 ++++-- swmodd/files/etc/swmodd/run.sh | 10 ++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/swmodd/Makefile b/swmodd/Makefile index f3f7c421c..a85f2729a 100755 --- a/swmodd/Makefile +++ b/swmodd/Makefile @@ -5,13 +5,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=swmodd -PKG_VERSION:=2.2.2 +PKG_VERSION:=2.2.3 LOCAL_DEV:=0 ifneq ($(LOCAL_DEV),1) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://dev.iopsys.eu/lcm/swmodd.git -PKG_SOURCE_VERSION:=db0805d7833a27afc9a42edd094209978f43e311 +PKG_SOURCE_VERSION:=4a1bd7087e2e357d52820ad330c2829add215841 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_MIRROR_HASH:=skip endif diff --git a/swmodd/files/etc/init.d/crun b/swmodd/files/etc/init.d/crun index 976c58745..cfd77ec2f 100644 --- a/swmodd/files/etc/init.d/crun +++ b/swmodd/files/etc/init.d/crun @@ -22,6 +22,7 @@ configure_crun_container() { BUNDLE="${2}" BRIDGE="${3}" BOOT="${4}" + TIMEOUT="${5}" config_get name "${1}" name "" config_get type "${1}" type "" @@ -46,7 +47,7 @@ configure_crun_container() { uci_set ocicontainer "${1}" du_status Installing_start uci_set ocicontainer "${1}" username "" uci_set ocicontainer "${1}" password "" - result=$(${RUNNER} -b "${BUNDLE}" -n "${name}" -r "${url}" -l "${username}:${password}") + result=$(${RUNNER} -b "${BUNDLE}" -n "${name}" -r "${url}" -l "${username}:${password}" -t "${TIMEOUT}") if [ "$?" -eq 0 ]; then result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_description") if [ "${result}" != "null" ]; then @@ -190,6 +191,7 @@ start_service() { config_load swmodd config_get bundle globals oci_bundle_root "" config_get bridge globals lan_bridge "br-lan" + config_get timeout globals oci_pull_timeout "10" if [ -z "${bundle}" ] || [ -z "${bridge}" ]; then log "Empty bundle path or bridge" @@ -199,7 +201,7 @@ start_service() { if [ -f "${bundle}/ocicontainer" ]; then UCI_CONFIG_DIR="${bundle}" config_load ocicontainer - config_foreach configure_crun_container du_eu_assoc "${bundle}" "${bridge}" "${boot}" + config_foreach configure_crun_container du_eu_assoc "${bundle}" "${bridge}" "${boot}" "${timeout}" uci_commit ocicontainer # Add a timer for DuStateChange! diff --git a/swmodd/files/etc/swmodd/run.sh b/swmodd/files/etc/swmodd/run.sh index 879e30999..a0fa4b4c3 100644 --- a/swmodd/files/etc/swmodd/run.sh +++ b/swmodd/files/etc/swmodd/run.sh @@ -164,14 +164,15 @@ pull_image_from_registry() { OPTS="--src-creds ${LOGIN}" INSPECT_OPT="--creds ${LOGIN}" fi - if ! skopeo --command-timeout 4m copy ${OPTS} ${REGURL} oci:${NAME}_tmp:latest >/dev/null 2>&1; then - log "Failed to download image" + + if ! skopeo --command-timeout ${TIMEOUT:-10}m copy ${OPTS} ${REGURL} oci:${NAME}_tmp:latest >/dev/null 2>&1; then + log "Failed to download image: $?" cd - rm -rf "${temp}" exit 1 fi if ! umoci unpack --image ${NAME}_tmp:latest ${NAME} >/dev/null 2>&1; then - log "Failed to unpack image" + log "Failed to unpack image: $?" cd - rm -rf "${temp}" exit 1 @@ -211,7 +212,7 @@ pull_image_from_registry() { clean=0 net_update=0 update_json=0 -while getopts b:n:i:r:l:cuU options +while getopts b:n:i:r:l:t:cuU options do case "${options}" in b) BUNDLE=${OPTARG};; @@ -219,6 +220,7 @@ do i) BRIDGE=${OPTARG};; r) REGURL=${OPTARG};; l) LOGIN=${OPTARG};; + t) TIMEOUT=${OPTARG};; c) clean=1;; u) net_update=1;; U) update_json=1;;