Brief Description
-----------------
From the O-RAN O2 interface's Watcher module, a Fault Management API call to StarlingX server to get the Alarm details of a non-existing Alarm ID(old alarm) is returning 500 HTTP Internal Server Error instead of the 404 HTTP Not Found exception.
Severity
--------
Critical as per O-RAN specifications
Steps to Reproduce
------------------
With a valid keystone token($OS_TOKEN) send a GET alarm request with invalid ID as shown below:-
curl -g -i --insecure -X GET http://<server IP:port>/v1/alarms/1532e62c-f04c-48ef-823b-7cfa432722a0 -H "Content-Type: application/json" -H "User-Agent: python-fmclient" -H "X-Auth-Token: $OS_TOKEN"
Expected Behavior
------------------
404 HTTP Not Found
Actual Behavior
----------------
500 HTTP Error
Reproducibility
---------------
100%
Timestamp/Logs
--------------
Log of O-RAN O2 Watcher:-
2023-12-11 08:42:32,772:[urllib3.connectionpool]:[connectionpool.py]-[456] [DEBUG]:http://10.10.10.11:18002 "GET /v1/alarms/1532e62c-f04c-48ef-823b-7cfa432722a0 HTTP/1.1" 500 0
2023-12-11 08:42:32,772:[keystoneauth.session]:[session.py]-[550] [DEBUG]:RESP: [500] content-length: 0 content-type: text/plain date: Mon, 11 Dec 2023 08:42:32 GMT
2023-12-11 08:42:32,772:[fmclient.common.http]:[http.py]-[101] [ERROR]:Request returned failure status 500.
2023-12-11 08:42:32,772:[o2common.service.watcher.base]:[base.py]-[48] [WARNING]:Failed to probe alarm watcher due to: <class 'fmclient.common.exceptions.HttpServerError'> - HTTP Server Error (HTTP 500)
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor [req-a60767a9-04af-4c56-aa8b-f796ff0fd4df 6bf166da41134647b04826dc900c779a b139a637ac38407f94e3e08fc7372157 default - -] Exception in AuditLogging passed to event 'on_error': 'AlarmNotFound' object has no attribute 'value': AttributeError: 'AlarmNotFound' object has no attribute 'value'
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor Traceback (most recent call last):
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor File "/usr/lib/python3/dist-packages/fm/db/sqlalchemy/api.py", line 207, in alarm_get
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor result = query.one()
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor File "/usr/lib/python3/dist-packages/sqlalchemy/orm/query.py", line 3500, in one
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor raise orm_exc.NoResultFound("No row was found for one()")
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor sqlalchemy.orm.exc.NoResultFound: No row was found for one()
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor During handling of the above exception, another exception occurred:
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor Traceback (most recent call last):
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor File "/usr/lib/python3/dist-packages/wsmeext/pecan.py", line 84, in callfunction
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor result = f(self, *args, **kwargs)
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor File "/usr/lib/python3/dist-packages/fm/api/controllers/v1/alarm.py", line 341, in get_one
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor rpc_ialarm = objects.alarm.get_by_uuid(
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor File "/usr/lib/python3/dist-packages/oslo_versionedobjects/base.py", line 184, in wrapper
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor result = fn(cls, context, *args, **kwargs)
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor File "/usr/lib/python3/dist-packages/fm/objects/alarm.py", line 66, in get_by_uuid
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor return cls.dbapi.alarm_get(uuid)
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor File "/usr/lib/python3/dist-packages/fm/objects/__init__.py", line 23, in wrapper
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor result = fn(*args, **kwargs)
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor File "/usr/lib/python3/dist-packages/fm/db/sqlalchemy/api.py", line 209, in alarm_get
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor raise exceptions.AlarmNotFound(alarm=uuid)
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor fm.common.exceptions.AlarmNotFound: <unprintable AlarmNotFound object>
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor During handling of the above exception, another exception occurred:
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor Traceback (most recent call last):
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor File "/usr/lib/python3/dist-packages/pecan/core.py", line 683, in __call__
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor self.invoke_controller(controller, args, kwargs, state)
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor File "/usr/lib/python3/dist-packages/pecan/core.py", line 574, in invoke_controller
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor result = controller(*args, **kwargs)
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor File "/usr/lib/python3/dist-packages/wsmeext/pecan.py", line 108, in callfunction
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor data = wsme.api.format_exception(
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor File "/usr/lib/python3/dist-packages/wsme/api.py", line 219, in format_exception
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor else six.text_type(error))
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor File "/usr/lib/python3/dist-packages/fm/common/exceptions.py", line 41, in __str__
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor return repr(self.value)
2023-12-11 08:44:59.145 8351 ERROR fm.api.hooks.auditor AttributeError: 'AlarmNotFound' object has no attribute 'value'
Test Activity
-------------
Conformance Testing for O-RAN O2 interface
Workaround
----------
Change O2 code to handle 500 Exception.
Solution
---------
In https://opendev.org/starlingx/fault/src/branch/master/fm-rest-api/fm/fm/common/exceptions.py#L41, the 'value' attribute is incorrect due to which the error is occurring. Please rectify it.
No other response code, except HTTP 200, seems to be working properly.