844 Commits

Author SHA1 Message Date
Julia Kreger
6ac3f350c0 Unmount config drives
If this seems like deja vu, that is because it is. We had this
very same issue with the original CoreOS ramdisk. Since we don't
control the whole OS of the ramdisk, it only made sense to teach
the agent to umount the folder.

The folder is referenced already, and the agent does have safeguards
in place, but unfortunately this issue led to a rebuild breaking where
cloud-init, glean, and the agent were all trying do the right thing
as they thought, and there were just multiple /mnt/config folders
present in the OS. These are separate issues we also need to try and
remedy.

What happens is when the device is locked via a mount, the partition
table is never updated to the running OS as the mount creates a lock.
So the agent ends up thinking, in the case of a rebuild, that everything
including creating a configuration drive on that device has been
successful, but when you reboot, there is no partition table entry
for the new partition as the change was not successfully written.
This state prevented the workload from rebooting properly.
This change eliminates that possibility moving forward by attempting
to ensure that the cloud configuration folder is no longer mounted.

Change-Id: I4399dd0934361003cca9ff95a7e3e3ae9bba3dab
2024-04-29 15:41:59 -07:00
Zuul
28053644cd Merge "add mixed matching of root device hints" 2024-04-27 17:26:25 +00:00
Zuul
2b67f277b7 Merge "Step to clean UEFI NVRAM entries" 2024-04-27 02:10:54 +00:00
Tudor Domnescu
ceec5a7367 destroy_disk_metadata: support 4096 sector size
A sector size of 512 was assumed and hardcoded, causing dd to fail when
it tried to write in chunks smaller than the sector size for disks with
4096 bytes sectors. The size of GPT in sectors also depends on sector size.

Change-Id: Ide5318eb503d728cff3221c26bebbd1c214f6995
2024-04-24 20:37:44 +00:00
Adam Rozman
84a1195d5a add mixed matching of root device hints
This commit introduces the following changes:
  - New optional `all_serial_and_wwn` argument for the block device
    listing logic. The new argument makes it possible to
    collect wwn and serial number information from both
    lsblk and udevadm at the same time
  - Both the short and the long serials are collected
    from udeavadm without prioritization when the new argument
    has teh value True
  - The new feature is automatically enabled during block device listing
    as part of the root disk selecetion
  - New options are added to the lsblk command when used in the block
    device discovery process, previously lsblk was not looking
    for wwn numbers and now it does

Closes-Bug: #2061437
Change-Id: I438a686d948cd929311e2f418bb02fb771805148
Signed-off-by: Adam Rozman <adam.rozman@est.tech>
2024-04-15 15:53:50 +03:00
Steve Baker
215fecd447 Step to clean UEFI NVRAM entries
Adds a deploy step ``clean_uefi_nvram`` to remove unrequired extra UEFI
NVRAM boot entries. By default any entry matching ``HD`` as the root
device, or with a ``shim`` or ``grub`` efi file in the path will be
deleted, ensuring that disk based boot entries are removed before the
new entry is created for the written image. The ``match_patterns``
parameter allows a list of regular expressions to be passed, where a
case insensitive search in the device path will result in that entry
being deleted.

Closes-Bug: #2041901
Change-Id: I3559dc800fcdfb0322286eba30ce47041419b0c6
2024-04-11 01:17:23 +12:00
Zuul
cdd0a83448 Merge "Import disk_{utils,partitioner} from ironic-lib" 2024-04-03 01:04:10 +00:00
Zuul
c784ee7cb9 Merge "Fix mocking for TestGenericHardwareManager" 2024-04-01 14:57:34 +00:00
Zuul
b6075156b3 Merge "USB device discovery" 2024-03-28 21:22:53 +00:00
Daniel King
cae6b15bbc
Fix mocking for TestGenericHardwareManager
This test class is testing the GenericHardwareManager, but did no
mocking for dispatch_to_managers. Therefore, if any of its methods
attempted to make a call to that method, it would break the unit tests.

This update adds mocking for get_managers to prevent the tests from
breaking if a method calls dispatch_to_managers.

Additionally, updates test_delete_configuration_skip_list.
test_delete_configuration_skip_list mocks get_skip_list_from_node.
mocks get_skip_list_from_node.
Correcting the return_value from a list to a set to match what is
returned from the original method.

Related-Bug: 2057668

Change-Id: Ifaa800449b49f64c6ba5779bfae1c8e2c3249903
2024-03-25 12:16:02 -04:00
Dmitry Tantsur
f824930bbd
Import disk_{utils,partitioner} from ironic-lib
With the iscsi deploy long gone, these modules are only used in IPA and
in fact represent a large part of its critical logic. Having them
separately sometimes makes fixing issues tricky if an interface of
a function needs changing.

This change imports the code mostly as it is, just removing run_as_root and
a deprecated function, as well as moving configuration options to config.py.

Also migrates one relevant function from ironic_lib.utils.

Change-Id: If8fae8210d85c61abb85c388b300e40a75d0531c
2024-03-15 18:45:04 +01:00
Zuul
e28b3e72f7 Merge "Use assert_not_called" 2024-03-15 17:30:21 +00:00
Riccardo Pittau
95b3ed3fed Fix unit tests after ironic-lib changes
Updating tests after change [1] and [2] in ironic-lib.

[1] ae53e8e4b3
[2] 7644196e7d

Change-Id: I880b4f82beb117d8812e60c13040e19476cec32b
2024-03-12 09:13:14 +01:00
Thomas Goirand
ca6ff4706b Use assert_not_called
IPA still has 3 occurences of not_called() which are failing for me
when building the Ironic Debian package in Debian Unstable (ie: with
Python 3.12).

This patch uses assert_not_called() instead of not_called(), fixing
the problem.

Change-Id: I8bd27fa706b298b28ef5bef405134a2c9803d757
2024-02-26 11:57:10 +01:00
Damien Rannou
3fd68c0848 USB device discovery
The idea is to retreive USB devices informations via 'lshw' and
return the list to ironic in order to be able to create introspection
rules based on USB devices.

Change-Id: I39d60cb467614fca7a7f701dbe576154213580a5
2024-02-19 14:49:52 +01:00
Zuul
df7eccd7f1 Merge "Trivial: avoid deprecated utcnow" 2024-02-08 14:43:41 +00:00
Zuul
6d35c1e949 Merge "Make inspection URL optional if the collectors are provided" 2024-02-07 23:06:34 +00:00
Zuul
359ac636f0 Merge "Drop usage of run_as_root" 2024-01-31 16:29:06 +00:00
Dmitry Tantsur
8877e1f319
Trivial: avoid deprecated utcnow
Change-Id: I5dbe3c2be36e23e749fbeebbc448d413d276b401
2024-01-31 10:09:13 +01:00
Dmitry Tantsur
0010f5c11a
Also retry inspection on HTTP CONFLICT
The new implementation can return it when unable to lock the node.

Other possible errors are 400 and 404 (should not be retried), as well as
5xx (already retried).

Change-Id: I74c2f54a624dc47e8e2d1e67ae4c6a6078e01d2f
2024-01-26 16:21:24 +01:00
Dmitry Tantsur
9f849472ca
Drop usage of run_as_root
IPA can only be run as root and does not use rootwrap. We need to
eventually remove support for rootwrap from ironic-lib.

Change-Id: Iffd5cae5e3dc8637bc6dd10b3bcc9fe33932b8cf
2024-01-23 14:23:23 +01:00
Zuul
1e107bd625 Merge "Add support for reporting CPU socket number" 2024-01-22 11:52:06 +00:00
Kaifeng Wang
9cafe76225 Add support for reporting CPU socket number
IPA reports a few cpu fields including cores, arch, flags etc.
There is a need that user wants to utilize the physical number in
a baremetal since cores are just a logical representation of the
compute resource.
The socket number is more suitable for the quota control in some
use cases.

Change-Id: I94be86d6b12a3a7e7ca1041d948427a073412a31
2024-01-19 21:24:37 +00:00
Dmitry Tantsur
6cd36a750f
Make inspection URL optional if the collectors are provided
With the new in-band inspection, we can derive the callback URL from
the Ironic URL, there is no need to duplicate it. This change uses
the presence of collectors as a sign to run inspection.

The previous approach of setting an inspection URL, with or without
explicitly setting collectors, still works for compatibility with
ironic-inspector.

Change-Id: Ie4279ee6d2995c9686f1dcdef1d6e5dc1dd20871
2024-01-10 08:55:42 +01:00
Dmitry Tantsur
0d4ae976c2
Support several API and Inspector URLs
Allows nodes with a single IP stack to be deployed from a dual-stack
Ironic.

Detecting advertised address and usable Ironic URLs are done completely
independently which does open some space for a misconfiguration. I hope
it's not likely in the reality, especially since this feature is
targetting advanced standalone users.

Change-Id: Ifa506c58caebe00b37167d329b81c166cdb323f2
Closes-Bug: #2045548
2024-01-09 16:43:23 +01:00
Dmitry Tantsur
2bb74523ae
Add missing headers to the inspection callback
Somehow, it has worked correctly for years, but now I've discovered that
the new inspection is (no longer?) tolerant to the missing header.

While here, copy all headers from the heartbeat code.

Change-Id: I9e5c609eb4435e520bc225dea08aedfdf169744b
2024-01-09 16:38:46 +01:00
Jay Faulkner
36e5993a04 [codespell] Fix spelling issues in IPA
This fixes several spelling issues identified by codepsell. In some
cases, I may have manually modified a line to make the output more clear
or to correct grammatical issues which were obvious in the codespell
output.

Later changes in this chain will provide the codespell config used to
generate this, as well as adding this commit's SHA, once landed, to a
.git-blame-ignore-revs file to ensure it will not pollute git historys
for modern clients.

Related-Bug: 2047654
Change-Id: I240cf8484865c9b748ceb51f3c7b9fd973cb5ada
2023-12-28 10:54:46 -08:00
Iury Gregory Melo Ferreira
03b6b0a4ab Fix inspector retries to not take a long time
Since we moved to exponential wait we increased the amount of time
to run unit tests, now we can configure the max time to wait

- before: Ran: 33 tests in 22.6581 sec.
- after: Ran: 33 tests in 4.0256 sec.

Change-Id: Ibdcfebacad0489d17183e43ceb0d603fce67e72b
2023-12-19 14:26:59 -03:00
Dmitry Tantsur
2ab8364649
Add a jitter to heartbeat retries
Currently, if heartbeat fails, we reschedule it after 5 seconds.
This is fine for the first retry, but it can cause a thundering herd
problem when a lot of nodes fail to heartbeat at once.

This change adds jitter to the minimum wait of 5 seconds. The jitter is
not applied for forced heartbeats: they still have a minimum wait of
exactly 5 seconds from the last heartbeat.

The code is re-ordered to move the interval calculation to one place.
Bonus: correctly logging the next interval.

The unit tests have been rewritten to test the heartbeat process step by
step and not rely on the exact sequence of the calls.

Closes-Bug: #2038438
Change-Id: I4c4207b15fb3d48b55e340b7b3b54af833f92cb5
2023-12-13 17:34:24 +01:00
Iury Gregory Melo Ferreira
801da9ec1f Retry in ProxyError during post inspector data
* ProxyError is derived from ConnectionError, but it's necessary
to check the Response object to identify.

- Added ProxyError in retry_if_exception_type
- Updated _post_to_inspector to proper handle ProxyError
- Updated the wait to use wait_exponential instead of wait_fixed.

Closes-Bug: 2045429
Change-Id: Iefe3fe581cd4e7c91a0da708e6f6d0fdaacab6fe
2023-12-06 12:01:35 -03:00
Zuul
beccfe8c92 Merge "Revert "Fix vmedia network config drive handling"" 2023-11-30 15:14:20 +00:00
Dmitry Tantsur
c57deb7e76 Revert "Fix vmedia network config drive handling"
This reverts commit 33f01fa3c2f32f447ed36f00fea68321c3991c2e.

There are a few issues with the patch - see my comments there.
The most pressing and the reasons to revert are:
1) It breaks deployments when the vmedia is present but does not
   have a network_data.json (the case for Metal3).
2) It assumes the presence of Glean which may not be the case.

Neither Julia nor myself have time to thoroughly fix the issue,
leaving a revert as the only option to unblock Metal3.

Change-Id: I3f1a18a4910308699ca8f88d8e814c5efa78baee
Closes-Bug: #2045255
2023-11-30 10:33:29 +00:00
Zuul
61d17e2225 Merge "Parse efibootmgr type and details" 2023-11-29 01:10:27 +00:00
Zuul
eea9917023 Merge "Fix vmedia network config drive handling" 2023-11-29 01:10:25 +00:00
Steve Baker
352df0bc54 Parse efibootmgr type and details
This change improves the regex to match an exact entry name, and to also
match with the the entry type from a set of recognised types.
The boot entry details start from the recognised type onwards.

This can be used by a step which deletes all entries of type 'HW' and
UsbClass.

Related-Bug: #2041901
Change-Id: I5d879f724efc2919b541fd3fef0f931df67ff9c7
2023-11-24 09:45:40 +13:00
Zuul
768aa17442 Merge "Add mlnx deploy_step entry to enable deploy time firmware" 2023-11-23 00:12:13 +00:00
Zuul
7a4114512c Merge "Handle different device outputs for multipath" 2023-11-22 21:36:40 +00:00
Zuul
9f9940efdc Merge "Test coverage for efi_utils.get_boot_record" 2023-11-22 21:36:39 +00:00
Iury Gregory Melo Ferreira
0a29206b8d Handle different device outputs for multipath
In some cases the output of the multipath can differ
and we would return a wrong parent device.

Closes-Bug: 2043992
Change-Id: I848d7df798cc736bd5a55eed8fa46110caea1dc3
2023-11-20 22:51:41 -03:00
Zuul
845df338f8 Merge "improve multipathd error handling" 2023-11-09 17:31:32 +00:00
Julia Kreger
33f01fa3c2 Fix vmedia network config drive handling
When performing DHCP-less deployments, the agent can start and
discover more than one configuration drive present on a host.

For example, a host was previously deployed using Ironic, and
is now being re-deployed again.

If Glean was present in the ramdisk, the glean-early.sh would end
mounting the folder based upon label.

If cloud-init, somehow is still in the ramdisk, the other folder
could somehow get mounted.

This patch, which is intended to be backportable, causes the agent
to unmount any configuration drive folders, mount the most likely
candidate based upon device type, partition, and overall state of
the machine, and then utilize that configuration, if present,
to re-configure and reload networking.

Thus allowing dhcp-less re-deployments to be fixed without
forcing any breaking changes.

It should also be noted that this fix was generated in concert
with an additional tempest test case, because this overall failure
case needed to be reproduced to ensure we had a workable non-breaking
path forward.

Closes-Bug: 2032377
Change-Id: I9a3b3dbb9ca98771ce2decf893eba7a4c1890eee
2023-11-08 12:11:06 -08:00
Zuul
9d9568ba23 Merge "Get numa_node info when collecting pci devices info" 2023-11-06 18:15:33 +00:00
Steve Baker
26be55f763 Test coverage for efi_utils.get_boot_record
A step will be developed to delete all EFI entries of type HD. As part
of this get_boot_record will need to parse more of the output of
`efibootmgr -v`.

This change asserts the existing behaviour of get_boot_record, and the
test can evolve with the changes in get_boot_record.

Related-Bug: #2041901
Change-Id: I0c5ac4adc1044c528c27a4eaf580c619ceef47e0
2023-11-06 14:12:02 +13:00
Jay Faulkner
3d42298619 Remove standby.cache_image support
Image caching was never fully supported in Ironic or IPA; this is vestigal
code leftover from a partial implementation.

Even if we implemetented it today, we'd likely use a completely different
methodology.

Change-Id: Id4ab7b3c4f106b209585dbd090cdcb229b1daa73
2023-10-24 15:02:44 -07:00
Zhou Ya
76ad06225a Get numa_node info when collecting pci devices info
IPA now includes information about numa node id when collecting
information about PCI devices.

Closes-bug: #1622940
Co-Authored-By: Jay Faulkner <jay@jvf.cc>
Change-Id: I70b0cb3eff66d67bb8168982acbbf335de0599cd
2023-10-24 14:27:21 -07:00
Adam Rozman
13537db293 improve multipathd error handling
This commit:
  - Adds the ability to ignore inconsequential OS error caused
    by starting the multipathd service when an instance of the
    service is already running.

Related launchpad issue https://bugs.launchpad.net/ironic-python-agent/+bug/2031092

Change-Id: Iebf486915bfdc2546451e6b38a450b4c241e43a8
2023-10-23 16:33:03 +03:00
Zuul
b42f0be422 Merge "implement basic-auth support for user-image download process" 2023-10-13 17:08:28 +00:00
Boushra Bettir
dbf3e5408d Replace shlex module with helper function
Used helper function, `parse_device_tags`
from ironic_lib instead of the
shlex module for their identical
functionality. Updated
mock_execute.side_effect for lsblk
compatibility in utils.execute.

Closes-Bug: #2037572
Change-Id: I6600e054f9644c67ab003f0e0f6c380b5c217223
2023-10-12 13:34:32 -07:00
Julia Kreger
cb61a8d6c0 Retry on checksum failures
HTTP is a fun protocol.

Size is basically optional. And clients implicitly trust the server
and socket has transferred all the bytes. Which *really* means you
should always checksum.

But... previously we didn't checksum as part of retrying.

So if anything happened with python-requests, or lower level
library code or the system itself causing bytes to be lost off the
buffer, creating an incomplete transfer situation, then we wouldn't
know until the checksum.

So now, we checksum and re-trigger the download if there is a
failure of the checksum.

This involved a minor shift in the download logic, and resulted in
a needful minor fix to an image checksum test as it would loop for
90 seconds as well.

Closes-Bug: 2038934
Change-Id: I543a60555a2621b49dd7b6564bd0654a46db2e9a
2023-10-10 09:15:31 -07:00
Adam Rozman
70961789a6 implement basic-auth support for user-image download process
This feature was proposed in https://bugs.launchpad.net/ironic-python-agent/+bug/2021947

Change-Id: I9dbfc1402240beb75b6736214753fd86dccae676
2023-10-10 16:25:51 +03:00