Skip to content

Conversation

shay23bra
Copy link
Contributor

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 like nvme (/dev/nvme0n1p2) and dm-*.

Changes

  • EFI path resolution: In src/ops/ops.go, findEfiDirectory now uses o.getPartitionPathFromLsblk(device, "2") to obtain the correct partition path from lsblk.
  • lsblk invocation: Replace lsblk -b -J with lsblk --bytes --json <device> and rely on the scoped output instead of manual filtering.
  • Linter cleanup: Remove redundant slice nil check (S1009) in src/ops/ops.go.
  • Tests: Update mocks and expectations in src/ops/ops_test.go to reflect the new lsblk arguments and single-device behavior.

Validation

go test ./... passes locally.
Manually verified EFI partition resolution for sda, nvme0n1, and dm-* style names.

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
@openshift-ci openshift-ci bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 19, 2025
@openshift-ci openshift-ci bot requested review from eliorerz and javipolo August 19, 2025 20:31
@shay23bra shay23bra changed the title Mgmt 20756 assisted installer naive string concatenation for partition finding [master] Mgmt 20756 assisted installer naive string concatenation for partition finding Aug 19, 2025
@shay23bra shay23bra changed the title [master] Mgmt 20756 assisted installer naive string concatenation for partition finding [master] MGMT-20756 assisted installer naive string concatenation for partition finding Aug 19, 2025
Copy link

codecov bot commented Aug 19, 2025

Codecov Report

❌ Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.98%. Comparing base (7552020) to head (b7998d6).

Files with missing lines Patch % Lines
src/ops/ops.go 25.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
src/ops/ops.go 42.65% <25.00%> (-4.25%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shay23bra
Copy link
Contributor Author

/retest

@openshift-ci openshift-ci bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 20, 2025
@omertuc
Copy link
Contributor

omertuc commented Aug 20, 2025

Looks good but failing unit tests

@omertuc
Copy link
Contributor

omertuc commented Aug 20, 2025

/approve

Copy link

openshift-ci bot commented Aug 20, 2025

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 20, 2025
@shay23bra
Copy link
Contributor Author

/retest

Copy link

openshift-ci bot commented Aug 20, 2025

@shay23bra: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/edge-unit-test b7998d6 link true /test edge-unit-test
ci/prow/okd-scos-e2e-aws-ovn b7998d6 link false /test okd-scos-e2e-aws-ovn

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants