Bug 7863 - vsmserver crashes and dies on too long agent hostname
Summary: vsmserver crashes and dies on too long agent hostname
Status: CLOSED FIXED
Alias: None
Product: ThinLinc
Classification: Unclassified
Component: VSM Server (show other bugs)
Version: trunk
Hardware: PC Unknown
: P2 Normal
Target Milestone: 4.16.0
Assignee: Pierre Ossman
URL:
Keywords: adaha_tester, prosaic
Depends on:
Blocks:
 
Reported: 2022-03-15 10:21 CET by Pierre Ossman
Modified: 2023-11-01 14:44 CET (History)
1 user (show)

See Also:
Acceptance Criteria:
MUST: * A sensible error message should be logged on invalid hostnames, not a traceback * The vsmserver service should continue working


Attachments

Description Pierre Ossman cendio 2022-03-15 10:21:01 CET
If I configure "LongName_60characters_1234567890_1234567890_1234567890_12345" as a hostname then I get this crash for vsmserver:

> Traceback (most recent call last):
>   File "/opt/thinlinc/sbin/vsmserver", line 18, in <module>
>     OOoOoo000O00 ( )
>   File "/opt/thinlinc/sbin/vsmserver", line 15, in OOoOoo000O00
>     VSMServer ( sys . argv )
>   File "/opt/thinlinc/modules/thinlinc/vsm/vsmserver.py", line 168, in __init__
>     self . loop ( )
>   File "/opt/thinlinc/modules/thinlinc/vsm/asyncbase.py", line 426, in loop
>     OooO0O00o0 = self . run_delayed_calls ( )
>   File "/opt/thinlinc/modules/thinlinc/vsm/asyncbase.py", line 384, in run_delayed_calls
>     I1I1IIi1IIIi . func ( * I1I1IIi1IIIi . args , ** I1I1IIi1IIIi . kw )
>   File "/opt/thinlinc/modules/thinlinc/vsm/loadbalancer.py", line 196, in periodic_update
>     GetLoadCall ( OO00OOooO , ii , self . periodic_update ,
>   File "/opt/thinlinc/modules/thinlinc/vsm/call_getload.py", line 25, in __init__
>     self . xmlrpc_call ( 'get_load' )
>   File "/opt/thinlinc/modules/thinlinc/vsm/xmlrpc.py", line 335, in xmlrpc_call
>     self . create_xmlrpc_call ( methodname , params )
>   File "/opt/thinlinc/modules/thinlinc/vsm/xmlrpc.py", line 363, in create_xmlrpc_call
>     oO0 += b"Host: " + self . url [ 1 ] . encode ( "idna" ) + b"\r\n"
> UnicodeError: encoding with 'idna' codec failed (UnicodeError: label too long)

This should of course be handled better. It is also extra concerning that it brings down the entire vsmserver and not just fails to communicate with that agent.

Hopefully this rarely happens in practice as this limit is a DNS thing and not imposed by ThinLinc or Python. As such there should be no machines configured this way.

Seen while testing 4.14.0post on Ubuntu 20.04.
Comment 1 Pierre Ossman cendio 2023-10-27 10:40:03 CEST
As of bug 8224, this is now much more well-behaved:

> 2023-10-27 10:34:29 WARNING vsmserver.loadinfo: Error getting load from agent LongName_60characters_1234567890_1234567890_1234567890_1234567890: encoding with 'idna' codec failed (UnicodeError: label too long)
> 2023-10-27 10:34:29 WARNING vsmserver.loadinfo: Marking agent LongName_60characters_1234567890_1234567890_1234567890_1234567890 as down

(Note that I had to use a longer name than what was given in the initial description.)
Comment 2 Adam Halim cendio 2023-11-01 14:44:44 CET
It seems like the switch to asyncio in r40451 stopped the service from dying when using the hostname example as in comment #0, but with a hostname that is 100 characters long.

For the traceback, it seems to have been removed in r40496 (once again, using the same example).

> MUST:
> * A sensible error message should be logged on invalid hostnames, not a traceback  ✓
> * The vsmserver service should continue working ✓
Looks good, closing.

Note You need to log in before you can comment on or make changes to this bug.