Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2237235

Summary: Cannot install the system when a LUKS device is used to store kickstart data
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
Component: anacondaAssignee: anaconda-maint
Status: CLOSED MIGRATED QA Contact: Release Test Team <release-test-team-automation>
Severity: high Docs Contact:
Priority: high    
Version: 8.8CC: jkonecny, sbarcomb
Target Milestone: rcKeywords: MigratedToJIRA
Target Release: ---Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-09-18 17:35:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Renaud Métrich 2023-09-04 10:04:38 UTC
Description of problem:

Some customers use a LUKS encrypted archive to store their kickstart data. This archive is getting opened by the kickstart early with a %pre script.
Later, during installation, the partitioning is setup and fails due to having the LUKS archive be opened.
Until RHEL8.6 included, this was working fine, but RHEL8.8 nor RHEL9.2 let that work anymore.

Version-Release number of selected component (if applicable):

RHEL8.8 & RHEL9.2

How reproducible:

Always

Steps to Reproduce:
1. Create a LUKS archive stored somewhere on NFS

  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
  # truncate -s 200M luks.img
  # cryptsetup luksFormat luks.img --force-password
  [...]
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

2. Create a kickstart fetching the LUKS archive and opening it

  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
  %pre
  iotty="$(tty)"
  exec > "${iotty}" 2> "${iotty}"
  
  mkdir /mnt/rmetrich
  mount 192.168.122.1:/home/rmetrich /mnt/rmetrich
  
  while true; do
    cryptsetup luksOpen /mnt/rmetrich/luks.img cryptroot - && break
  done
  %end
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

3. Proceed to installation of the system using the kickstart

Actual results:

Fails at partitioning step:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
The existing unlocked LUKS device loop3 cannot be used for the installation without an encryption key specified for this device. Please, rescan the storage.
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Expected results:

No failure

Comment 1 Jiri Konecny 2023-09-06 08:41:43 UTC
Hi, we took a look on this and it seems it's happening because of https://github.com/storaged-project/blivet/pull/991 which is basically fix that Anaconda now see devices with different than expected name.

The proposed solution is to try to add `ignoredisk` command for the loop devices.

Comment 2 Renaud Métrich 2023-09-06 08:55:40 UTC
"ignoredisk --drives=/dev/loop3" doesn't help

Comment 3 Renaud Métrich 2023-09-06 09:14:46 UTC
Instrumentation in /usr/lib64/python3.6/site-packages/pyanaconda/modules/storage/checker/utils.py to see what changes:
~~~
diff -u rootfs/usr/lib64/python3.6/site-packages/pyanaconda/modules/storage/checker/utils.py update88/usr/lib64/python3.6/site-packages/pyanaconda/modules/storage/checker/utils.py 
--- rootfs/usr/lib64/python3.6/site-packages/pyanaconda/modules/storage/checker/utils.py	2023-03-17 14:44:41.000000000 +0100
+++ update88/usr/lib64/python3.6/site-packages/pyanaconda/modules/storage/checker/utils.py	2023-09-06 11:04:52.690308527 +0200
@@ -350,6 +350,12 @@
         and any(c.name == d.format.map_name for c in d.children)
     ]
 
+    for dev in [ d for d in storage.devices if d.format.type == "luks" and d.format.exists ]:
+        report_warning("XXX device {}: map_name: {}".format(dev, dev.format.map_name))
+        for c in dev.children:
+            report_warning("XXX child {}: name: {}".format(c, c.name))
+
+
     for dev in devices:
         report_error(_("The existing unlocked LUKS device {} cannot be used for "
                        "the installation without an encryption key specified for "
~~~

Result on RHEL8.8:
~~~
XXX device existing 200 MiB loop loop3 (50) with existing luks: map_name: cryptroot
XXX child existing 184 MiB luks/dm-crypt cryptroot (80): name: cryptroot
~~~

Result on RHEL8.6 (works):
~~~
XXX device existing 200 MiB loop loop3 (50) with existing luks: map_name: luks-c9ef7a5f-2ca9-465b-9ecf-72e7fe223d1c
XXX child existing 184 MiB luks/dm-crypt cryptroot (80): name: cryptroot
~~~

Here above we see "dev.format.map_name" is the name that WOULD be used if Anaconda created the device.

Comment 4 Jiri Konecny 2023-09-07 08:55:20 UTC
Thanks for testing this Renauld.

Would it be possible to cleanup in the %pre script and unmount the loop device before installation is started? If something needs to be read during the installation it is possible to store these data into /tmp or on disk and clean them up in the %post section.



Another option would be to make Anaconda smarter to ignore loop devices or similar, however, I have a bad feeling that we broke another user use-case by that change where loop device is used on purpose for the installation.

Comment 5 Renaud Métrich 2023-09-07 09:16:27 UTC
Indeed, copying the luks archive content into a tmpfs is a known working, but for the end customer, his archive is huge, so it requires a lot of memory.

Comment 7 RHEL Program Management 2023-09-18 17:34:09 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 8 RHEL Program Management 2023-09-18 17:35:51 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.