Skip to content

Add osism manage redfish validate - #2951

Merged
ideaship merged 6 commits into
mainfrom
implement/issue-2594-redfish-validate
Dec 1, 2026
Merged

ideaship merged 6 commits into
mainfrom
implement/issue-2594-redfish-validate

Conversation

@berendt

@berendt berendt commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

osism manage redfish validate <hostname> checks the BMC of one node against Ironic's OpenStackIronicProfile v1.2.0. It prints a verdict per requirement and exits with 0 (PASS), 1 (FAIL) or 2 (INCOMPLETE, or ERROR if the validation could not run). The DMTF Redfish-Interop-Validator 3.0.5 evaluates the profile in a conductor task. The run is read-only, apart from creating and deleting its Redfish session.

Closes #2594

Commits

  1. Extract the Redfish access resolution: moves the address and credential lookup out of get_redfish_connection unchanged, and adds tests for it.
  2. Add the redfish-interop-validator dependency: pins 3.0.5 and regenerates Pipfile.lock.
  3. Vendor the OpenStackIronicProfile v1.2.0: adds the unmodified file, installs it to /etc/redfish/, and adds the setting REDFISH_INTEROP_PROFILE_PATH.
  4. Validate a node against the profile on the conductor: adds validate_profile and its task. The tests run against the real validator and replace only its HTTP client.
  5. Add the manage redfish validate command: adds the table and JSON output and the exit codes.
  6. Document the Redfish profile validation.

Differences from the issue

The profile is in files/redfish-profiles/, not files/redfish/. This also changes the path in the issue's SHA-256 criterion. mypy takes a directory files/redfish for the redfish package that files/redfishMockupCreate.py imports, and fails with Module "redfish" has no attribute "redfish_logger". mypy passes on main and fails on main with only that directory added. The installed path and the default of the setting are as in the issue.

Five more differences come from reading the pinned validator and client sources:

  1. The links to the subtrees come from the service root as read after the login, not from sut.service_root. That copy is from before the login. On a BMC that answers that request with 401, it holds no links, and a conforming node gets a FAIL. A test covers this case and fails with sut.service_root.
  2. unreadable[].error is the name of the exception class if the exception has no message. The client raises RetriesExhaustedError() without one, for example after timeouts.
  3. The redfish.rest.v1 logger is set to WARNING. At INFO, the level of the worker, the client logs the response to the login request. In a local test with a mock BMC that returns the password in that response, the client alone logged the password at INFO. The worker log did not contain it.
  4. An outer handler turns any unexpected exception into the issue's Validation of <hostname> aborted result, so that the function never raises.
  5. The validator's stdout is redirected for the whole run, because load_profile also prints when it fails.

In an ERROR result, service is null.

Three more differences come from the review:

  1. If no requirement failed but a resource is unreadable, the result is INCOMPLETE with exit code 2, not PASS. The validator adds no rows for such a resource, so a second system that cannot be read did not change the result. INCOMPLETE keeps the rows and the unreadable resources, which an ERROR result does not have. A FAIL stays a FAIL.
  2. unreadable also lists responses with status 200 whose body is empty or not a JSON object. The client returns {} for an empty body. validate_response() accepts that, but the validator then skips the resource.
  3. If the task cannot be sent or its result cannot be read, the command prints an ERROR result in the chosen format and exits with 2. Before, the exception led to exit code 1, the code of a FAIL.

Deviations from the approved plan

  • The directory name, as described above. The author chose the rename over adding a mypy option.
  • Pipfile.lock gains 12 packages for the validator, as the issue expected. It also gains backports-zstd (only for Python before 3.14) and typing-extensions in the develop section. Locking the unchanged Pipfile with Python 3.13 adds the same two. No locked version changes and no package is removed.
  • The test environment was installed with pip install -e . including dependencies, not with --no-deps. CI also installs the dependencies. tabulate and fastapi are only in requirements.txt.
  • The local run of the command used a separate environment with requirements.txt and requirements.ansible.txt, because the conductor imports ansible. The unit tests stub it.
  • There are four more tests than planned. They cover the description of the run in the result, the folding of array indexes, resource-level rows in the table, and the full scope with missing service values in the table.

Verification

  • pytest in an environment installed with pipenv install --dev --deploy: 4456 passed, 3 expected failures. main has 4364 passed and the same 3 expected failures. No existing test case changed.
  • black 26.10.1, flake8 7.5.0 (on the changed Python files) and mypy 1.20.2, the versions the Zuul jobs use, pass locally.
  • The test for two runs in one process fails without the reset of the validator's module state. Without it, the missing VirtualMedia resource of the second node counts as found.
  • The real command ran against a real Celery worker and a mock BMC over HTTP, with fakeredis as the broker. It covered --help, a rejected --format yaml, PASS, FAIL with an unreadable resource, and ERROR. The last three ran with both output formats and returned exit codes 0, 1 and 2. One more run used --full. The BMC received 59 GET requests, and one POST and one DELETE of the session for each of the 5 runs that reached it. The address and the credentials came from a stand-in, because the real lookup needs NetBox and /etc/conductor.yml. Unit tests with mocked sources cover the lookup. No real BMC was tested. This run was before the rebase and the review changes and was not repeated. Only unit tests cover INCOMPLETE and the ERROR result for a failed task.

Not exercised locally

  • The Zuul jobs flake8, python-black, mypy and hadolint: only a live system can verify them (Zuul). hadolint was not run locally.
  • The Zuul job container-image-python-osism-build, including uv pip check --system and osism --help: only a live system can verify it (Zuul). The image was not built locally. uv pip compile resolves its nine requirement files with the four override files for Python 3.13 on musl. This does not include the install of /src itself. This check was before the rebase and was not repeated.

Declined questions

None.

Noticed but not touching

  • README.md:22-23: the documented steps pipenv install --dev and pipenv run pytest do not install tabulate and fastapi, which are missing from the Pipfile. Without them, 20 test modules fail at collection. CI also runs pipenv run pip install .. Changing the test setup is outside this issue.
  • osism/tasks/conductor/utils.py:215: get_redfish_connection reads REDFISH_TIMEOUT but does not pass it to sushy.Sushy. The issue lists this as a Non-Goal.

🤖 Generated with Claude Code

@berendt
berendt marked this pull request as ready for review November 29, 2026 10:37
@berendt berendt moved this from New to Ready for review in Human Board Nov 29, 2026
@berendt
berendt requested a review from ideaship November 29, 2026 10:37
@berendt berendt self-assigned this Nov 29, 2026

@ideaship ideaship left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR needs a rebase (expect to resolve a conflict).

"model": sut.model,
"firmware_version": sut.firmware_version,
},
result="FAIL" if counts["FAIL"] else "PASS",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verdict only looks at requirement rows, so a resource the BMC failed to serve can't change it.

Take a BMC that lists two systems, serves the first and returns 500 for the second. In validator 3.0.5, validate() stops at validate_response() for the second one, before profile.get_requirements(), so it adds no rows and no entry to FoundURIs. apply_global_checks() then sees the first system in FoundURIs and passes the mandatory ComputerSystem check. The second system shows up only as an Unreadable: line, and the command exits 0, although none of that system's mandatory properties were checked. Anything that uses exit code 0 as a gate would let this node through.

Could we stop returning PASS/0 when unreadable is non-empty? Either a separate verdict such as INCOMPLETE, or mapping it to ERROR/2. Please add a test where the first system is readable and the second is not.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a4da6de, as a separate verdict. If no requirement failed but unreadable is not empty, the result is INCOMPLETE and the exit code is 2. I chose it over ERROR because an ERROR result has no rows and no unreadable resources, and the operator needs both. A FAIL stays a FAIL. test_unreadable_second_system_is_incomplete covers a readable first system with a second one that returns 500, times out, or returns 200 with a non-object body.

unreadable = []
for uri, data in sut._resources.items():
exc = data["Exception"]
if exc is not None or data["StatusCode"] != 200:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This misses resources that came back with HTTP 200 but a body the validator can't use: malformed JSON, or JSON that isn't an object. Exception is only set when the fetch itself fails, and StatusCode is 200, so neither condition is true. validate_response() still returns None for such a body, and the validator drops the resource without a row.

That contradicts the docs, which tell the operator to look for a missing resource among the Unreadable: lines. Could this also count an entry as unreadable when validate.validate_response(data) returns None? Then it also feeds into the verdict, see the comment on the verdict line. A test with a 200 response and a non-object body would cover it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a4da6de. An entry now also counts as unreadable if validate_response() returns None, and that feeds into the verdict. One more case has the same effect: for an empty body with status 200, the client returns {}. validate_response() accepts that, but the validator then skips the resource because it has no @odata.type. Such an entry is unreadable too. test_unreadable_lists_unusable_bodies covers malformed JSON, a list, a string, null and the empty body.

Comment thread osism/commands/redfish.py Outdated

from osism.tasks.conductor import validate_redfish_profile

result = validate_redfish_profile.delay(hostname, parsed_args.full).get()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If .delay() or .get() raises, cliff exits 1. That happens when the broker is down, the worker is lost, or the task raises. The docs reserve 1 for FAIL and promise 2 when "the validation could not run", so a script can't tell "the node violates the profile" from "we never checked". With --format json, nothing is printed on stdout either.

The task can raise in practice. _traverse() runs in a try/finally with no except, and in the default scope get_resource_data(SERVICE_ROOT) returns the parsed body as is. If the BMC answers the service root with a JSON array or string, service_root.get(...) raises AttributeError, and that ends up here.

Could you catch the exception here, build an ERROR result with the exception type and message, render it in both formats, and return 2? test_validate_propagates_task_error currently asserts that the exception propagates, so it would change to assert exit code 2 and the ERROR output. Catching exceptions from _traverse() in the task and returning _error(...) would also give a clean message in the conductor log.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f5244ab. If .delay() or .get() raises, the command builds an ERROR result with the exception type and message, prints it in the chosen format, and returns 2. The JSON document has the same keys as a result from the conductor. Tests that expect exit code 2 and the ERROR output replace test_validate_propagates_task_error.

The service root example did not raise out of the task: the outer handler in validate_profile already catches exceptions from _traverse(). With a JSON array as the root, it logs and returns Validation of node-1 aborted: AttributeError: 'list' object has no attribute 'get', and the session is logged out. I left that code as it is and added test_root_that_is_not_an_object_returns_error in a4da6de for an array and a string.

@github-project-automation github-project-automation Bot moved this from Ready for review to In review in Human Board Nov 30, 2026
get_redfish_connection resolves the base URL and the credentials of a
node inline before it builds the sushy connection. Move that part
unchanged into get_redfish_access, so that a caller that does not use
sushy resolves a node the same way. The profile validation added later
in this series is such a caller.

The lookup order and the log messages stay the same:
get_redfish_connection keeps its signature and still returns None for
an empty hostname. The resolution had no tests, so add them.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Christian Berendt <berendt@osism.tech>
The profile validation added later in this series runs the DMTF
Redfish-Interop-Validator in-process on the conductor. Pin it to 3.0.5
in requirements.txt and in the Pipfile. Its requirement redfish>=3.1.5
is met by the existing pin of redfish 3.4.2.

Regenerating Pipfile.lock with pipenv lock adds the validator and 11
packages it depends on. No locked version changes and no package is
removed. The lock also gains two entries that do not come from the
validator: backports-zstd, whose marker limits it to Python versions
before 3.14, and typing-extensions in the develop section. Locking the
unchanged Pipfile with Python 3.13 adds the same two.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Christian Berendt <berendt@osism.tech>
Ironic publishes its expectations of a Redfish service as a DMTF
interoperability profile. Add an unmodified copy of version 1.2.0, taken
from redfish-interop-profiles/OpenStackIronicProfile.v1_2_0.json at
openstack/ironic@5928707. The file
states its license as Apache-2.0.

The Containerfile installs it to /etc/redfish. The new setting
REDFISH_INTEROP_PROFILE_PATH defaults to that path, so a deployment sets
nothing. Unit tests and installs outside the image can point it at
another copy.

The directory is not called files/redfish, because mypy would take it
for the redfish package that files/redfishMockupCreate.py imports, and
fail with "Module "redfish" has no attribute "redfish_logger"".

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Christian Berendt <berendt@osism.tech>
Add the task validate_redfish_profile. It runs the DMTF
Redfish-Interop-Validator in-process against one node and returns a
verdict per profile requirement, aggregated over all resources, and an
overall PASS, FAIL, INCOMPLETE or ERROR. By default it reads the service
root and the six subtrees that hold the resource types of the profile.
With full it crawls the whole service. It sends GET requests only, apart
from creating and deleting its Redfish session.

The validator adds no rows for a resource that the service fails to
serve, or serves with status 200 and a body that is empty or not a JSON
object. If one of two systems cannot be read, the rows of the other one
can all be a PASS. Such resources are listed as unreadable, and a run
that has any is INCOMPLETE instead of PASS. A FAIL stays a FAIL.

The validator has no public result interface and keeps loaded profiles
in module state. A worker process runs many validations, and without a
reset a mandatory resource that is missing on one node counts as found
if the previous node had it. The tests run against the real package and
replace only its HTTP client, so a validator upgrade that moves these
internals fails there.

The links to the subtrees come from the service root as read after the
login. The client's own copy is from before the login. On a service that
answers that request with 401 it holds no links, and the validation
would report every mandatory resource but the root as missing.

At INFO level, which the worker uses, the client logs the response to
the login request. A service that returns the password in it would put
the password into the worker log, so raise the level of that logger to
WARNING.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Christian Berendt <berendt@osism.tech>
An operator who adds a bare-metal node has no check up front whether its
BMC offers what Ironic needs. A missing capability shows up during
enrollment, inspection or the first deploy, with an error that names a
symptom.

"osism manage redfish validate <hostname>" runs the new conductor task
and prints one row per profile requirement and the overall result. A
failing row names the resource that fails. Resources that the BMC failed
to serve are listed as well, because they otherwise look like resources
that do not exist. --full crawls the whole service, and --format json
prints only the result document on stdout.

The exit codes follow "osism sonic validate": 0 for a pass, 1 for a
missed mandatory requirement, and 2 if the validation is incomplete or
could not run. If the task cannot be sent or its result cannot be read,
the command prints an ERROR result in the chosen format and exits with
2. Uncaught, the exception would exit with 1, the code of a FAIL.
Warnings and skipped requirements do not fail the run.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Christian Berendt <berendt@osism.tech>
Describe how to run "osism manage redfish validate", what its results
and exit codes mean, what each scope reads, and why a run is safe on a
node in production. Record where the vendored profile comes from and how
to replace it, and what to re-check when the pin of the validator
moves.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Christian Berendt <berendt@osism.tech>
@berendt
berendt force-pushed the implement/issue-2594-redfish-validate branch from 2f750d7 to 550bcf4 Compare December 1, 2026 08:08
@berendt
berendt requested a review from ideaship December 1, 2026 08:09
@ideaship
ideaship merged commit d9b1a11 into main Dec 1, 2026
2 checks passed
@ideaship
ideaship deleted the implement/issue-2594-redfish-validate branch December 1, 2026 08:42
@github-project-automation github-project-automation Bot moved this from In review to Done in Human Board Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add a command to validate Redfish nodes against the OpenStackIronicProfile

2 participants