From 73ebe96f72482e2a39be5b54917f1cd65876979f Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Tue, 1 Sep 2026 21:48:54 -0300 Subject: [PATCH] fix(postage): the provmethod override in makescript can never fire The syncfiles deferral resolved the node's provmethod through $image_hash{$osimgname}{provmethod} when the node names an osimage. makescript fills %image_hash from getImage(), which stores pkglist, pkgdir, otherpkglist, otherpkgdir and environvar -- and no provmethod. getScripts() has a separate hash that does store one, which is where the pattern was copied from. So the lookup was always undef, the override never fired, and the code claimed a behaviour it did not have. Pass $provmethod directly and say in the comment why there is nothing to resolve it with. No behaviour changes -- the branch was inert -- so there is no red to show first; what the deletion needs is coverage that the path it was supposed to serve still works. That is what the two new assertions do: an osimage-named provmethod with nodesetstate 'install' still defers, and the same name with no nodesetstate is not mistaken for a diskful install. nodesetstate is what carries the install signal here, which is why the override was never load-bearing. Making the deferral ignore nodesetstate and require provmethod eq 'install' reddens both. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-server/lib/perl/xCAT/Postage.pm | 13 ++++++----- .../unit/postage_ubuntu_syncfiles_postboot.t | 22 +++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Postage.pm b/xCAT-server/lib/perl/xCAT/Postage.pm index 6da8b3277..c575304cd 100644 --- a/xCAT-server/lib/perl/xCAT/Postage.pm +++ b/xCAT-server/lib/perl/xCAT/Postage.pm @@ -601,12 +601,15 @@ sub makescript { # See defer_syncfiles_to_postboot(): on the Ubuntu/Debian diskful install path syncfiles # has to run on the booted node, not in the installer's in-target chroot. - my $effective_provmethod = $provmethod; - if ($osimgname && defined($image_hash{$osimgname}{'provmethod'})) { - $effective_provmethod = $image_hash{$osimgname}{'provmethod'}; - } + # + # $provmethod is passed as-is. An earlier version tried to resolve it through + # $image_hash{$osimgname}{provmethod} when the node names an osimage, but makescript + # fills %image_hash from getImage(), which stores pkglist/pkgdir/otherpkg*/environvar and + # no provmethod -- getScripts() has a separate hash that does. So that lookup was always + # undef and the override never fired. $nodesetstate is what carries the install signal on + # this path anyway: nodeset sets it, and defer_syncfiles_to_postboot checks it first. ($postscripts, $postbootscripts) = defer_syncfiles_to_postboot( - $os, $effective_provmethod, $nodesetstate, $postscripts, $postbootscripts); + $os, $provmethod, $nodesetstate, $postscripts, $postbootscripts); # if using zones then must go to the zone.sshbetweennodes # else go to site.sshbetweennodes diff --git a/xCAT-test/unit/postage_ubuntu_syncfiles_postboot.t b/xCAT-test/unit/postage_ubuntu_syncfiles_postboot.t index 9962ea20c..7603c97aa 100644 --- a/xCAT-test/unit/postage_ubuntu_syncfiles_postboot.t +++ b/xCAT-test/unit/postage_ubuntu_syncfiles_postboot.t @@ -102,4 +102,26 @@ foreach my $case (@untouched) { is($postboot2, $postboot, 'a second pass does not duplicate syncfiles'); } +# The node's provmethod is frequently an osimage NAME rather than the literal 'install' -- that +# is what makescript passes, and resolving it to a real provmethod is not possible there +# (getImage does not store one). nodesetstate is what carries the install signal on that path, +# so the deferral must key off it and not require provmethod to say 'install'. +{ + my ($post, $postboot) = defer( + 'ubuntu24.04', 'ubuntu24.04-x86_64-install-compute', 'install', + "otherpkgs\nsyncfiles\nremoteshell\n", "" ); + unlike( $post, qr/^syncfiles$/m, + 'an osimage-named provmethod still defers when nodesetstate says install' ); + like( $postboot, qr/^syncfiles$/m, + 'and syncfiles lands in the postboot scripts' ); +} + +{ + my ($post, $postboot) = defer( + 'ubuntu24.04', 'ubuntu24.04-x86_64-install-compute', undef, + "otherpkgs\nsyncfiles\nremoteshell\n", "" ); + like( $post, qr/^syncfiles$/m, + 'with no nodesetstate an osimage name is not mistaken for a diskful install' ); +} + done_testing();