clients: update clients to timeout in 10 secs, try SSL#2847
clients: update clients to timeout in 10 secs, try SSL#2847jimklimov merged 35 commits intonetworkupstools:masterfrom
Conversation
|
Thanks. I presume you saw comments to PR #85 which tackled this matter before? At least, yours does use Also, this deserves entries in |
No, I hadn't searched back that far :)... I just had a machine go offline and all my upsmon's starting failing the watchdog and restarting (which failed their heartbeats)... (and my checkmk agents started stalling on
Well, several of the clients use '-t seconds' for a command completion timeout... do you want me to apply that timeout to the connect part too? Environment config would be possible, but that gets into a much more involved "one per client vs unified client default vs nutclient.so library default vs ???" I didn't add "alarms" to the network transport part of the program (like upsmon has), but I guess that's possible too...
OK, I'll put something in them once we've got a consensus on what we're doing :) |
|
I think Alternately, maybe better, As for defaulting, I suppose there can be a new method in The same method can be called to handle config file options, if any are provided (so maybe calling it twice, or with two args either or both of which can be null). Two args would help establish priorities better (built-in, config file, envvar, CLI option). |
'W' appears available for all the clients; matching the
So you're thinking something like: which can be called multiple times, and if opt_val/config_val are non-NULL they "update" the internal timeout, and later calls to get_default_timeout(NULL, NULL, &tv) will return the latest value? |
|
Actually, would it not be simpler to just have upscli_connect() just honor the default timeout? Then it's as easy as: The timeout is unset at startup, so current library users don't see a change. All nut client tools could have the new option, always call upscli_set_default_timeout() and get network timeouts with no further updates. The timeout could also apply to all network traffic (not just connect) and make clients easier to maintain. Most clients would never even call upscli_get_default_timeout()... UPSCLI_DEFAULT_TIMEOUT could be in a common nut tool header somewhere, but isn't really in the library (which has no default) Option ==> UPSCLI_DEFAULT_TIMEOUT is the new global default, but can be turned off with upscli_set_default_timeout(NULL) |
|
As a trial, I added the api above and updated upsc (only) to use it with option -W (option -W 0 sets no timeout) |
Many clients currently have no network timeout; connections can take several minutes to fail (or longer if multiple addresses are resolved). Added upscli_set_default_timeout() to assign a default timeout, honored by upscli_connect(). Adds a 10 second timeout to all client connections. upsmon especially benefits from the patch as one unavailable ups could delay processing of other ups's, and also cause the watchdog to fire. upsc has a new option '-W <secs>' to set the network timeout. Many ups clients were also not attempting SSL, even ones that use authentication to perform actions. Patch adds flag to attempt (but not require) it. Signed-off-by: Scott Shambarger <devel@shambarger.net>
Well, my idea here was that this method selects the best default timeval from given sources that may be present or absent, and the program then keeps the variable and uses it for The idea with It may be even easier on processing (logic at least) somewhat, the method picks the best preferred non-NULL string and parses it into a number. MAYBE if the parsing fails, it takes the next best-liked string pointer and so on. Although then the
This method, per #85 discussion, should connect until the system reports a failure (e.g. TCP/IP stack timeout). If we have a soft timeout to consider, consumer code should (be changed to) use |
So I guess I'm unsure what the I guess I thought it would be nice to have a function that changed the timeouts for all network functions so that each client didn't have to "re-invent the wheel" with alarms or such (and not calling the function just keeps things the way they are now...)
So you think upsmon/upslog might need different network timeouts for different UPSs? That's flexible, but i wonder how many people would need different timeouts for each UPS... of course, just calling the xxx_default_timeout() before handling each UPS's network traffic could support that -- perhaps a more clearly named
Yeah, I couldn't quite figure out a good name though, since it's only the "DEFAULT" if you actually call the function :D
Wouldn't it be useful to have a parse error (on a parameter value for example) actually fail the command with a useful error message rather than a warning and ignoring it?
But that would still require clients to (a) pass the timeout value about, (b) apply it to alarms() etc to interrupt other network functions... upscli_tryconnect() is useful for explicit timeouts, but a nice function to set the "default" timeout would make the interface easier to use... |
|
BTW, it's worth noting that the Oddly, upscli_sendline(...) calls upscli_sendline_timeout(...,0) |
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
… of the method remaining as it was Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ale) Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…) to avoid dependency on env (locale) Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
The standard says that static-storage arithmetic values are pre-initialized to
zero implicitly, but better safe than sorry with all the compilers out there.
The X={0} spelling for aggregates of arithmetic entities to be zero-inited for
each component should be supported since at least C89 standard.
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…applied as such Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…any clients changed to 10-second default timeout instead of blocking [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…_TRYSSL [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…t_timeout to 0 [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…t to stress that "default network timeout" is about "initial connection" [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ONS" including the new "-W secs" [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…onnect_timeout [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
|
Regarding naming changes (hey, ain't known as one of the hardest problems in IT for nothing) - hopefully my work for this pass is done... if CI agrees. |
…g timeout for particular addrinfo [networkupstools#2847, networkupstools#85] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
|
Hm, that IP address printing misfired, will look at it later... or you can :) |
…etworkupstools#2847, networkupstools#85] Clang complained about explicit pointers: upsclient.c:1187:37: error: cast from 'struct sockaddr *' to 'struct sockaddr_in *' increases required alignment from 2 to 4 [-Werror,-Wcast-align] 1187 | struct sockaddr_in *addr_in = (struct sockaddr_in *)ai->ai_addr; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ upsclient.c:1192:39: error: cast from 'struct sockaddr *' to 'struct sockaddr_in6 *' increases required alignment from 2 to 4 [-Werror,-Wcast-align] 1192 | struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *)ai->ai_addr; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 errors generated. Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
|
❌ Build nut 2.8.2.2930-master failed (commit 454fc01cf8 by @jimklimov) |
|
Reports from NetBSD worker would be fixed in #2870 |
…UT envvar [networkupstools#2847, networkupstools#2869] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
… envvar [networkupstools#2847, networkupstools#2869] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…UT envvar [networkupstools#2847, networkupstools#2869] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
… envvar [networkupstools#2847, networkupstools#2869] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…UT envvar [networkupstools#2847, networkupstools#2869] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
… envvar [networkupstools#2847, networkupstools#2869] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…d DEFAULT_NETWORK_TIMEOUT but also upscli_default_connect_timeout if initialized [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ct timeout default [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…d DEFAULT_NETWORK_TIMEOUT but also upscli_default_connect_timeout if initialized [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ct timeout default [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ult_connect_timeout being 0 (for blocking connect, not select!) [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ct timeout default [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ct timeout default [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ct timeout default [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ct timeout default [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ct timeout default [networkupstools#2847] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Many clients currently have no network timeout; connections can take several minutes to fail (or longer if multiple addresses are resolved).
Patch adds a 10 second timeout to all client connections. upsmon especially benefits from the patch as one unavailable ups could delay processing of other ups's, and also cause the watchdog to fire.
Many ups clients were also not attempting SSL, even ones that use authentication to perform actions. Patch adds flag to attempt (but not require) it.