Skip to content

Commit 43e6a9f

Browse files
committed
Set up /var/run/nfv-vim as vim's default temp files location
nfv vim call the k8s python client to perform a number of operations. The k8s python client creates temp files under /tmp and continues 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 vim 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: kubernetes-client/python#765 The commit fixes this issue by setting TMPDIR to /var/run/nfv-vim when sm starts vim. Change-Id: I4f0544055e9d10ba2374e9fdb5133d767c1fa2c3 Closes-Bug: 1883599 Signed-off-by: Andy Ning <[email protected]>
1 parent 4c36f91 commit 43e6a9f

File tree

1 file changed

+20
-0
lines changed
  • nfv/nfv-vim/scripts

1 file changed

+20
-0
lines changed

nfv/nfv-vim/scripts/vim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ OCF_RESKEY_pid_default="/var/run/${binname}.pid"
3535
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
3636

3737
mydaemon="/usr/bin/${OCF_RESKEY_binary}"
38+
TMP_DIR=/var/run/nfv-vim
3839

3940
#######################################################################
4041

@@ -98,6 +99,21 @@ END
9899

99100
PROCESS_NOT_RUNNING_FILE="/var/run/.nfv-vim.not_running"
100101

102+
nfv_vim_tmpdir () {
103+
local rc
104+
105+
if [ ! -d "$TMP_DIR" ]; then
106+
mkdir -p "$TMP_DIR"
107+
rc=$?
108+
if [ $rc -ne 0 ]; then
109+
ocf_log err "NFV Service (${OCF_RESKEY_binary}) failed to create temp dir (rc=${rc})"
110+
return ${OCF_ERR_GENERIC}
111+
fi
112+
fi
113+
export TMPDIR="$TMP_DIR"
114+
return ${OCF_SUCCESS}
115+
}
116+
101117
vim_validate() {
102118
check_binary ${OCF_RESKEY_binary}
103119
check_binary pidof
@@ -297,6 +313,10 @@ esac
297313
# Anything except meta-data and help must pass validation
298314
vim_validate || exit $?
299315

316+
# Set up tmpfiles directory to avoid temp files being
317+
# cleaned up by systemd tmpfiles clean service.
318+
nfv_vim_tmpdir || exit $?
319+
300320
case ${__OCF_ACTION} in
301321

302322
start) vim_start

0 commit comments

Comments
 (0)