Affects Version/s: 3.10.0b1
Fix Version/s: None
Component/s: Built-in functions
Although since cfengine 3.8 we have nice function url_get, old function readtcp still usefull for check plain tcp. Accordingly readtcp doc:
"The return value is cached."
But if tcp port unavailable, this negative result did not cached.
- ftpd on port 21
- nothing on port 666
- cf-agent -K -f unit_test_readtcp.cf
R: unit_test_readtcp : class server_21_ok detected
R: unit_test_readtcp : port_21: 220 ProFTPD
R: unit_test_readtcp : class server_666_wrong detected
R: unit_test_readtcp : port_666: not available
Positive result is cached as expected:
- cf-agent -K -f unit_test_readtcp.cf -v | grep "Connecting to host localhost, port 21 as address 127.0.0.1" | wc -l
Negative result did not cached:
- cf-agent -K -f unit_test_readtcp.cf -v | grep "Connecting to host localhost, port 666 as address 127.0.0.1" | wc -l
In case of a huge number of checked ports/servers we have a very large number of tries.