2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-09-05 12:37:56 +00:00
Commit Graph

158 Commits

Author SHA1 Message Date
Markus Hilger 497a7abffb Do not cache an SDR that failed to build
init_sdr assigned self._sdr before initialize() ran, so a failure left the
half built object in the cache. The next call saw a non-None _sdr and handed
back that partial repository rather than trying again.

The visible symptom is a first call raising and the second appearing to
succeed. The real cost is on a bmc where the read fails once: the client
keeps the incomplete sdr for the life of the session and every later sensor
lookup answers from it without complaint.
2026-09-03 02:15:22 +02:00
Jarrod Johnson 7afbbca691 Merge pull request #291 from Obihoernchen/fix/multi-nic-refusal
Say which interfaces a multi-homed BMC has, rather than crash
2026-09-02 10:29:29 -04:00
Jarrod Johnson d4c5fd850a Merge pull request #290 from Obihoernchen/fix/report-failures-not-crashes
Let a failed request report itself
2026-09-02 10:16:16 -04:00
Jarrod Johnson 26c69e6cc0 Merge pull request #289 from Obihoernchen/fix/health-optional-collections
Handle Redfish services that omit optional collections
2026-09-02 10:13:26 -04:00
Markus Hilger 9012888cc0 Report a refused XCC web login instead of returning None
get_webclient falls off its end when /api/login answers anything but 200, so
it returned None. wc() passes that back, and thirty of the thirty-four call
sites use it unchecked, so a refused login arrived as "'NoneType' object has
no attribute 'grab_json_response'" from wherever it landed.

Raised where the failure is known, and with the status: 404 is firmware with
no web api, or a Redfish-only capture of one, while 401 is credentials it
will not take. Neither was distinguishable before.

The other four call sites are the inventory reads, and they always did check.
They answer partially when the web interface is out of reach, which is why
nodeinventory still says something useful. They ask through wc_if_available
now, so that tolerance is stated rather than resting on a None.
2026-09-01 23:52:49 +02:00
Markus Hilger 7a7bd758a4 Let a failed request report itself
Two places where the code that exists to explain a failure fails instead, and
the caller is shown the second failure rather than the first.

_do_web_request builds its message from the response body when that body is
not the JSON error document the spec asks for. An html 404 page is exactly
that, the body is bytes, and str + bytes raised TypeError. The status and the
body never reached anyone.

LenovoFirmwareConfig raised a bare Exception when python-lxml and
python-eficompressor are absent. Confluent has no handler for one, so a
missing dependency showed as "Unexpected Error" and hid a message that
already said what to install.

Neither changes what fails, only what the caller is told.
2026-09-01 23:52:49 +02:00
Markus Hilger 1d8dcae6b0 Refuse plainly when a BMC lists no interfaces at all
Same function, one line above. EthernetInterfaces is optional, and when it is
absent the None went into a request and raised TypeError from the url library
rather than saying what was missing.

Kept beside the ambiguous case because the two are one question asked twice.
2026-09-01 23:52:25 +02:00
Markus Hilger 6909d1b5df Say which interfaces a multi-homed BMC has, rather than crash
Dedicated plus shared is how BMCs are built, so several NICs is ordinary.
_get_bmc_nic_url only reaches the count when the address the session came in
on matches none of them, which is what a tunnel or a NAT does, and it then
raised the bare PyghmiException base class.

Confluent has no handler for the base class, so it fell through to the
generic one and showed "Unexpected Error" plus a traceback, for a machine
doing nothing wrong. UnsupportedFunctionality now, which the redfish plugin
already reports plainly and which stays inside PyghmiException.

The message said "does not have exactly one interface" without saying how
many, which ones, or what to do. Every caller takes a name, so it lists the
candidates, and the empty case reads differently from the ambiguous one.
2026-09-01 23:52:25 +02:00
Markus Hilger 26151c506f Read power and boot from a service that has no system
A Redfish service may publish no Systems collection, and power and cooling
equipment does exactly that. sysurl is then None, and get_power and
get_bootdev handed it straight to a request, raising TypeError from inside
the url library.

sysinfo already guarded the same field. Both now ask through _system_url and
get a refusal naming what is missing. DMTF publish three services of this
shape, which is why they sit commented out in inventory-dmtf.yaml.
2026-09-01 23:51:32 +02:00
Markus Hilger 5d5ad821f4 Read health from a service that publishes no PCIe
PCIeDevices and PCIeFunctions are optional, and get_health indexed both
without checking. _get_adp_urls in the same file already spells it
.get('PCIeDevices', []), so these two were the outliers.

Power and cooling equipment has no PCIe at all. The KeyError escaped the
health read and reached the user as "Unexpected Error" with a traceback
behind it. Reproduces offline against DMTF's public-rackmount1 mockup.
2026-09-01 23:51:32 +02:00
Markus Hilger 2e7ce63b51 Read a fractional second as a fraction
parse_time read the digits after the decimal point as whole milliseconds, so
'.5' became 5ms instead of 500ms. Only a three digit fraction came out right,
and a BMC may write either.

'.5', '.50' and '.500' are all 500ms now, '.125' is 125ms. Every other format
parse_time accepts is untouched.
2026-09-01 23:51:00 +02:00
Markus Hilger ef9afa7d72 Fix advanced settings
Disabled this by accident when doing the async fixes.
Upstream pyghmi passess this as well.
2026-08-20 00:41:34 +02:00
Jarrod Johnson 2bd931658c Defer creating locks until loop is running
In python 3.9, this pattern was causing issues.
2026-08-19 13:13:20 -04:00
Jarrod Johnson a0d99a15ce Fix use of positional arguments in getadrrinfo
The new getaddrinfo needs this as a keyvalue pair.
2026-08-19 11:05:41 -04:00
Jarrod Johnson ec64a6d46c Change to asyncio based name lookup in various places 2026-08-19 10:28:55 -04:00
Jarrod Johnson 31647a52e1 Remove disused RLock and simplify code. Fix name lookup stalls on connection. 2026-08-19 09:56:28 -04:00
Markus Hilger 9cdcbe4046 Look elsewhere when the manager publishes no log services
The early return sat before the fallback, so the one layout it was
written for was the one it could not reach.
2026-08-19 15:10:55 +02:00
Markus Hilger caa857ead0 Gather every event log a platform keeps, wherever it keeps it
A read only ever looked at the manager's log services, and fell back to the
system's when the manager published none.  A platform that keeps an event log
in both places had the second one invisible: an AMI MegaRAC keeps power unit
and thermal events in a chassis log that nothing read, 103 records that no
command could reach.

Clearing deliberately does not follow.  It stays where it was, so a log that
only a read reaches is never destroyed by one, and clearing a platform that
keeps its only event log on the system still works.

The name test now ignores spacing, since a build that calls its post code log
"BIOS POST Code Log" was read as an event log and merged 2719 post codes in.
2026-08-19 15:10:55 +02:00
Jarrod Johnson 3fa1236d34 Merge pull request #278 from Obihoernchen/fix/configurable-endpoints
configurable sockapi path and ipmi port
2026-08-19 08:33:06 -04:00
Jarrod Johnson c87bdc5a40 Merge pull request #274 from Obihoernchen/openbmc-support
Various fixes and features for AMI MegaRAC and OpenBMC BMCs
2026-08-19 08:22:26 -04:00
Markus Hilger 9e811dd81c Leave it to OpenBMC to say which of its logs are not events
Reading an event log skipped every log service whose id or name said journal,
dump, post code, host logger or crash, on every implementation.  Those names
are bmcweb's: the AMI and Lenovo bmcs call theirs SEL, EventLog, AuditLog and
PlatformLog.  bmcweb does need the distinction, keeping its event log under the
system while a clear would destroy its dumps, so it gets a handler that names
the words and generic names none, reading whatever a platform publishes.
2026-08-18 22:58:48 +02:00
Markus Hilger 811d48ed42 Ask only MegaRAC for the parameters part it insists on
Generic added an UpdateParameters part to every multipart firmware push,
because the specification has one carried.  Only the AMI firmware was seen to
insist on it, so name it in that handler and let generic send what the caller
passed.
2026-08-18 22:58:48 +02:00
Markus Hilger eaa1a8bfc7 Let a console work through a forwarded ipmi port
A bmc behind a forward answers Activate Payload with the port it listens on
itself, and the advertised-port check refused that, so a console failed where
command traffic worked. The advertised port is never sent to, so the check now
applies only on the default port. A bmc on another port advertising a third one
is no longer refused outright, which nothing here could have served anyway.
2026-08-16 21:37:50 +02:00
Markus Hilger c5f831e589 Start the bmc reset grace when the bmc actually goes
The deadline was set when monitoring began, so a flash that kept
answering for longer than the grace period had already spent it by the
time the reboot it covers arrived, and reported a working update as a
failure.
2026-08-15 13:46:18 +02:00
Markus Hilger 3ace6af075 Reserve the sensor records of the lun they are read from
A device holds its sensor records per lun and scopes the reservation the
same way, so a token taken on lun 0 can be refused for lun 1 with 0xc5.
The retry then took the same wrong token again without end.
2026-08-15 13:45:49 +02:00
Markus Hilger 274b1b310d Record why identify writes the system and not the chassis
An SD665-N V3 refuses every IndicatorLED value on its chassis and takes
all of them on the system, so making the write follow the read breaks it.
2026-08-15 13:44:49 +02:00
Markus Hilger c9804368f2 Only read a user slot as empty when the bmc says it is
Any completion code counted as an absent slot, so a bmc that was busy
or still starting up quietly shortened the user list.
2026-08-15 13:44:49 +02:00
Markus Hilger 803c4f2ceb Skip a shared enclosure when reading the leds
get_identify already ignores a chassis several systems share, so that
one node does not report the enclosure's indicator as its own.
2026-08-15 13:44:49 +02:00
Markus Hilger be1304e560 Name the firmware categories beyond core, adapters and disks
Firmware for a supply or a fan matched no fragment and so was called
core, and nothing could ever answer for misc.

Only the collections that mean one thing are matched by url.  A Storage
resource is the subsystem, so its firmware is the controller rather than
a drive, and a Processor is a cpu as readily as an accelerator, so that
one is decided by asking the processor what it is.
2026-08-15 13:44:37 +02:00
Markus Hilger 8c884e2ece Keep unrelated firmware in core rather than nowhere
An entry naming no RelatedItem was dropped from every category as soon
as any other entry named one, so core lost the bmc and uefi versions.
2026-08-15 12:58:47 +02:00
Markus Hilger e69f82a6a2 Do not let a failed lookup pass for a failed delete
The check for whether the account went sat outside the try, so an error
reading it escaped instead of falling back to blanking the account.
2026-08-15 12:58:32 +02:00
Markus Hilger 24e8cd7e00 Check for a deleted account without the cache
The delete that failed left the account collection cached as it was, so
asking whether the account is gone could only ever answer no.
2026-08-15 12:58:16 +02:00
Markus Hilger fd84d38bbd Read the lan config parameter through raw_command
pyghmi asks for this parameter with xraw_command and catches the completion
code for a bmc that does not have it, and folding aiohmi in renamed that call
to oldraw_command rather than raw_command, so the handler could no longer fire.
Answering the code out of the returned dictionary repaired the crash but kept
the call on the older contract, which is now the only one left in the tree.

Catch it again instead: raw_command puts the completion code on the exception
as ipmicode, and nothing here reads the payload of a reply that carries a code,
which is the one thing catching gives up.

No behaviour change, checked against the previous version over the same fake
session for a good reply, an empty one, 0x80 and 0xC9 with and without a stray
payload, four other completion codes, a timeout, a lost session and a reply
with no data at all: same return value, same exception type, text and ipmicode,
same bytes on the wire.
2026-08-15 05:08:45 +02:00
Markus Hilger 2becb424fc End the device sdr retries a bmc will not satisfy
_read_device_sdr_lun negotiates the read size down when the bmc answers 0xCA,
but the size > 5 guard leaves a size of 5 alone, so a bmc that will not serve
5 bytes at once was asked the same question for ever.  Give up once the
request cannot get any smaller, and once a header read would go under the 5
bytes the record length sits in, by falling through to the raise already
there.

The stale reservation retry could not end on its own either: it cleared the
id and left taking a new one to the top of the loop, which only reserves for
a partial read, so the very first request repeated unchanged.  Take one where
the code is handled.
2026-08-15 04:44:43 +02:00
Markus Hilger 7c68758761 Back off a fru read the bmc will not serve in one piece
Completion codes 201 and 202 mean the chunk asked for was too big, and the
check for them sat after a call that raises, so a bmc that cannot serve 224
bytes at once failed the fru read rather than being asked for less.

The retry could not terminate either: chunksize // 2 + 2 is 4 for a chunksize
of 4, so the chunksize == 3 guard was unreachable and a bmc that kept refusing
would have been asked for 4 bytes for ever.
2026-08-15 04:33:28 +02:00
Markus Hilger d5e9be5abb Skip an absent optional sensor again, and read the ipv6 answer
Completion code 203 on a sensor reading means the sensor is not present, which
is expected of an optional device, but the check for it sat after a call that
raises first, so one absent sensor ended the whole sensor sweep.

_supports_standard_ipv6 read rsp['code'] the same way, so it could only ever
answer True; a platform without the standard parameters raised instead.  A
completion code is that platform's answer, while a timeout or a lost session is
not and must not be cached as one.

raw_command's docstring still described itself as the other call it was renamed
from, which is how these checks came to be written against the wrong contract.
2026-08-15 04:33:28 +02:00
Markus Hilger a513bfc04f Read the sdr partial read codes from the exception
raw_command raises on any nonzero completion code, so the 0xCA and 0xC5 checks
in get_sdr could not run: a bmc that will not return a whole record in one go,
or whose reservation went stale, failed the sensor load outright instead of
being retried.  Read the code from the exception, which carries it.

The back off also had a fixed point, size // 2 + 2 being 3 for a size of 3, so
a bmc that kept refusing would have been asked the same question for ever.
Give up when the request cannot get any smaller.  A header read cannot go
under 5 bytes either, since that is where the record length sits, so give up
there rather than parse a reply too short to index.

The stale reservation retry could not end on its own either: it cleared the id
and left taking a new one to the top of the loop, which only reserves for a
partial read.  Take one where the code is handled.
2026-08-15 04:33:28 +02:00
Markus Hilger f1fddd89b9 Drop a firmware entry that answered with nothing
The labels are worked out across the whole inventory, since a platform may give
every entry the same Name, so an entry that came back empty would be asked for a
name it does not have and take the naming of the others with it.
2026-08-15 04:07:23 +02:00
Markus Hilger 93a6ee554b Tell a refused user slot apart from a session that went away
get_user_name documents that it answers None when reading a slot fails, but
raw_command raises before the check that would return it, so that branch has
never run and one refused slot aborted the whole user list.  Answer None where
the docstring says to, and let get_users drop the blanket except it grew to
work around it.

Only a completion code counts as the bmc answering about the slot.  A timeout
carries the fabricated 0xffff from the session layer and a lost session carries
no code at all, and swallowing either of those reports a list truncated at the
point of failure as a complete one.
2026-08-14 22:04:59 +02:00
Markus Hilger dda9b47a51 Ask a platform which firmware image types it takes
Some will not take an image without being told which kind it is, and the
only way to find out was to attempt an update and read the error, which
writes to the bmc before it gets that far.
2026-08-14 21:26:29 +02:00
Markus Hilger 055434a862 Only ask a second time when the bmc might answer differently
Retrying a refusal three times over nine seconds only delayed the fallback
meant for it.
2026-08-14 21:26:29 +02:00
Markus Hilger 2ba5119f44 Judge a bios link by the status it answered
A link that is not served need not answer with a redfish error, so the
message id could not decide.
2026-08-14 21:26:29 +02:00
Markus Hilger eb742c5701 Let a virtual media insert report why it failed
Any failure fell back to setting the properties, so the property set's
complaint replaced the real reason.
2026-08-14 21:26:29 +02:00
Markus Hilger dd41aed9cc Write the identify indicator where reading finds it
Reading prefers the chassis, writing looked only at the system.
2026-08-14 21:26:29 +02:00
Markus Hilger 6576c25f77 Require a bmc to have gone away before an update counts as applied
A bmc that keeps answering while the task read fails is a fault, not the
update landing.
2026-08-14 21:26:29 +02:00
Markus Hilger fe3e98a426 Read device sensor records without raising on the retry codes
raw_command raises on 0xCA and 0xC5 before the partial read loop can act
on them.
2026-08-14 21:26:29 +02:00
Markus Hilger bf9aba73d3 Report no unit for a sensor that has no reading
The sdr carries unit fields for every sensor record, and they were read into
the reading whether or not the sensor has a number for them to describe.  A
discrete sensor reports which of its states are asserted and no value at all,
so a watchdog came back with units of "% ", and a discrete sensor on a full
record picks up a base unit the same way, reporting degrees celsius for a
sensor that never has a temperature.  A caller that shows the unit alongside
whatever value it was handed then prints a unit with nothing to apply it to,
which is what the client was taught to skip in 8c8c32cc.  The client is not
the only consumer of a reading, so answer the question in the library.

The record itself says which sensors those are, and the reading path already
works it out to decide whether to decode a number: a sensor has one only if
the numeric format says how to read it, or the format is unsigned and the
record either supports thresholds or is of reading type 1.  Ask that once,
where the units are assembled, and give the sensors that fail it no unit, so
the unit and the value cannot come to different conclusions about whether the
sensor has a reading at all.

A threshold or numeric sensor reports exactly what it did before, including
the ones whose unit is a percentage, a combination of two units, or nothing
because the record names no unit.  On the Lenovo XCC this was checked against
nothing changes: its 305 readable sensors decode identically, discrete ones
included, because they are all compact records naming no unit in the first
place.  The sensors that change are the ones the finding came from, which
name a unit on a record that has no number to put it on.
2026-08-14 21:26:29 +02:00
Markus Hilger 6ce03f5081 Call a firmware entry something that identifies it
This bmc gives all three of its firmware entries the same Name, "Software
Inventory", and puts what they actually are in the description.  The first
entry took that name, and the two after it fell back to their ids, so
nodefirmware answered with "Software Inventory", "cpld_active" and
"d1dc9e4b" for what are the host, cpld and bmc images.

Decide the labels across the collection rather than one entry at a time,
so a name the platform repeats can be recognised as no name at all.  Where
that happens, use a description that does tell them apart, and the id when
even that is shared.  A platform whose names are already distinct keeps
exactly the names it had.

The labels are what a caller addresses an entry by, so this also turns
inventory/firmware/all/d1dc9e4b into inventory/firmware/all/bmc_image.
2026-08-14 21:26:29 +02:00
Markus Hilger 586b2f1d77 Report more of a processor than its model
Processor inventory carried a single field, the model, so a platform that
does not give one had a processor in the listing with nothing in it, and
the client, which skips empty values, showed no processor at all.  This
bmc names the manufacturer, the socket and the core and thread counts, and
gives no model.

Carry those, along with the speed, serial and part number where a platform
offers them, and treat a processor as missing only when the bmc says its
state is absent, rather than whenever it does not describe a state.
2026-08-14 21:26:29 +02:00
Markus Hilger 63c5f2dca5 Keep the device available bit out of the firmware version
The top bit of the major revision byte of Get Device ID says the device is
still initialising or taking a firmware update.  It was read as part of
the revision, so immediately after a bmc reset nodefirmware reported "BMC
Version: 131.11" for what is 3.11, and settled down only once the bit
cleared.

Mask it as sdr.py already does for the same byte, so the two agree about
the same field.
2026-08-14 21:26:29 +02:00