From 4b73175670c4595914bbc267c7a6808b2c1e15d5 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Tue, 29 Sep 2026 18:19:32 -0300 Subject: [PATCH] fix(xcat-core): nodepurge leaves the autoinstall directory of an Ubuntu node After nodepurge removes a Subiquity node, /install/autoinst/ is still on disk with meta-data, user-data and vendor-data in it. user-data carries the root password hash of a node that no longer exists. remove_node_config_files removed each path with unlink. unlink cannot remove a directory, and mkinstall in debian.pm calls mkpath for a Subiquity node, so the node configuration is a directory there and a plain file on the preseed and kickstart paths. The routine now removes a directory with rmtree. nodepurge_autoinst_cleanup.t fails without this change and passes with it. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- perl-xCAT/xCAT/ProfiledNodeUtils.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/ProfiledNodeUtils.pm b/perl-xCAT/xCAT/ProfiledNodeUtils.pm index 5926cab22..9b063e776 100644 --- a/perl-xCAT/xCAT/ProfiledNodeUtils.pm +++ b/perl-xCAT/xCAT/ProfiledNodeUtils.pm @@ -4,7 +4,7 @@ package xCAT::ProfiledNodeUtils; use strict; use warnings; use Socket; -use File::Path qw/mkpath/; +use File::Path qw/mkpath rmtree/; use File::Temp qw/tempfile/; use Fcntl qw(:flock); require xCAT::Table; @@ -1607,7 +1607,14 @@ sub remove_node_config_files { foreach my $suffix ("", ".pre", ".post") { my $path = "$config_dir/$one_node$suffix"; next unless (-e $path); - unlink $path; + + # mkinstall writes a directory here for a Subiquity node, with meta-data, + # user-data and vendor-data in it. unlink cannot remove a directory. + if (-d $path) { + rmtree($path); + } else { + unlink $path; + } } } }