From 0161c3ecd112fc9b86eb14e91e1eaee14fb2523e Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Fri, 2 Oct 2026 16:28:33 -0300 Subject: [PATCH] fix(xcat-core): nic_cfg.sh backup fails on a node with no network configuration "nic_cfg.sh backup" returns 1 on a node that has just netbooted, so confignetwork_static_installnic fails on its third command before it configures anything. The identical call seven seconds later returns 0, once confignetwork has created the directory. The backup arm ended in a cp over the backend's configuration directory, so the script exited with that cp's status. A diskless Ubuntu node has no /etc/network/interfaces.d until confignetwork writes one, the cp failed, and the caller read "nothing to back up" as a failure. Copy only when the source directory exists. A cp that fails with the directory present still returns non-zero, and so does a backup that cannot create its own directory. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> (cherry picked from commit 3a682a130dffe2406a5048174e174ee693133cc4) --- xCAT-test/autotest/testcase/commoncmd/nic_cfg.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/xCAT-test/autotest/testcase/commoncmd/nic_cfg.sh b/xCAT-test/autotest/testcase/commoncmd/nic_cfg.sh index 2b09e00d46..cb1d10fe42 100755 --- a/xCAT-test/autotest/testcase/commoncmd/nic_cfg.sh +++ b/xCAT-test/autotest/testcase/commoncmd/nic_cfg.sh @@ -181,12 +181,15 @@ case "$1" in esac ;; backup) - be=$(detect_backend); rm -rf "$BACKUP"; mkdir -p "$BACKUP" + # A source directory that does not exist holds no configuration to snapshot, which is + # the state of a node that has just netbooted. Report success: the exit status of a cp + # over an absent directory made the caller read "nothing to back up" as a failure. + be=$(detect_backend); rm -rf "$BACKUP"; mkdir -p "$BACKUP" || exit 1 case "$be" in - nm) cp -af "$NMDIR"/. "$BACKUP"/ 2>/dev/null ;; - suse) cp -af "$SUSEDIR"/ifcfg-* "$BACKUP"/ 2>/dev/null ;; - rh) cp -af "$RHDIR" "$BACKUP"/ 2>/dev/null ;; - ubuntu) cp -af "$UBUDIR"/. "$BACKUP"/ 2>/dev/null ;; + nm) if [ -d "$NMDIR" ]; then cp -af "$NMDIR"/. "$BACKUP"/ 2>/dev/null; fi ;; + suse) if [ -d "$SUSEDIR" ]; then cp -af "$SUSEDIR"/ifcfg-* "$BACKUP"/ 2>/dev/null || :; fi ;; + rh) if [ -d "$RHDIR" ]; then cp -af "$RHDIR" "$BACKUP"/ 2>/dev/null; fi ;; + ubuntu) if [ -d "$UBUDIR" ]; then cp -af "$UBUDIR"/. "$BACKUP"/ 2>/dev/null; fi ;; esac ;; restore)