swmodd: added timeout to pull container image from registry

This commit is contained in:
suvendhu 2023-04-28 13:20:51 +05:30
parent 7168b5f1e0
commit 993fedb1b1
3 changed files with 12 additions and 8 deletions

View file

@ -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

View file

@ -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!

View file

@ -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;;