From 7ad7293b71cdc5706c4e19947a4e0a62d1f5bb7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Mon, 17 Aug 2026 16:30:31 -0300 Subject: [PATCH 1/2] fix(xcatd): only call a same-release build difference a build difference xcatd warns "xCAT Version mismatch!" when a node's xCAT version differs from the server's. It compared the full version strings, which include a build-specific suffix such as " (git commit )". Two nodes at the same release built from different snapshots then reported a version mismatch on every request, even though the same release is ABI compatible. Keep warning when the versions differ, but tell the two cases apart. A different release is still "xCAT Version mismatch!". The same release built from a different commit now reports "xCAT build level differs (same release):" instead, so the build difference is still visible without being called a mismatch. Both messages show the full version strings. Add xCAT::Version->Release, which returns the version without the build-specific suffix, to make that distinction. This was recovered from the lenovobuild branch, which stripped the older "built " suffix and dropped the same-release warning entirely; this reimplements it for the current version format and keeps the build difference visible. --- perl-xCAT/xCAT/Version.pm | 30 ++++++++++++++++++++++++++++++ xCAT-server/sbin/xcatd | 8 ++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/Version.pm b/perl-xCAT/xCAT/Version.pm index 086799bde..1aa35869c 100644 --- a/perl-xCAT/xCAT/Version.pm +++ b/perl-xCAT/xCAT/Version.pm @@ -54,4 +54,34 @@ sub Version } +#------------------------------------------------------------------------------- + +=head3 Release + Arguments: + Optional version string; defaults to Version(); + Returns: + the release part of the version, without the build-specific + decoration the build stamps on, such as " (git commit )", + so two nodes at the same release built from different snapshots + compare equal. + Globals: + none + Error: + none + Example: + $release=xCAT::Version->Release($someversion); + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub Release +{ + my $class = shift; + my $version = shift; + $version = $class->Version() unless defined $version; + $version =~ s/\s*\(.*//s; + return $version; +} + 1; diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index d1e27025d..fc1047033 100755 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -2945,9 +2945,13 @@ sub service_connection { #if the 2 versions are different, a warning message is included in the response if($req->{'_xcatver'} and $req->{'_xcatver'}->[0]){ my $myxcatver=xCAT::Version->Version(); - if($req->{'_xcatver'}->[0] ne $myxcatver){ + my $peerxcatver=$req->{'_xcatver'}->[0]; + if($peerxcatver ne $myxcatver){ my $myhostname=Sys::Hostname::hostname; - my $resp = { warning => ["xCAT Version mismatch! \n $myhostname: $myxcatver\n $peerhost: $req->{'_xcatver'}->[0]\n"]}; + my $label = (xCAT::Version->Release($peerxcatver) ne xCAT::Version->Release($myxcatver)) + ? "xCAT Version mismatch!" + : "xCAT build level differs (same release):"; + my $resp = { warning => ["$label \n $myhostname: $myxcatver\n $peerhost: $peerxcatver\n"]}; send_response($resp, $sock); } } From a1aa237c6461f191ef847a0c54bcf7190b7e7204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Mon, 17 Aug 2026 16:30:32 -0300 Subject: [PATCH 2/2] test(xcatd): cover the version release comparison Checks that xCAT::Version->Release strips the git-commit decoration, that the same release from different snapshots compares equal, and that a real release difference is still reported. That distinction is what lets xcatd separate a real version mismatch from a same-release build difference. --- xCAT-test/unit/version_release.t | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 xCAT-test/unit/version_release.t diff --git a/xCAT-test/unit/version_release.t b/xCAT-test/unit/version_release.t new file mode 100644 index 000000000..9dc2e44fd --- /dev/null +++ b/xCAT-test/unit/version_release.t @@ -0,0 +1,32 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use FindBin; +use Test::More; + +use lib "$FindBin::Bin/../../perl-xCAT"; +require xCAT::Version; + +# xcatd tells a real version mismatch (different release) from a same-release +# build difference by comparing xCAT::Version->Release. Release must strip the +# build-specific decoration the build stamps onto the version string, so nodes +# at the same release built from different snapshots are not reported as a +# version mismatch. + +my $va = "Version 2.18.2 (git commit aaaaaaaaaaaaaaaa)"; +my $vb = "Version 2.18.2 (git commit bbbbbbbbbbbbbbbb)"; +my $vc = "Version 2.19.0 (git commit cccccccccccccccc)"; + +is(xCAT::Version->Release($va), "Version 2.18.2", + 'Release strips the git-commit decoration'); +is(xCAT::Version->Release($va), xCAT::Version->Release($vb), + 'the same release built from different snapshots compares equal'); +isnt(xCAT::Version->Release($va), xCAT::Version->Release($vc), + 'a real release difference is still reported'); + +# A string with no decoration is returned unchanged. +is(xCAT::Version->Release("Version 2.18.2"), "Version 2.18.2", + 'a version without decoration is left as is'); + +done_testing();