Open starbops opened 9 months ago
Just FYI https://github.com/openshift-metal3/fakefish have something for faking redfish for KubeVirt instances
Hey @e-minguez thanks for the pointer. The way FakeFish works looks interesting. I should've found it earlier. Nevertheless, this gave me some ideas...
So there are different levels of faking for a Redfish server...
Since our use cases involve POST actions, such as power management, we're more likely to implement a tiny but self-contained emulator.
I've checked several implementations on the Internet, but I only found one project that uses the OpenAPI generator to generate the client library in Go from the DMTF-published DSP8010 Redfish OpenAPI schema.
My current plan is to use a Golang-based OpenAPI generator [1][2] to generate models and server stubs from the Redfish OpenAPI schema. It turns out this isn't as easy as I imagine at the beginning. The Golang OpenAPI generators have their own limitations and they're both not as mature as the Java-based openapi-generator. Moreover, the Redfish OpenAPI schema is gigantic and uses some cryptic (or should I say erroneous) OpenAPI syntax that I'm unfamiliar with.
I might go the other way around to trim down the schema a bit since we wouldn't support that many endpoints and resources. Because of that, we'll stick to a specific Redfish version. Though that seems lame, it might be the only way that I can see. If my plan B is not going well, we'll need to fallback to JSON templates, which makes me arrrr...
My methods for verifying whether our Redfish implementation works mainly involve ad-hoc curl commands, but that might not be sufficient. I know KubeVirtBMC is far from a certified/validated Redfish device, but I'll try to make it as close as possible. Right now, I'll try to drop it into the workflow of the Tinkerbell use case and see what will happen.
Rufio is complaining about the returned Redfish ComputerSystem resource:
{"level":"error","controller":"machine","controllerGroup":"bmc.tinkerbell.org","controllerKind":"Machine","Machine":{"name":"machine-1","namespace":"tink-system"},"namespace":"tink-system","name":"mac
hine-1","reconcileID":"99daf185-ae31-4907-85de-081315bbd0e9","error":"get power state: 2 errors occurred:\n\t* provider: gofish: failed to retrieve some items: [{\"link\":\"/redfish/v1/Systems/1\",\"e
rror\":\"json: cannot unmarshal object into Go struct field .OperatingSystem of type string\"}]\n\t* failed to get power state\n\n","logger":"controllers/Machine","host":"default-machine-1-virtbmc.172
.19.31.240.sslip.io","caller":"/workspace/controller/machine.go:149","time":"2024-11-20T14:16:12Z","message":"failed to get Machine power state"}
Rufio is complaining about the returned Redfish ComputerSystem resource...
So the "OperatingSystem"-unmarshalling issue was raised in stmcginnis/gofish#364 and has already been fixed on the main branch (not yet shipped in any releases). But Rufio v0.5.2 depends on bmclib v2.3.4, which depends on gofish v0.19.0. It's relatively complex for us to build everything ourselves just for a working demo.
We can wait for those projects to bump their dependencies eventually. In the meantime, I'll try to modify the generated model and implementation of KubeVirtBMC to see if that's the only issue. I'll also look into Metal3 as a possible replacement for the demo.
Well, after I modified the OperatingSystem
field from the OdataV4IdRef
to the string
type, Rufio can successfully contact the virtBMC via the Redfish protocol. Hooray!
This should be a temporary fix and will be corrected once the upstream fix is released.
There are many more functionalities yet to be implemented, including
/redfish/v1/$metadata
and /redfish/v1/odata
URIs, respectivelyhttps://redfishforum.com/post/1907/thread
$metadata is only a necessity for OData-based clients.
According to the section 8.4.1 in the Redfish specification 1.21.0,
... Clients are not required to request metadata if they already have sufficient understanding of the target service...
we can lower the priority of the OData-related functionalities since we're not focusing on providing the Redfish service to OData clients.
Is your feature request related to a problem? Please describe.
Currently, KubeBMC only supports limited IPMI functionalities for KubeVirt VMs. It would also be helpful to support Redfish as it is newer, feature-rich, and gradually becomes dominant in such areas.
Describe the solution you'd like
A set of Redfish APIs that supports users to communicate with to instruct KubeBMC to:
for KubeVirt VMs.
Describe alternatives you've considered
N/A
Additional context
We could implement the following resources to provide a minimum viable functionalities. Kudos to @rwleea!