* [pbs-devel] [PATCH proxmox-backup v4 1/2] pbs2to3: add test for kernel version compatibility
@ 2024-09-18 13:00 Daniel Kral
2024-09-18 13:01 ` [pbs-devel] [PATCH proxmox-backup v4 2/2] fix #5600: pbs2to3: allow arbitrary newer '-pve' kernels after upgrade Daniel Kral
2024-11-12 20:22 ` [pbs-devel] applied-series: [PATCH proxmox-backup v4 1/2] pbs2to3: add test for kernel version compatibility Thomas Lamprecht
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Kral @ 2024-09-18 13:00 UTC (permalink / raw)
To: pbs-devel
Factors the kernel version compatibility check into its own method and
adds test cases for a set of expected and unexpected kernel versions.
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
Changes to v1/v2/v3:
- Moved refactoring and test in first commit and changes afterwards
src/bin/pbs2to3.rs | 62 ++++++++++++++++++++++++++++++++++++++++------
1 file changed, 55 insertions(+), 7 deletions(-)
diff --git a/src/bin/pbs2to3.rs b/src/bin/pbs2to3.rs
index 1f895abd..d90e62ce 100644
--- a/src/bin/pbs2to3.rs
+++ b/src/bin/pbs2to3.rs
@@ -123,18 +123,27 @@ impl Checker {
Ok(())
}
+ fn is_kernel_version_compatible(&self, running_version: &str) -> bool {
+ let re = if self.upgraded {
+ r"^6\.(?:2\.(?:[2-9]\d+|1[6-8]|1\d\d+)|5)[^~]*$"
+ } else {
+ r"^(?:5\.(?:13|15)|6\.2)"
+ };
+ let re = Regex::new(re).expect("failed to compile kernel compat regex");
+
+ re.is_match(running_version)
+ }
+
fn check_kernel_compat(
&mut self,
pkg_versions: &[pbs_api_types::APTUpdateInfo],
) -> Result<(), Error> {
self.output.log_info("Check running kernel version..")?;
- let (krunning, kinstalled) = if self.upgraded {
- (
- Regex::new(r"^6\.(?:2\.(?:[2-9]\d+|1[6-8]|1\d\d+)|5)[^~]*$")?,
- "proxmox-kernel-6.2",
- )
+
+ let kinstalled = if self.upgraded {
+ "proxmox-kernel-6.2"
} else {
- (Regex::new(r"^(?:5\.(?:13|15)|6\.2)")?, "pve-kernel-5.15")
+ "pve-kernel-5.15"
};
let output = std::process::Command::new("uname").arg("-r").output();
@@ -144,7 +153,7 @@ impl Checker {
.log_fail("unable to determine running kernel version.")?,
Ok(ret) => {
let running_version = std::str::from_utf8(&ret.stdout[..ret.stdout.len() - 1])?;
- if krunning.is_match(running_version) {
+ if self.is_kernel_version_compatible(running_version) {
if self.upgraded {
self.output.log_pass(format!(
"running new kernel '{running_version}' after upgrade."
@@ -620,3 +629,42 @@ impl ConsoleOutput {
Ok(())
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn test_is_kernel_version_compatible(
+ expected_versions: &[&str],
+ unexpected_versions: &[&str],
+ upgraded: bool,
+ ) {
+ let checker = Checker {
+ output: ConsoleOutput::new(),
+ upgraded,
+ };
+
+ for version in expected_versions {
+ assert!(checker.is_kernel_version_compatible(version));
+ }
+ for version in unexpected_versions {
+ assert!(!checker.is_kernel_version_compatible(version));
+ }
+ }
+
+ #[test]
+ fn test_is_pve_kernel_version_compatible() {
+ let expected_versions = &["5.13.19-6-pve", "5.15.158-2-pve", "6.2.16-5-pve"];
+ let unexpected_versions = &["6.1.10-1-pve", "5.19.17-2-pve"];
+
+ test_is_kernel_version_compatible(expected_versions, unexpected_versions, false);
+ }
+
+ #[test]
+ fn test_is_proxmox_kernel_version_compatible() {
+ let expected_versions = &["6.2.16-20-pve", "6.5.13-6-pve"];
+ let unexpected_versions = &["5.13.19-6-pve", "6.1.15-1-pve"];
+
+ test_is_kernel_version_compatible(expected_versions, unexpected_versions, true);
+ }
+}
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pbs-devel] [PATCH proxmox-backup v4 2/2] fix #5600: pbs2to3: allow arbitrary newer '-pve' kernels after upgrade
2024-09-18 13:00 [pbs-devel] [PATCH proxmox-backup v4 1/2] pbs2to3: add test for kernel version compatibility Daniel Kral
@ 2024-09-18 13:01 ` Daniel Kral
2024-11-12 20:22 ` [pbs-devel] applied-series: [PATCH proxmox-backup v4 1/2] pbs2to3: add test for kernel version compatibility Thomas Lamprecht
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Kral @ 2024-09-18 13:01 UTC (permalink / raw)
To: pbs-devel
Fixes a bug where `pbs2to3` shows an incorrect warning about an
unexpected running kernel version, where newer kernel versions than 6.5
were marked as unexpected (e.g. "8.6.12-1-pve").
This commit allows arbitrary newer kernel versions that are suffixed
with '-pve' from kernel version 6.2 onward. This is the same behavior as
in other upgrade helpers like `pve7to8` [1] and `pmg7to8` [2].
[1] https://git.proxmox.com/?p=pve-manager.git;a=commit;h=fb59038a8b110b0b0b438ec035fd41dd9d591232
[2] https://git.proxmox.com/?p=pmg-api.git;a=commit;h=9d67a9af218b73027822c9c4665b88e6662e7ef7
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
I've used a single regex pattern instead of the two sequential regex
pattern matches in the linked commits from pve-manager and pmg-api,
because I thought it would be a little more readable when only compiling
the regex patterns at one location here.
Changes to v1/v2/v3:
- Split up kernel version regex to make it a little more readable
- Include arbitrary newer versions from 6.2 onward ending with '-pve'
src/bin/pbs2to3.rs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/bin/pbs2to3.rs b/src/bin/pbs2to3.rs
index d90e62ce..0d6a4b10 100644
--- a/src/bin/pbs2to3.rs
+++ b/src/bin/pbs2to3.rs
@@ -2,6 +2,7 @@ use std::io::Write;
use std::path::Path;
use anyhow::{format_err, Error};
+use const_format::concatcp;
use regex::Regex;
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
@@ -124,8 +125,11 @@ impl Checker {
}
fn is_kernel_version_compatible(&self, running_version: &str) -> bool {
+ const MINIMUM_RE: &str = r"6\.(?:2\.(?:[2-9]\d+|1[6-8]|1\d\d+)|5)[^~]*";
+ const ARBITRARY_RE: &str = r"(?:[6-9]|\d{2,})\.(?:[2-9]|\d{2,})[^~]*-pve";
+
let re = if self.upgraded {
- r"^6\.(?:2\.(?:[2-9]\d+|1[6-8]|1\d\d+)|5)[^~]*$"
+ concatcp!(r"^(?:", MINIMUM_RE, r"|", ARBITRARY_RE, r")$")
} else {
r"^(?:5\.(?:13|15)|6\.2)"
};
@@ -662,7 +666,7 @@ mod tests {
#[test]
fn test_is_proxmox_kernel_version_compatible() {
- let expected_versions = &["6.2.16-20-pve", "6.5.13-6-pve"];
+ let expected_versions = &["6.2.16-20-pve", "6.5.13-6-pve", "6.8.12-1-pve"];
let unexpected_versions = &["5.13.19-6-pve", "6.1.15-1-pve"];
test_is_kernel_version_compatible(expected_versions, unexpected_versions, true);
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pbs-devel] applied-series: [PATCH proxmox-backup v4 1/2] pbs2to3: add test for kernel version compatibility
2024-09-18 13:00 [pbs-devel] [PATCH proxmox-backup v4 1/2] pbs2to3: add test for kernel version compatibility Daniel Kral
2024-09-18 13:01 ` [pbs-devel] [PATCH proxmox-backup v4 2/2] fix #5600: pbs2to3: allow arbitrary newer '-pve' kernels after upgrade Daniel Kral
@ 2024-11-12 20:22 ` Thomas Lamprecht
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2024-11-12 20:22 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Daniel Kral
Am 18.09.24 um 15:00 schrieb Daniel Kral:
> Factors the kernel version compatibility check into its own method and
> adds test cases for a set of expected and unexpected kernel versions.
>
> Signed-off-by: Daniel Kral <d.kral@proxmox.com>
> ---
> Changes to v1/v2/v3:
> - Moved refactoring and test in first commit and changes afterwards
>
> src/bin/pbs2to3.rs | 62 ++++++++++++++++++++++++++++++++++++++++------
> 1 file changed, 55 insertions(+), 7 deletions(-)
>
>
applied both patches, thanks!
albeit, it might be even nicer to just parse out the major and minor parts
of the version and compare them explicitly to a simple const u16 tuple, that
way bumping the minimum kernel might be less headache than coming up with
a new regex.
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-12 20:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-18 13:00 [pbs-devel] [PATCH proxmox-backup v4 1/2] pbs2to3: add test for kernel version compatibility Daniel Kral
2024-09-18 13:01 ` [pbs-devel] [PATCH proxmox-backup v4 2/2] fix #5600: pbs2to3: allow arbitrary newer '-pve' kernels after upgrade Daniel Kral
2024-11-12 20:22 ` [pbs-devel] applied-series: [PATCH proxmox-backup v4 1/2] pbs2to3: add test for kernel version compatibility Thomas Lamprecht
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.