-
Notifications
You must be signed in to change notification settings - Fork 109
[master] MGMT-20756 assisted installer naive string concatenation for partition finding #1214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Replace naive string concatenation for partition finding with robust lsblk --json based approach. This fixes mounting issues with device mapper devices (dm-*) where the old approach would try to mount /dev/dm-02 instead of the correct /dev/dm-2. - Add getPartitionPathFromLsblk() function using lsblk --json output - Update OverwriteOsImage() to use new partition discovery method - Fix calculateFreePercent() to use proper array indexing - Add test for device mapper devices to verify the fix - Maintain backward compatibility with existing device types (sda, nvme, mmcblk)
- Add 16 unit tests covering all device types and edge cases - Test SATA, NVMe, MMC, and Device Mapper devices - Test error handling: invalid JSON, missing devices, no partitions - Test boundary conditions: invalid partition numbers, out of range - Test realistic multi-device scenarios - Verify exact ticket scenario: /dev/dm-0 partition 2 → /dev/dm-2 - All tests placed at end of file following best practices - 100% test coverage for the new lsblk-based partition discovery
len() returns 0 for nil slices, so explicit nil check is unnecessary
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1214 +/- ##
==========================================
- Coverage 55.82% 54.98% -0.84%
==========================================
Files 15 15
Lines 3477 3468 -9
==========================================
- Hits 1941 1907 -34
- Misses 1329 1358 +29
+ Partials 207 203 -4
🚀 New features to boost your workflow:
|
/retest |
Looks good but failing unit tests |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: omertuc, shay23bra The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
@shay23bra: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Summary
Improve partition detection by querying
lsblk
directly for the device and using its JSON to resolve the EFI partition path, eliminating brittle string concatenation.Problem
findEfiDirectory
previously constructed the EFI partition path via naive string concatenation (e.g.,device + "2"
), which fails for device name patterns likenvme
(/dev/nvme0n1p2
) anddm-*
.Changes
findEfiDirectory
now useso.getPartitionPathFromLsblk(device, "2")
to obtain the correct partition path fromlsblk
.lsblk
invocation: Replacelsblk -b -J
withlsblk --bytes --json <device>
and rely on the scoped output instead of manual filtering.nil
check (S1009) insrc/ops/ops.go
.src/ops/ops_test.go
to reflect the newlsblk
arguments and single-device behavior.Validation
go test ./...
passes locally.Manually verified EFI partition resolution for
sda
,nvme0n1
, anddm-*
style names.