From 0f12faa0fc7d4532a2308f04c0fbefca9a7621fe Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Fri, 28 Aug 2026 09:45:56 -0300 Subject: [PATCH] fix(xcat-core): do not add a second syncfiles when the node already defers it A node may list syncfiles in both postscripts and postbootscripts -- once for the install and once for the booted node. The deferral prepended its own copy regardless, so the booted node ran syncfiles twice in a row inside a marker block that made it look like xCAT had generated the duplicate. Keep the entry the node already has and still remove the install-time one, which is the copy that cannot work in the in-target chroot. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-server/lib/perl/xCAT/Postage.pm | 5 +++++ xCAT-test/unit/postage_ubuntu_syncfiles_postboot.t | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/xCAT-server/lib/perl/xCAT/Postage.pm b/xCAT-server/lib/perl/xCAT/Postage.pm index 5fda1acfd..6da8b3277 100644 --- a/xCAT-server/lib/perl/xCAT/Postage.pm +++ b/xCAT-server/lib/perl/xCAT/Postage.pm @@ -214,6 +214,11 @@ sub defer_syncfiles_to_postboot { unless defined($postscripts) && $postscripts =~ s/^[ \t]*syncfiles[ \t]*\n//m; $postbootscripts = "" unless defined $postbootscripts; + + # A node may already list syncfiles as a postbootscript of its own; do not add a second copy. + return ($postscripts, $postbootscripts) + if $postbootscripts =~ /^[ \t]*syncfiles[ \t]*$/m; + $postbootscripts = "# ubuntu-deferred-postbootscripts-start-here\nsyncfiles\n# ubuntu-deferred-postbootscripts-end-here\n" . $postbootscripts; diff --git a/xCAT-test/unit/postage_ubuntu_syncfiles_postboot.t b/xCAT-test/unit/postage_ubuntu_syncfiles_postboot.t index e0e935ffb..9962ea20c 100644 --- a/xCAT-test/unit/postage_ubuntu_syncfiles_postboot.t +++ b/xCAT-test/unit/postage_ubuntu_syncfiles_postboot.t @@ -83,6 +83,16 @@ foreach my $case (@untouched) { is($postboot, $DEFERRED, 'an undefined postbootscripts list becomes the deferral block'); } +# A node that already lists syncfiles as its own postbootscript keeps that entry, and does not +# gain a second one -- the install-time copy is still removed, since that is the one that cannot work. +{ + my ($post, $postboot) = + defer('ubuntu24.04', 'install', 'install', "syncfiles\nfoo\n", "syncfiles\nsetupntp\n"); + is($post, "foo\n", 'the postscripts entry is still removed'); + is($postboot, "syncfiles\nsetupntp\n", + "an admin's own syncfiles postbootscript is left as it was, not duplicated"); +} + # Rendering the same node twice must not stack a second copy. { my ($post, $postboot) =