Bug 2159680

Summary: Traceback raised by tuned when busctl/dbus-send is used with nonsense (typo) command.
Product: Red Hat Enterprise Linux 9 Reporter: Robin Hack <rhack>
Component: tunedAssignee: Jaroslav Škarvada <jskarvad>
Status: CLOSED ERRATA QA Contact: Robin Hack <rhack>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.2CC: fsumsal, jeder, jskarvad, systemd-maint-list
Target Milestone: rcKeywords: AutoVerified, Patch, TestCaseNeeded, Triaged, Upstream
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tuned-2.20.0-0.1.rc1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-09 08:26:31 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Robin Hack 2023-01-10 11:39:51 UTC
Description of problem:


Version-Release number of selected component (if applicable):
systemd-252-2.el9.x86_64

How reproducible:
always


Steps to Reproduce:
busctl --system call com.redhat.tuned '/Tuned' com.redhat.tuned.contro active_profile

(missing letter 'l' in word control)

Actual results:
Call failed: Traceback (most recent call last):
  File "/usr/lib64/python3.9/site-packages/dbus/service.py", line 662, in _message_cb
    (candidate_method, parent_method) = _method_lookup(self, method_name, interface_name)
  File "/usr/lib64/python3.9/site-packages/dbus/service.py", line 252, in _method_lookup
    raise UnknownMethodException('%s is not a valid method of interface %s' % (method_name, dbus_interface))
dbus.exceptions.UnknownMethodException: org.freedesktop.DBus.Error.UnknownMethod: Unknown method: active_profile is not a valid method of interface com.redhat.tuned.contro


Expected results:
Something nice and not traceback?


Additional info:

Comment 1 Frantisek Sumsal 2023-01-10 12:06:43 UTC
The traceback is not from busctl (which is written in C using sd-bus), but from tuned (or, more specifically, the dbus Python library it uses), we just show what the remote side sent us:

# SYSTEMD_LOG_LEVEL=debug busctl --system --verbose call com.redhat.tuned '/Tuned' com.redhat.tuned.contro active_profileq 
Bus n/a: changing state UNSET → OPENING
sd-bus: starting bus by connecting to /run/dbus/system_bus_socket...
Bus n/a: changing state OPENING → AUTHENTICATING
Bus n/a: changing state AUTHENTICATING → HELLO
Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=Hello cookie=1 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a
Got message type=method_return sender=org.freedesktop.DBus destination=:1.39 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=1 signature=s error-name=n/a error-message=n/a
Bus n/a: changing state HELLO → RUNNING
Sent message type=method_call sender=n/a destination=com.redhat.tuned path=/Tuned interface=com.redhat.tuned.contro member=active_profileq cookie=2 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a
Got message type=error sender=:1.34 destination=:1.39 path=n/a interface=n/a member=n/a cookie=9 reply_cookie=2 signature=s error-name=org.freedesktop.DBus.Error.UnknownMethod error-message=Traceback (most recent call last):
  File "/usr/lib64/python3.9/site-packages/dbus/service.py", line 662, in _message_cb
    (candidate_method, parent_method) = _method_lookup(self, method_name, interface_name)
  File "/usr/lib64/python3.9/site-packages/dbus/service.py", line 252, in _method_lookup
    raise UnknownMethodException('%s is not a valid method of interface %s' % (method_name, dbus_interface))
dbus.exceptions.UnknownMethodException: org.freedesktop.DBus.Error.UnknownMethod: Unknown method: active_profileq is not a valid method of interface com.redhat.tuned.contro
Call failed: Traceback (most recent call last):
  File "/usr/lib64/python3.9/site-packages/dbus/service.py", line 662, in _message_cb
    (candidate_method, parent_method) = _method_lookup(self, method_name, interface_name)
  File "/usr/lib64/python3.9/site-packages/dbus/service.py", line 252, in _method_lookup
    raise UnknownMethodException('%s is not a valid method of interface %s' % (method_name, dbus_interface))
dbus.exceptions.UnknownMethodException: org.freedesktop.DBus.Error.UnknownMethod: Unknown method: active_profileq is not a valid method of interface com.redhat.tuned.contro
Bus n/a: changing state RUNNING → CLOSED

I'm not sure if that's expected behavior or not, so reassigning to tuned folks.

Comment 2 Frantisek Sumsal 2023-01-10 12:12:41 UTC
You can also trigger the same traceback using the dbus-send utility:

# dbus-send --print-reply --system --type=method_call --dest=com.redhat.tuned /Tuned com.redhat.tuned.contro.active_profileq 
Error org.freedesktop.DBus.Error.UnknownMethod: Traceback (most recent call last):
  File "/usr/lib64/python3.9/site-packages/dbus/service.py", line 662, in _message_cb
    (candidate_method, parent_method) = _method_lookup(self, method_name, interface_name)
  File "/usr/lib64/python3.9/site-packages/dbus/service.py", line 252, in _method_lookup
    raise UnknownMethodException('%s is not a valid method of interface %s' % (method_name, dbus_interface))
dbus.exceptions.UnknownMethodException: org.freedesktop.DBus.Error.UnknownMethod: Unknown method: active_profileq is not a valid method of interface com.redhat.tuned.contro

Comment 3 Robin Hack 2023-01-10 12:35:28 UTC
(In reply to Frantisek Sumsal from comment #2)
> You can also trigger the same traceback using the dbus-send utility:
> 
> # dbus-send --print-reply --system --type=method_call
> --dest=com.redhat.tuned /Tuned com.redhat.tuned.contro.active_profileq 
> Error org.freedesktop.DBus.Error.UnknownMethod: Traceback (most recent call
> last):
>   File "/usr/lib64/python3.9/site-packages/dbus/service.py", line 662, in
> _message_cb
>     (candidate_method, parent_method) = _method_lookup(self, method_name,
> interface_name)
>   File "/usr/lib64/python3.9/site-packages/dbus/service.py", line 252, in
> _method_lookup
>     raise UnknownMethodException('%s is not a valid method of interface %s'
> % (method_name, dbus_interface))
> dbus.exceptions.UnknownMethodException:
> org.freedesktop.DBus.Error.UnknownMethod: Unknown method: active_profileq is
> not a valid method of interface com.redhat.tuned.contro

Yes. I reported bug to dbus-send too.

Ok. So tuned it is. Thanks.

Comment 4 Robin Hack 2023-01-10 12:37:05 UTC
*** Bug 2159665 has been marked as a duplicate of this bug. ***

Comment 5 Robin Hack 2023-01-10 12:38:41 UTC
Another way how to reproduce:

# dbus-send --system --print-reply --type=method_call --dest='com.redhat.tuned' '/Tuned' com.redhat.tuned.control.list_profiles
(list_profiles is nonsense here)

Comment 6 Jaroslav Škarvada 2023-01-12 01:04:06 UTC
Yep it's not traceback from the application using the TuneD D-Bus API but the way how the D-Bus library used by TuneD handles errors. For some reason the developers of the library thought that handling errors by tracebacks and sending these tracebacks through the D-Bus is a good idea. This maybe useful for debugging of bugs in the library, but it's absolutely useless in production and can be confusing for users, i.e. the user of the application which uses TuneD D-Bus API doesn't need to know that the UnknownMethod error was handled by the line 659 of the service.py. All what does she or he needs to know is that they misused the API and called non existent method.

Unfortunately, it doesn't seem there is a simple way how to disable this behavior. I have to use hackish approach with monkey patching of the D-Bus library. Now it only returns tracebacks if TuneD is running in the debug mode. It now also works with the type errors and others, e.g.:

# dbus-send --system --print-reply --type=method_call --dest='com.redhat.tuned' '/Tuned' com.redhat.tuned.control.switch_profile
Error org.freedesktop.DBus.Python.TypeError: TypeError: switch_profile() missing 1 required positional argument: 'profile_name'

I.e. the switch_profile takes argument which the caller didn't provide.

And when the TuneD daemon is running in the debug mode:
# dbus-send --system --print-reply --type=method_call --dest='com.redhat.tuned' '/Tuned' com.redhat.tuned.control.switch_profile
Error org.freedesktop.DBus.Python.TypeError: Traceback (most recent call last):
  File "/usr/lib64/python3.11/site-packages/dbus/service.py", line 712, in _message_cb
    retval = candidate_method(self, *args, **keywords)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: switch_profile() missing 1 required positional argument: 'profile_name'

Upstream PR:
https://github.com/redhat-performance/tuned/pull/489

Comment 9 Jaroslav Škarvada 2023-02-08 15:29:48 UTC
Upstream PR:
https://github.com/redhat-performance/tuned/pull/489

Comment 19 errata-xmlrpc 2023-05-09 08:26:31 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (tuned bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2585