apt repositories: detect mixed suites before major upgrade

Usually, differing suites already produce warnings/errors, but before
a major upgrade the current and the next suite are both valid. Mixing
them is an issue though.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fiona Ebner 2023-06-05 17:43:12 +02:00 committed by Thomas Lamprecht
parent b9b1a51a2e
commit e6ed4498cd

View File

@ -460,6 +460,7 @@ Ext.define('Proxmox.node.APTRepositories', {
let nosubscription = vm.get('noSubscriptionRepo'); let nosubscription = vm.get('noSubscriptionRepo');
let test = vm.get('testRepo'); let test = vm.get('testRepo');
let wrongSuites = vm.get('suitesWarning'); let wrongSuites = vm.get('suitesWarning');
let mixedSuites = vm.get('mixedSuites');
if (!enterprise && !nosubscription && !test) { if (!enterprise && !nosubscription && !test) {
addCritical( addCritical(
@ -477,6 +478,10 @@ Ext.define('Proxmox.node.APTRepositories', {
addWarn(gettext('Some suites are misconfigured')); addWarn(gettext('Some suites are misconfigured'));
} }
if (mixedSuites) {
addWarn(gettext('Detected mixed suites before upgrade'));
}
if (!activeSubscription && enterprise) { if (!activeSubscription && enterprise) {
addWarn(gettext('The enterprise repository is enabled, but there is no active subscription!')); addWarn(gettext('The enterprise repository is enabled, but there is no active subscription!'));
} }
@ -507,6 +512,7 @@ Ext.define('Proxmox.node.APTRepositories', {
product: 'Proxmox VE', // default product: 'Proxmox VE', // default
errors: [], errors: [],
suitesWarning: false, suitesWarning: false,
mixedSuites: false, // used before major upgrade
subscriptionActive: '', subscriptionActive: '',
noSubscriptionRepo: '', noSubscriptionRepo: '',
enterpriseRepo: '', enterpriseRepo: '',
@ -641,6 +647,11 @@ Ext.define('Proxmox.node.APTRepositories', {
let digest; let digest;
let suitesWarning = false; let suitesWarning = false;
// Usually different suites will give errors anyways, but before a major upgrade the
// current and the next suite are allowed, so it makes sense to check for mixed suites.
let checkMixedSuites = false;
let mixedSuites = false;
if (success && records.length > 0) { if (success && records.length > 0) {
let data = records[0].data; let data = records[0].data;
let files = data.files; let files = data.files;
@ -659,6 +670,9 @@ Ext.define('Proxmox.node.APTRepositories', {
infos[path][idx] = { infos[path][idx] = {
origin: '', origin: '',
warnings: [], warnings: [],
// Used as a heuristic to detect mixed repositories pre-upgrade. The
// warning is set on all repositories that do configure the next suite.
gotIgnorePreUpgradeWarning: false,
}; };
} }
@ -667,8 +681,11 @@ Ext.define('Proxmox.node.APTRepositories', {
} else if (info.kind === 'warning') { } else if (info.kind === 'warning') {
infos[path][idx].warnings.push(info); infos[path][idx].warnings.push(info);
} else if (info.kind === 'ignore-pre-upgrade-warning') { } else if (info.kind === 'ignore-pre-upgrade-warning') {
infos[path][idx].gotIgnorePreUpgradeWarning = true;
if (!repoGrid.majorUpgradeAllowed) { if (!repoGrid.majorUpgradeAllowed) {
infos[path][idx].warnings.push(info); infos[path][idx].warnings.push(info);
} else {
checkMixedSuites = true;
} }
} }
} }
@ -683,8 +700,21 @@ Ext.define('Proxmox.node.APTRepositories', {
repo.Origin = infos[file.path][n].origin || Proxmox.Utils.UnknownText; repo.Origin = infos[file.path][n].origin || Proxmox.Utils.UnknownText;
repo.warnings = infos[file.path][n].warnings || []; repo.warnings = infos[file.path][n].warnings || [];
if (repo.Enabled && repo.warnings.some(w => w.property === 'Suites')) { if (repo.Enabled) {
suitesWarning = true; if (repo.warnings.some(w => w.property === 'Suites')) {
suitesWarning = true;
}
let originType = me.classifyOrigin(repo.Origin);
// Only Proxmox and Debian repositories checked here, because the
// warning can be missing for others for a different reason (e.g.
// using 'stable' or non-Debian code names).
if (checkMixedSuites && repo.Types.includes('deb') &&
(originType === 'Proxmox' || originType === 'Debian') &&
!infos[file.path][n].gotIgnorePreUpgradeWarning
) {
mixedSuites = true;
}
} }
} }
gridData.push(repo); gridData.push(repo);
@ -700,6 +730,7 @@ Ext.define('Proxmox.node.APTRepositories', {
vm.set('errors', errors); vm.set('errors', errors);
vm.set('suitesWarning', suitesWarning); vm.set('suitesWarning', suitesWarning);
vm.set('mixedSuites', mixedSuites);
me.getController().updateState(); me.getController().updateState();
}); });