Set up /var/run/sysinv_tmp as sysinv's default temp files location
sysinv call the k8s python client to perform a number of operations. The k8s python client creates temp files under /tmp and continues to use these tmp files for the life-cycle of the processes. However systemd-tmpfiles-clean.service will run every day to clean up files in /tmp dir that are older than 10 days. If the k8s client code is not triggered for more than 10 days (thus its temp files are not accessed for more than 10 days), these temp files will be removed as part of the cleanup. Certain sysinv operations then starts to fail with an error that the tmp file is no longer there. This is a known issue of kubernetes python client: https://github.com/kubernetes-client/python/issues/765 The commit fixes this issue by setting TMPDIR to /var/run/sysinv_tmp when sm starts sysinv-conductor and sysinv-inv. Change-Id: I8544272b2431607ed1041473c5da2eecb64635af Closes-Bug: 1883599 Signed-off-by: Andy Ning <andy.ning@windriver.com>
This commit is contained in:
parent
3a893d1586
commit
31533adf42
|
@ -56,6 +56,7 @@ OCF_RESKEY_client_binary_default="system"
|
|||
: ${OCF_RESKEY_client_binary=${OCF_RESKEY_client_binary_default}}
|
||||
|
||||
mydaemon="/usr/bin/${OCF_RESKEY_binary}"
|
||||
TMP_DIR=/var/run/sysinv_tmp
|
||||
|
||||
#######################################################################
|
||||
|
||||
|
@ -136,6 +137,22 @@ END
|
|||
return ${OCF_SUCCESS}
|
||||
}
|
||||
|
||||
sysinv_api_tmpdir () {
|
||||
local rc
|
||||
|
||||
if [ ! -d "$TMP_DIR" ]; then
|
||||
mkdir -p "$TMP_DIR"
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
ocf_log err "Inventory Service (${OCF_RESKEY_binary}) failed to create temp dir (rc=${rc})"
|
||||
return ${OCF_NOT_RUNNING}
|
||||
fi
|
||||
chown sysinv:sysinv "$TMP_DIR"
|
||||
fi
|
||||
export TMPDIR="$TMP_DIR"
|
||||
return ${OCF_SUCCESS}
|
||||
}
|
||||
|
||||
sysinv_api_validate() {
|
||||
|
||||
local rc
|
||||
|
@ -392,6 +409,10 @@ esac
|
|||
# Anything except meta-data and help must pass validation
|
||||
sysinv_api_validate || exit $?
|
||||
|
||||
# Set up tmpfiles directory to avoid temp files being
|
||||
# cleaned up by systemd tmpfiles clean service.
|
||||
sysinv_api_tmpdir || exit $?
|
||||
|
||||
if [ ${OCF_RESKEY_dbg} = "true" ] ; then
|
||||
ocf_log info "${binname}:${__OCF_ACTION} action"
|
||||
fi
|
||||
|
|
|
@ -40,6 +40,7 @@ OCF_RESKEY_config_default="/etc/sysinv/sysinv.conf"
|
|||
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
|
||||
|
||||
mydaemon="/usr/bin/${OCF_RESKEY_binary}"
|
||||
TMP_DIR="/var/run/sysinv_tmp"
|
||||
|
||||
#######################################################################
|
||||
|
||||
|
@ -111,6 +112,21 @@ END
|
|||
return ${OCF_SUCCESS}
|
||||
}
|
||||
|
||||
sysinv_conductor_tmpdir () {
|
||||
local rc
|
||||
if [ ! -d "$TMP_DIR" ]; then
|
||||
mkdir -p "$TMP_DIR"
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
ocf_log err "Inventory Service (${OCF_RESKEY_binary}) failed to create temp dir (rc=${rc})"
|
||||
return ${OCF_NOT_RUNNING}
|
||||
fi
|
||||
chown sysinv:sysinv "$TMP_DIR"
|
||||
fi
|
||||
export TMPDIR="$TMP_DIR"
|
||||
return ${OCF_SUCCESS}
|
||||
}
|
||||
|
||||
sysinv_conductor_validate() {
|
||||
|
||||
local rc
|
||||
|
@ -389,10 +405,15 @@ esac
|
|||
# Anything except meta-data and help must pass validation
|
||||
sysinv_conductor_validate || exit $?
|
||||
|
||||
# Set up tmpfiles directory to avoid temp files being
|
||||
# cleaned up by systemd tmpfiles clean service.
|
||||
sysinv_conductor_tmpdir || exit $?
|
||||
|
||||
if [ ${OCF_RESKEY_dbg} = "true" ] ; then
|
||||
ocf_log info "${binname}:${__OCF_ACTION} action"
|
||||
fi
|
||||
|
||||
|
||||
case ${__OCF_ACTION} in
|
||||
|
||||
start) sysinv_conductor_start
|
||||
|
|
Loading…
Reference in New Issue