From cc599dab15ed5c8761b3bcdfb113403fa6d4bc77 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Sun, 5 Jul 2020 10:25:36 +0200 Subject: [PATCH] [type/__uci_commit] Move uncommited changes check from explorer to code-remote This is done to prevent false positives/negatives (see NOTE in code) --- cdist/conf/type/__uci_commit/explorer/changes | 22 ------------------- cdist/conf/type/__uci_commit/gencode-remote | 21 +++++++++++++----- 2 files changed, 15 insertions(+), 28 deletions(-) delete mode 100644 cdist/conf/type/__uci_commit/explorer/changes diff --git a/cdist/conf/type/__uci_commit/explorer/changes b/cdist/conf/type/__uci_commit/explorer/changes deleted file mode 100644 index 2690def7..00000000 --- a/cdist/conf/type/__uci_commit/explorer/changes +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -# -# 2020 Dennis Camera (dennis.camera at ssrq-sds-fds.ch) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# This explorer outputs the uncommited UCI changes on the target. - -uci changes diff --git a/cdist/conf/type/__uci_commit/gencode-remote b/cdist/conf/type/__uci_commit/gencode-remote index dd1d839c..504f7c3b 100755 --- a/cdist/conf/type/__uci_commit/gencode-remote +++ b/cdist/conf/type/__uci_commit/gencode-remote @@ -23,19 +23,28 @@ batchfile="${__global:?}/tmp/__uci/${transaction_name}.txt" test -s "${batchfile}" || exit 0 -if test -s "${__object:?}/explorer/changes" +printf 'commit transaction %s\n' "${transaction_name}" >>"${__messages_out:?}" + +# NOTE: Uncommited changes are checked in code-remote instead of in an explorer +# because in cdist there is no interlocking between explorers and code +# execution. +# Checking for uncommited changes in an explorer leaves a time slot in +# which changes made are not detected by the code. +# Furthermore an explorer running concurrently with another transactions +# code-remote could lead to a false positive. + +cat <&2 -printf 'commit transaction %s\n' "${transaction_name}" >>"${__messages_out:?}" - -cat <