add module to centrally track Ceph release info for the backend

Add a small module with a static hash that includes most relevant
meta-info of ceph release. Ceph 15.2 Octopus was used as rather
arbitrary cut-off.
Not all meta-info will be used, but those basic things seemed to not
hurt to add already now.

Further add some helper to query available and available+supported
release codenames and the default release codename and a getter for a
whole release entry.

We currently to not clone entries when returning them, so callers can
mess with the references content, but as this seems unlikely to cause
fallout for this very specific info lets keep it simple for now.

As a implementation details the module experiments with opting into
modern perl feature set through `use v5.36`, allowing signatures and
avoiding the need for enabling warnings/strict modes.
In general all but one of the features that get enabled are pretty
much safe, the problematic one being the feature_bitwise one, which
separates using bitwise operators for numerical and string data types,
causing potential fallout if one used them for a bitwise operation on
a string that should be interpreted as number.

The module will be used in the next commits.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2024-09-26 17:30:10 +02:00
parent abbf6dedb9
commit 3a4881713d
2 changed files with 129 additions and 2 deletions

View File

@ -1,8 +1,9 @@
include ../../defines.mk
PERLSOURCE = \
Releases.pm \
Services.pm \
Tools.pm
Tools.pm \
all:

126
PVE/Ceph/Releases.pm Normal file
View File

@ -0,0 +1,126 @@
package PVE::Ceph::Releases;
use v5.36;
use PVE::pvecfg;
my sub get_current_pve_major_release {
my $release_tuples = [ split(/\./, PVE::pvecfg::release()) ];
return $release_tuples->[0];
}
my $_ceph_release_info;
my sub get_ceph_release_def {
if (defined($_ceph_release_info)) {
return $_ceph_release_info;
}
# Track all ceph releases (from a initial cut-off) with some metainfo.
#
# Schema keys:
# - `release`: version number of the stable release, which for ceph normally is `X.2`
# - `initial-upstream-release`: the ISO 8601 formatted day when upstream made their initial
# stable release.
# - `estimated-end-of-upstream-support`: the ISO 8601 formatted day when upstream will go EOL
# - `available-for-pve-release`: a hash that denotes for which PVE major release series a ceph
# release is available, where available does not necessarily means (already) fully supported
# - `current-backend-default`: set to `1` if a release is currently used as default in the
# backend, i.e. by pveceph. The wizard from the web UI often uses a newer release, which is
# currently tracked manually there.
# - `unsupported`: set to `1` to mark a release as (currently) unsupported, which most often
# means that upstream either had no stable release yet, or we aren't 100 % finished with QA
# of that release yet.
#
# NOTE: very old releases got left out from the list, but there's _no_ need to clean-up
# periodically check https://docs.ceph.com/en/latest/releases/ for all past releases
my $ceph_release_info = {
octopus => {
release => '15.2',
'initial-upstream-release' => '2020-03-23',
'estimated-end-of-upstream-support' => '2022-08-09',
'available-for-pve-release' => {
6 => 1,
7 => 1,
},
},
pacific => {
release => '16.2',
'initial-upstream-release' => '2021-03-31',
'estimated-end-of-upstream-support' => '2024-03-04',
'available-for-pve-release' => {
7 => 1,
},
},
quincy => {
release => '17.2',
'current-backend-default' => 1,
'initial-upstream-release' => '2022-04-19',
'estimated-end-of-upstream-support' => '2024-06-01',
'available-for-pve-release' => {
7 => 1,
8 => 1,
},
},
reef => {
release => '18.2',
'initial-upstream-release' => '2023-08-07',
'estimated-end-of-upstream-support' => '2025-08-01',
'available-for-pve-release' => {
8 => 1,
},
},
};
my $current_pve_major_release = get_current_pve_major_release();
for my $codename (sort keys $ceph_release_info->%*) {
my $ceph_release = $ceph_release_info->{$codename};
$ceph_release->{codename} = $codename;
$ceph_release->{'available-for-current-pve-release'} = $ceph_release->{'available-for-pve-release'}->{$current_pve_major_release};
}
$_ceph_release_info = $ceph_release_info;
}
sub get_ceph_release_info($codename) {
my $ceph_releases = get_ceph_release_def();
return $ceph_releases->{$codename};
}
my $_available_ceph_releases;
sub get_all_available_ceph_releases {
if (!defined($_available_ceph_releases)) {
my $ceph_releases = get_ceph_release_def();
$_available_ceph_releases = {};
for my $codename (sort keys $ceph_releases->%*) {
if ($ceph_releases->{$codename}->{'available-for-current-pve-release'}) {
$_available_ceph_releases->{$codename} = $ceph_releases->{$codename};
}
}
}
return $_available_ceph_releases;
}
sub get_available_ceph_release_codenames($include_unstable_releases = 0) {
my $available_releases = get_all_available_ceph_releases();
return $include_unstable_releases
? [ sort keys $available_releases->%* ]
: [ grep { !$available_releases->{$_}->{unsupported} } sort keys $available_releases->%* ]
;
}
my $_default_ceph_release_codename;
sub get_default_ceph_release_codename {
if (!defined($_default_ceph_release_codename)) {
my $ceph_releases = get_all_available_ceph_releases();
my @default_release = grep { $ceph_releases->{$_}->{'current-backend-default'} } keys $ceph_releases->%*;
die "internal error: got multiple ceph releases with 'current-backend-default' set\n"
if scalar(@default_release) > 1;
die "internal error: got no ceph releases with 'current-backend-default' set\n"
if scalar(@default_release) < 1;
$_default_ceph_release_codename = $default_release[0];
}
return $_default_ceph_release_codename;
}
1;