utils: fix extra slash in Redfish default systems url path#10630
utils: fix extra slash in Redfish default systems url path#10630DaanHoogland merged 4 commits intoapache:4.20from
Conversation
This removes extra slash from the base system url in Redfish oobm client utility. Fixes apache#10441 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
|
Requesting @kiranchavala for any quick tips, review & tests. Also cc @Pearl1594 @DaanHoogland @andrijapanicsb @steveroles |
utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java
Show resolved
Hide resolved
|
@blueorangutan package |
|
@rohityadavcloud a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.20 #10630 +/- ##
=========================================
Coverage 16.01% 16.02%
- Complexity 13110 13127 +17
=========================================
Files 5652 5652
Lines 495845 495928 +83
Branches 60046 60056 +10
=========================================
+ Hits 79409 79451 +42
- Misses 407574 407612 +38
- Partials 8862 8865 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue with an extra slash in the Redfish default systems URL path used by the OOBM client utility.
- Removed the trailing slash from the base systems URL.
- Updated the URL composition in both the main client code and its corresponding tests.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| utils/src/test/java/org/apache/cloudstack/utils/redfish/RedfishClientTest.java | Updated test constants and expected URL strings to reflect the removal of the trailing slash. |
| utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java | Adjusted the URL constants and string concatenation to correctly format the request URL without the extra slash. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12913 |
|
@blueorangutan test |
|
@rohityadavcloud a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian Build Failed (tid-12841) |
kiranchavala
left a comment
There was a problem hiding this comment.
getting the following exception
2025-03-28 10:48:38,052 ERROR [c.c.a.ApiAsyncJobDispatcher] (API-Job-Executor-32:[ctx-1ed229cb, job-40]) (logid:75fbfd7a) Unexpected exception while executing org.apache.cloudstack.api.command.admin.outofbandmanagement.IssueOutOfBandManagementPowerActionCmd java.lang.IllegalStateException: This is not a JSON Object.
[root@ref-trl-8237-k-Mol8-kiran-chavala-mgmt1 ~]# cat /var/log/cloudstack/management/management-server.log |grep -i "logid:75fbfd7a"
2025-03-28 10:48:38,016 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl$5] (API-Job-Executor-32:[ctx-1ed229cb, job-40]) (logid:75fbfd7a) Executing AsyncJob {"accountId":2,"cmd":"org.apache.cloudstack.api.command.admin.outofbandmanagement.IssueOutOfBandManagementPowerActionCmd","cmdInfo":"{\"response\":\"json\",\"ctxUserId\":\"2\",\"sessionkey\":\"ACPGChmkdLjBVz9y7ogyTXjzkkU\",\"action\":\"OFF\",\"hostid\":\"f4fe4f90-1e3b-4c5f-974e-e9d48e5e4c52\",\"httpmethod\":\"GET\",\"ctxStartEventId\":\"177\",\"ctxDetails\":\"{\\\"interface com.cloud.host.Host\\\":\\\"f4fe4f90-1e3b-4c5f-974e-e9d48e5e4c52\\\"}\",\"ctxAccountId\":\"2\",\"cmdEventType\":\"HOST.OOBM.ACTION\"}","cmdVersion":0,"completeMsid":null,"created":null,"id":40,"initMsid":32989224370467,"instanceId":1,"instanceType":"Host","lastPolled":null,"lastUpdated":null,"processStatus":0,"removed":null,"result":null,"resultCode":0,"status":"IN_PROGRESS","userId":2,"uuid":"75fbfd7a-84ee-484e-8744-121d82949182"}
2025-03-28 10:48:38,041 WARN [o.a.c.m.w.WebhookServiceImpl] (API-Job-Executor-32:[ctx-1ed229cb, job-40, ctx-291cbd2e]) (logid:75fbfd7a) Skipping delivering event Event {"description":"{\"details\":\"Host Id: 1 Action: OFF\",\"event\":\"HOST.OOBM.ACTION\",\"status\":\"Completed\"}","eventId":null,"eventType":"HOST.OOBM.ACTION","eventUuid":null,"resourceType":"Host","resourceUUID":null} to any webhook as account ID is missing
2025-03-28 10:48:38,042 WARN [o.a.c.f.e.EventDistributorImpl] (API-Job-Executor-32:[ctx-1ed229cb, job-40, ctx-291cbd2e]) (logid:75fbfd7a) Failed to publish event [category: ActionEvent, type: HOST.OOBM.ACTION] on bus webhookEventBus
2025-03-28 10:48:38,052 ERROR [c.c.a.ApiAsyncJobDispatcher] (API-Job-Executor-32:[ctx-1ed229cb, job-40]) (logid:75fbfd7a) Unexpected exception while executing org.apache.cloudstack.api.command.admin.outofbandmanagement.IssueOutOfBandManagementPowerActionCmd java.lang.IllegalStateException: This is not a JSON Object.
2025-03-28 10:48:38,053 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl] (API-Job-Executor-32:[ctx-1ed229cb, job-40]) (logid:75fbfd7a) Complete async job-40, jobStatus: FAILED, resultCode: 530, result: org.apache.cloudstack.api.response.ExceptionResponse/null/{"uuidList":[],"errorcode":"530","errortext":"This is not a JSON Object."}
2025-03-28 10:48:38,054 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl] (API-Job-Executor-32:[ctx-1ed229cb, job-40]) (logid:75fbfd7a) Publish async job-40 complete on message bus
2025-03-28 10:48:38,054 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl] (API-Job-Executor-32:[ctx-1ed229cb, job-40]) (logid:75fbfd7a) Wake up jobs related to job-40
2025-03-28 10:48:38,054 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl] (API-Job-Executor-32:[ctx-1ed229cb, job-40]) (logid:75fbfd7a) Update db status for job-40
2025-03-28 10:48:38,055 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl] (API-Job-Executor-32:[ctx-1ed229cb, job-40]) (logid:75fbfd7a) Wake up jobs joined with job-40 and disjoin all subjobs created from job- 40
2025-03-28 10:48:38,062 DEBUG [c.c.a.ApiServer] (API-Job-Executor-32:[ctx-1ed229cb, job-40]) (logid:75fbfd7a) Retrieved cmdEventType from job info: HOST.OOBM.ACTION
2025-03-28 10:48:38,064 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl$5] (API-Job-Executor-32:[ctx-1ed229cb, job-40]) (logid:75fbfd7a) Done executing org.apache.cloudstack.api.command.admin.outofbandmanagement.IssueOutOfBandManagementPowerActionCmd for job-40
2025-03-28 10:48:38,064 INFO [o.a.c.f.j.i.AsyncJobMonitor] (API-Job-Executor-32:[ctx-1ed229cb, job-40]) (logid:75fbfd7a) Remove job-40 from job monitoring
wido
left a comment
There was a problem hiding this comment.
CLGTM
Changes look good, thanks!
Fix the code to read all of the json content and now just upto newline :facepalm: Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13056 |
|
@blueorangutan test |
|
@rohityadavcloud a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
kiranchavala
left a comment
There was a problem hiding this comment.
Found the following issues when testing
- If the port is configured as 8000 , Cloudstack sends the request on the default port 80
- Cloudstack should send a POST request to control the hardware , currently we are sending only GET request
Example :
[root@ref-trl-8237-k-Mol8-kiran-chavala-kvm1 ~]# curl -s http://10.0.32.140:8000/redfish/v1/Systems/148a3231-209a-49ce-a8a9-b973dbb623c6
It supports the following operations
"Actions": {
"#ComputerSystem.Reset": {
"target": "/redfish/v1/Systems/148a3231-209a-49ce-a8a9-b973dbb623c6/Actions/ComputerSystem.Reset",
"ResetType@Redfish.AllowableValues": [
"On",
"ForceOff",
"GracefulShutdown",
"GracefulRestart",
"ForceRestart",
"Nmi",
"ForceOn"
]
}
},
curl -s -d '{"ResetType":"ForceOff"}' -H "Content-Type: application/json" -X POST http://$REDFISH_HOST:$REDFISH_PORT/redfish/v1/Systems/$REDFISH_SYSTEM/Actions/ComputerSystem.Reset
curl -s -d '{"ResetType":"ForceOn"}' -H "Content-Type: application/json" -X POST http://$REDFISH_HOST:$REDFISH_PORT/redfish/v1/Systems/$REDFISH_SYSTEM/Actions/ComputerSystem.Reset
I have followed the following blogs to test post request
|
[SF] Trillian test result (tid-13014)
|
|
Thanks @kiranchavala The issue 1 you've raised is a known problem as generally redfish is only on 443/https (when the global setting is on, it only works with 443/https). I've logged this issue for future fix #10742 2 is easily fixable but I don't know if it's a real-world issue or an issue with the emulator. @wido @GabrielBrascher do you remember or know if the redfish based servers you've, use GET or POST for actions (power operations including status checks)? |
thanks @rohityadavcloud According to the official redfish API reference guide , post request is used pg 59 in https://www.dmtf.org/sites/default/files/standards/documents/DSP0266_1.6.0.pdf |
This fixes the error message when Redfish doesn't support power related POST requests. Also fixes an NPE edge case discovered via the emulator. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
|
Thanks @kiranchavala I double checked, I think the problem is in your setup. The error message wasn't clear so I've pushed a commit, it was actually sending a POST request but the emulator isn't supporting them. The default emulator mode is static and states here https://github.com/DMTF/Redfish-Interface-Emulator?tab=readme-ov-file#static-emulation-of-a-mockup that Now, the error will say this when it happens:
Using the emulator, the dynamic one seems to be supporting POST requests: Maybe could you also try/test against the sushy tools? @blueorangutan package |
|
@rohityadavcloud a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Tested with:
On mac did this: |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13087 |
|
@blueorangutan test |
|
@rohityadavcloud a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
kiranchavala
left a comment
There was a problem hiding this comment.
LGTM, Tested with the following emulators and Cloudstack is sending the correct POST request
https://github.com/DMTF/Redfish-Interface-Emulator
https://github.com/openstack/sushy-tools/tree/master/sushy_tools/emulator
LOGS for DTMF
2025-04-17 08:49:24,832 DEBUG [o.a.c.u.r.RedfishClient] (API-Job-Executor-1:[ctx-24843844, job-62, ctx-67948a30]) (logid:6b7a8269) Sending ComputerSystem.Reset Command 'GracefulShutdown' to host '10.0.32.140' with request 'POST http://10.0.32.140/redfish/v1/Systems/System-1/Actions/ComputerSystem.Reset'
2025-04-17 08:52:24,201 DEBUG [o.a.c.u.r.RedfishClient] (API-Job-Executor-2:[ctx-0054bdcc, job-63, ctx-660040bc]) (logid:85f4142f) Sending ComputerSystem.Reset Command 'On' to host '10.0.32.140' with request 'POST http://10.0.32.140/redfish/v1/Systems/System-1/Actions/ComputerSystem.Reset'
2025-04-17 08:53:07,955 DEBUG [o.a.c.u.r.RedfishClient] (API-Job-Executor-3:[ctx-94a92e90, job-64, ctx-74bac251]) (logid:47a5a05e) Sending ComputerSystem.Reset Command 'PowerCycle' to host '10.0.32.140' with request 'POST http://10.0.32.140/redfish/v1/Systems/System-1/Actions/ComputerSystem.Reset'
2025-04-17 08:53:46,461 DEBUG [o.a.c.u.r.RedfishClient] (API-Job-Executor-4:[ctx-fa2d589c, job-65, ctx-b67d16fa]) (logid:56520d5e) Sending ComputerSystem.Reset Command 'ForceRestart' to host '10.0.32.140' with request 'POST http://10.0.32.140/redfish/v1/Systems/System-1/Actions/ComputerSystem.Reset'
2025-04-17 08:55:59,417 DEBUG [o.a.c.u.r.RedfishClient] (API-Job-Executor-5:[ctx-e0480ddb, job-66, ctx-7fa91049]) (logid:aa398dc4) Sending ComputerSystem.Reset Command 'GracefulShutdown' to host '10.0.32.140' with request 'POST http://10.0.32.140/redfish/v1/Systems/System-1/Actions/ComputerSystem.Reset'
2025-04-17 08:56:57,601 DEBUG [o.a.c.u.r.RedfishClient] (API-Job-Executor-6:[ctx-310053aa, job-67, ctx-7d3ef831]) (logid:13c86fa5) Retrieved System ID 'System-1' with request 'GET: http://10.0.32.140/redfish/v1/Systems'
2025-04-17 08:56:57,605 DEBUG [o.a.c.u.r.RedfishClient] (API-Job-Executor-6:[ctx-310053aa, job-67, ctx-7d3ef831]) (logid:13c86fa5) Retrieved System power state 'On' with request 'GET: http://10.0.32.140/redfish/v1/Systems/System-1'
Sushy tool
2025-04-17 09:18:52,658 DEBUG [o.a.c.u.r.RedfishClient] (API-Job-Executor-7:[ctx-4db9f593, job-68, ctx-9d1e43cd]) (logid:c1f7b01c) Sending ComputerSystem.Reset Command 'GracefulShutdown' to host '10.0.32.140' with request 'POST http://10.0.32.140/redfish/v1/Systems/2d75be19-84fe-41a8-9a9e-111c28b0ea9a/Actions/ComputerSystem.Reset'
2025-04-17 09:20:15,604 DEBUG [o.a.c.u.r.RedfishClient] (API-Job-Executor-8:[ctx-4d7c918c, job-69, ctx-38e7cd37]) (logid:5e0c53ad) Sending ComputerSystem.Reset Command 'On' to host '10.0.32.140' with request 'POST http://10.0.32.140/redfish/v1/Systems/2d75be19-84fe-41a8-9a9e-111c28b0ea9a/Actions/ComputerSystem.Reset'
2025-04-17 09:22:42,301 DEBUG [o.a.c.u.r.RedfishClient] (API-Job-Executor-9:[ctx-5d5b161d, job-70, ctx-156bac08]) (logid:9a065e18) Sending ComputerSystem.Reset Command 'PowerCycle' to host '10.0.32.140' with request 'POST http://10.0.32.140/redfish/v1/Systems/2d75be19-84fe-41a8-9a9e-111c28b0ea9a/Actions/ComputerSystem.Reset'
2025-04-17 09:23:38,048 DEBUG [o.a.c.u.r.RedfishClient] (API-Job-Executor-10:[ctx-c1b96157, job-71, ctx-5e030896]) (logid:dadd195f) Sending ComputerSystem.Reset Command 'ForceRestart' to host '10.0.32.140' with request 'POST http://10.0.32.140/redfish/v1/Systems/2d75be19-84fe-41a8-9a9e-111c28b0ea9a/Actions/ComputerSystem.Reset
2025-04-17 09:24:22,849 DEBUG [o.a.c.u.r.RedfishClient] (API-Job-Executor-11:[ctx-e35a4a38, job-72, ctx-8e74fbce]) (logid:34220137) Sending ComputerSystem.Reset Command 'GracefulShutdown' to host '10.0.32.140' with request 'POST http://10.0.32.140/redfish/v1/Systems/2d75be19-84fe-41a8-9a9e-111c28b0ea9a/Actions/ComputerSystem.Reset'
2025-04-17 09:24:48,304 DEBUG [o.a.c.u.r.RedfishClient] (API-Job-Executor-12:[ctx-ee26da42, job-73, ctx-d7ab286c]) (logid:79af02f4) Retrieved System power state 'Off' with request 'GET: http://10.0.32.140/redfish/v1/Systems/2d75be19-84fe-41a8-9a9e-111c28b0ea9a'
|
Please merge this as/when you may @Pearl1594 @DaanHoogland |
we cannot know/test against all hardware, merging. |
|
[SF] Trillian test result (tid-13032)
|
* 4.20: utils: fix extra slash in Redfish default systems url path (#10630)




This removes extra slash from the base system url in Redfish oobm client utility.
Fixes #10441
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity