Commit Graph

230 Commits

Author SHA1 Message Date
Luke Odom ae53e8e4b3 Swap partprobe and udev settle
On ubuntu based systems calling these in opposite causes a
race condition where partitions aren't ready when we read/use them

Closes-Bug: 2050013
Change-Id: Ied7e4f17786dfc0e7f54962013e48ff96c5faa88
2024-02-12 11:18:01 -08:00
Dmitry Tantsur 7644196e7d
Split common qemu-img functions from disk_utils
Adds a new module for two qemu-img wrappers that are used both by Ironic
and IPA. The remaining functions in disk_utils are only used by IPA and,
since most of them require root, can no longer be used in the
post-rootwrap Ironic any more. They should be moved to IPA eventually.

Change-Id: I3364a58b52a3e57c2f52356a6496865b749e74a8
2024-01-23 14:00:43 +01:00
Dmitry Tantsur 87a739fe17
Raise on non-existing file in qemu_img_info
I'm not sure why we silence the exception, right now it causes us a very
hard to debug failure. No code in Ironic seems to rely on this behavior.

Change-Id: I3740b600c60ed1b39808d18af2b5074e7e07a149
2024-01-15 17:24:27 +01:00
Sharpz7 7952b5d788 [codespell] Fixing spelling issues in Ironic-Lib
Continuing work by @JayF in other ironic repos. Find that explanation below.

This fixes several spelling issues identified by codepsell.

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: https://bugs.launchpad.net/ironic-python-agent/+bug/2047654

Change-Id: I38ad9c46add87b0e67c912f2920f76ea7d0c3b80
2024-01-15 07:16:16 +00:00
Zuul 523407eebf Merge "Compatibility with zeroconf 0.129.0" 2024-01-05 19:54:03 +00:00
Jay Faulkner 078cdabdf5 Improve error message for wrong metrics backend
We should breadcrumb the operator into what this message means -- right
now, it looks like a programming error when in most cases this is a
configuration error.

Related-bug: 2047709
Change-Id: Ica627834f799cffbf283ee01a2b2482a607c316d
2023-12-29 11:20:28 -08:00
Thomas Goirand e2ced90dc5
Compatibility with zeroconf 0.129.0
From Zeroconf CHANGELOG.md:
v0.129.0 (2023-12-13)

Feature

* Add decoded_properties method to ServiceInfo
https://github.com/python-zeroconf/python-zeroconf/issues/1332
9b595a1dca
* Ensure ServiceInfo.properties always returns bytes
https://github.com/python-zeroconf/python-zeroconf/issues/1333
d29553ab7d

Technically breaking change

* `ServiceInfo.properties` always returns a dictionary with type
`dict[bytes, bytes | None]` instead of a mix `str` and `bytes`. It was
only possible to get a mixed dictionary if it was manually passed in
when `ServiceInfo` was constructed.

Co-Authored-By: Dmitry Tantsur <dtantsur@protonmail.com>
Change-Id: I7f1a0c3329e5f29ec3e274558e3681142cc2ef78
2023-12-19 11:50:19 +01:00
Zuul 54597e9210 Merge "Trivial: remove an incorrect comment" 2023-12-06 19:27:49 +00:00
Zuul a0e26d4f8e Merge "JSON RPC: add support for unix sockets and extract common code" 2023-12-06 18:18:44 +00:00
Dmitry Tantsur 13fcbb9258
Trivial: remove an incorrect comment
IP addresses work, we even have unit tests for them.

Change-Id: I2765047896d722e647e69f0a03e3bb3b48c41b3b
2023-12-06 17:25:47 +01:00
Dmitry Tantsur 9846a1c18f
JSON RPC: add support for unix sockets and extract common code
Listening on Unix sockets is helpful when the whole Ironic is behind
a reverse proxy, as it's the case in Bifrost and Metal3 with TLS on.

This change also extracts some common code to be reused in Ironic later.

Change-Id: I3488b9bb67470ce6d062187dc5e44852f6908493
2023-11-24 18:56:06 +01:00
Julia Kreger 2f7f72e147 Increase the ESP partition size to 550 MB
This change makes ironic-lib consistent with ironic-python-agent
and diskimage-builder's defaults for ESP partition sizes.

The following fedora change lays out why this is a necessary
change: https://fedoraproject.org/wiki/Changes/BiggerESP

In summary, additional space is needed if OS driven firmware
flashing is going to take place, and unikernels + next generation
bootloaders are going to consume more space than the existing
grub loader has.

Change-Id: I4fc63c02bf57a08e75121cfa1fd35a56c0427553
2023-11-07 07:12:24 -08:00
Zuul bdbd0e9287 Merge "Add jsonrpc client port capability" 2023-05-08 19:19:58 +00:00
Jay Faulkner 853bedce5c Upgrade to latest hacking - v6
Includes a single minor change to comply with latest flake8.

Change-Id: Ifda4810940f5c4d963946939f103f65175cc7868
2023-04-21 12:26:23 -07:00
Julia Kreger 0a62259018 Add jsonrpc client port capability
Adds the capability for the topic to contain a port to which
the json rpc client will connect to. This allows for distinct
json-rpc targets to be configured in an environment.

Change-Id: I999316880639cd410543eb54475b0c647b35147b
2023-04-04 10:01:38 -07:00
Arne Wiebalck ec6ba65392 Use direct writes when erasing the GPT
Use direct I/O when overwriting the partition table to expose device
failures (which would not be directly noticed otherwise).

Change-Id: Ib0790099d895410681e4a1679bedea62209ff277
2023-03-01 15:11:04 +01:00
Julia Kreger 71e06086b0 Provide an interface to store metrics
Internally, if we want to re-use ironic-prometheus-exporter
*and* get useful metrics data out through it for ironic itself,
we need we need someway to collect and return metrics data.

Turns out, we did most of this for statsd ages ago, and we can
just reuse the framework.

Change-Id: I6060da4ab80c2e6d19d78b808216ae262edcc84c
2023-01-06 08:48:35 -08:00
Dmitry Tantsur 2337a06533 json_rpc.client: log the URL and exceptions
Change-Id: I0c02d68fd82dc5c9d5fec32ca98f02e98228eca2
2022-07-13 12:37:27 +02:00
Iury Gregory Melo Ferreira 7d68f9484c Follow-up Allow customizing roles to use JSON RPC
This is a follow-up for I143203be7827f73daba32e7c084c5807063ff91d
with minor fixes requested in the review.

Change-Id: I83a506b0a489efe56b4a11a954a76fe0783fa4ba
2022-02-17 09:56:48 -03:00
Takashi Kajinami 4ea8df8e21 Allow customizing roles to use JSON RPC
This change allows customizing the roles required for JSON RPC, to use
any roles different from the 'admin' role.

There is a plan, as part of SRBAC effort, to replace usage of the admin
role in each service by the new service role, which has more restricted
access, and we expect the ironic service user would require only
the service role once this work is done.

Change-Id: I143203be7827f73daba32e7c084c5807063ff91d
2022-01-26 21:29:35 +09:00
Riccardo Pittau 731e2f9c82 Restore blkid compatibility with Centos 7
The blkid version included in util-linux 2.23.2 does not allow long
options name for probe and match-tag.
Use the short single letter name to restore compatibility with Centos 7

Story: 2009328
Task: 43764

Change-Id: I10a52c16ebe4e519d0af63b36c3a89fd5d371319
2021-11-15 15:53:32 +01:00
Derek Higgins b6416eee71 Allow qemu-img to write out zeros to disk
Allow the sparse_size for qemu-img to be specified in order
instruct it to write out all zeros(when set to 0). Doing this
will cause it not to zero out the entire block device
which can be very costly on a slow HDD.

Story: 2009227
Task: 43315
Change-Id: I480352be378020a6063fe247238b18713031f6b0
2021-09-23 09:16:12 +01:00
Zuul 509d9ce360 Merge "Avoid using blkid in favour of lsblk and parted" 2021-09-07 14:47:37 +00:00
Dmitry Tantsur b7f12117b9 Avoid using blkid in favour of lsblk and parted
Per blkid man page, we should rather use lsblk, which has much better
debugging output (blkid essentially only returns an exit code). Since
the partition table type is not available in lsblk, copy the procedure
using parted from ironic-python-agent.

Change-Id: I3b20754727de904dbe72f358a21f31f00a5fbb77
2021-08-27 13:25:55 +02:00
Dmitry Tantsur ac95888059 Drop an explicit requirement of oslo.log
This library is designed for leaf applications (services, CLI). For
libraries it's enough to use the generic logging.

Unit tests needed adjustment since LOG.exception is implemented via
LOG.error internally.

Change-Id: I943e1f07a23e76354966acae5e4594e41dd4822b
2021-08-20 17:13:24 +02:00
David Vallee Delisle f6ddd09d50 json_rpc: list_opts() should return tuple
list_opts() should return a tuple otherwise
oslo-config-(genera|valida)tors are unable to parse its output.

Story: 2009126
Task: 43039

Change-Id: Ib4b9c270709f5994bc2c031c339822d7d6b9356d
2021-08-18 00:42:51 +00:00
Takashi Kajinami d33cf3e033 Use the json format output of qemu-img info
Support for the human format by oslo_utils.imageutils.QemuImgInfo was
deprecated since oslo.utils 4.9.1 [1]. This change replaces the human
format with the json format which will be used by default.

[1] 73eb0673f627aad382e08a816191b637af436465

Change-Id: I4c9bdbccb9345e2259ddb0737f37c09d99dd1c4f
2021-07-07 00:41:00 +09:00
Zuul 831b5c146c Merge "Remove the logic specific to the way deployment works" 2021-06-06 23:17:48 +00:00
Dmitry Tantsur e4d7c1f41e utils.execute: log stdout and stderr even on failure
Add logging when a command is not found.

Also remove duplicate logging of exit code and command line:
it's already done by processutils.

Change-Id: I0349073cf0f78fb021dcd3e830fedddf2b4a0c92
2021-06-02 11:37:21 +02:00
Julia Kreger 76cbb9623f Limit the number of malloc arenas for qemu-img convert
Under heavy load, the qemu-img convert method may attempt to create
additional malloc arenas to complete its work. By default this number
is 8 * ncpu * which at about 250 MB of memory which can be consumed
in this mannor should the.

Since this is only something which should realistically occur under
heavy cross-thread load where memory locking prevents a thread from
unlocking a range of memory, (such as what can happen with hypervisors
and VMs inside those hypervisors), then a new arena gets created, and
the memory consumption spikes.

More information is avialable at:
https://www.gnu.org/software/libc/manual/html_node/Memory-Allocation-Tunables.html

Change-Id: I8b2b490f2cc0ac5f47c3aaaaa249ce59db6602d6
Story: 2008928
Task: 42529
2021-05-26 13:47:26 -07:00
Dmitry Tantsur 36b8486419 convert_image: add flags required for IPA
To write whole disk images using convert_image we need to support
cache flags and out-of-order.

Change-Id: I60df5a747a51109965b432653184b1ee3c98e2a5
2021-05-18 14:48:04 +02:00
Dmitry Tantsur df9a2e85a5 Raise qemu-img memory limit to 2 GiB
The current value is insufficient for modern images. A similar change to IPA:
https://review.opendev.org/c/openstack/ironic-python-agent/+/778035

Change-Id: Ia1535b375d2cec467011c7456da84b5811ba48dd
2021-05-18 14:21:30 +02:00
Dmitry Tantsur 6aa94252dd Remove the logic specific to the way deployment works
This code used to be shared between the iSCSI and the direct deploy
interfaces. Now that iSCSI is gone, this code has been moved to IPA:
24951b1029

Change-Id: Ia879595d00501f3f06ae5dc2a9dca9c5ea234501
2021-05-10 13:02:11 +02:00
Dmitry Tantsur 4cf1b4f276 Remove runtime dependency on pbr
Pbr is a very heavy package to depend on. It requires git-core, which is
16 MiB on my Fedora. We only use it to detect the version, which can be
done without pbr by any consumer (e.g. with importlib_metadata).

This is technically a breaking change, although since ironic-lib is an
internal library it should not be an issue.

Change-Id: I6f5ee64226ffc6a30804c09bb28b3d6680b095d1
2021-04-26 09:01:13 +02:00
Dmitry Tantsur 41939c60d4 Fixes parsing blkid output with iSCSI devices
They have a colon in device names, so the current logic breaks.
Also add a more useful error message when splitting.

Change-Id: I55b2cc42789218afcf4ff05cdd50a250992cb9db
2021-03-04 15:51:38 +01:00
Zuul 930d456b18 Merge "Explicit execute arguments" 2021-03-01 15:34:49 +00:00
Zuul 6874b68233 Merge "Import json_rpc from ironic" 2021-02-28 14:41:57 +00:00
Riccardo Pittau 0ae0ca98dc Explicit execute arguments
The use_standard_locale and log_stdout arguments are not passed to
processutils.execute, they should be keyword arguments of the execute
function.

Change-Id: I743ce53d5e5d82401173eb7189e90531f3ee138e
2021-02-25 14:59:14 +01:00
Riccardo Pittau e7a35e41f1 Remove default parameter from execute
The param check_exit_code from the processutils extension execute has
default already at [0]
See:
https://opendev.org/openstack/oslo.concurrency/src/branch/master/oslo_concurrency/processutils.py#L214

Change-Id: Ia0f42bf3de9c074a1212859352b5c5e1abe7eed8
2021-02-25 11:22:01 +01:00
Dmitry Tantsur 22a944bd31 Import json_rpc from ironic
To be able to use the same JSON RPC implementation for ironic-inspector,
it is now imported in ironic-lib. Some additional abstraction laters are
added to avoid hard dependency on oslo.context and oslo.messaging.

Change-Id: I0e790cebcd086d26bf27b909f73842c3f46bbd77
2021-02-23 15:44:25 +01:00
Zuul 0b955a2bf7 Merge "Add a helper for getting partition path" 2021-02-22 09:00:59 +00:00
Zuul c220554915 Merge "Add find_efi_partition, deprecate get_uefi_disk_identifier" 2021-02-18 06:52:30 +00:00
Zuul 68aade81b4 Merge "utils.mounted: retry umount and allow retrying mount" 2021-02-17 03:57:01 +00:00
Zuul 18ce9e1c6e Merge "Split out a common helper for blkid" 2021-02-17 03:56:58 +00:00
Zuul 427d18a6de Merge "keystone: use os_service_type for service_type defaults" 2021-02-11 21:09:36 +00:00
Zuul 8f156d3284 Merge "Import common keystone configuration from ironic" 2021-02-11 19:13:52 +00:00
Dmitry Tantsur c2786caa1b Add find_efi_partition, deprecate get_uefi_disk_identifier
The get_uefi_disk_identifier function is currently unused in both
ironic and IPA. Furthermore, its name is confusing: it returns
the UEFI partition UUID, not the disk identifier, unlike the
similarly named get_disk_identifier.

This change imports get_efi_part_on_device from IPA as
find_efi_partition. The only difference is that it returns
a complete partition record rather than only the number.

Change-Id: I424d04adb6ccbb3daa99daa5c860cbb81332c02e
2021-02-11 18:08:12 +01:00
Dmitry Tantsur c9ac1c8186 Trivial: fix a type in tests
Change-Id: I735a6289b9b94b90f0737a4743b7281dd2bdcedf
2021-02-11 18:06:31 +01:00
Dmitry Tantsur 97affbf596 Split out a common helper for blkid
Add a new helper get_device_information that can call blkid
with various arguments. Also add get_partition_table_type
using the PTTYPE blkid field. Switch a few calls to using
the new helper.

Change-Id: I005613d9f7de8106f31c30abd9c87e0bcd6b9272
2021-02-11 18:04:14 +01:00
Dmitry Tantsur 3db78b001c utils.mounted: retry umount and allow retrying mount
It seems common in IPA to retry umount 3 times, so default to it.
Also permit retrying mount as well just in case.

Change-Id: I79fc069ff07af37bfc8109421f79c3175c4b2749
2021-02-10 18:32:09 +01:00