-
-
Notifications
You must be signed in to change notification settings - Fork 406
clients: update clients to timeout in 10 secs, try SSL #2847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 <[email protected]>
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 <[email protected]>
… of the method remaining as it was Signed-off-by: Jim Klimov <[email protected]>
…ale) Signed-off-by: Jim Klimov <[email protected]>
…) to avoid dependency on env (locale) Signed-off-by: Jim Klimov <[email protected]>
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 <[email protected]>
Signed-off-by: Jim Klimov <[email protected]>
…applied as such Signed-off-by: Jim Klimov <[email protected]>
…any clients changed to 10-second default timeout instead of blocking [networkupstools#2847] Signed-off-by: Jim Klimov <[email protected]>
…_TRYSSL [networkupstools#2847] Signed-off-by: Jim Klimov <[email protected]>
…t_timeout to 0 [networkupstools#2847] Signed-off-by: Jim Klimov <[email protected]>
…, docs/nut.dict: document upscli_tryconnect() too Signed-off-by: Jim Klimov <[email protected]>
…ault_timeout() Signed-off-by: Jim Klimov <[email protected]>
|
I think I'm done for now with formalities like man pages and news and stuff, if you could take over fixing the remaining NUT clients (I think most of them would just patch out the currently proposed numeric setting in favor of what ended up done in Maybe some special attention is needed to |
Added -W <secs> network timeout arg to all clients to match upsc usage. Updated help message with "common args" section for -h/-W/-V args. Added upscli_get_default_timeout (used by upsmon) Signed-off-by: Scott Shambarger <[email protected]>
|
I updated all the clients to use the same -W argument as For use in The client man pages don't mention -W yet (or -V or -h in most cases either)... I wasn't sure if you wanted to crowd the pages with all the "common arguments"... I noticed that Do you think other upsclient.c functions should use the default timeout too? eg |
|
❌ Build nut 2.8.2.2925-master failed (commit bfe46c67c9 by @sshambar) |
…tworkupstools#2847] Signed-off-by: Jim Klimov <[email protected]>
…orkupstools#2847] Signed-off-by: Jim Klimov <[email protected]>
|
Thanks! I've fixed a spellchecker complaint. A pointer in the getter I think is better - less data pushed through stack/registers :) As for default/configurable read/send timeouts, I'd say (and the amount of knobs in other programs supports this) that they are fundamentally different timeouts compared to initial-connection ones. It may make sense to add a similar set of methods and internal setting for those (gotta read up if anyone differentiates read and recv timeouts as two different beasts too, if there's reasonable precedent for that). In either case, perhaps it makes sense to rename the ones added by this PR so far to clarify that this is about connection timeouts, before the libupsclient API publishes "unfortunate" names forever. It is already unwieldy (bit me here) that |
|
Failures to parse were seen with debug... changing to |
…NG,...) about timeout strings that we failed to parse [networkupstools#2847] Signed-off-by: Jim Klimov <[email protected]>
…efault_timeout_initialized [networkupstools#2847] If not, auto-init in upscli_init() and upscli_connect() once, to help clients not modified to call upscli_init_default_timeout() explicitly to still benefit from NUT_DEFAULT_CONNECT_TIMEOUT envvar. Signed-off-by: Jim Klimov <[email protected]>
…on-blocking connection timeout [networkupstools#2847] Signed-off-by: Jim Klimov <[email protected]>
|
After the fix, runs with no logging do report the error(s): The wording may be not too friendly, but should get the point across :) |
|
✅ Build nut 2.8.2.2926-master completed (commit 300e8d27b0 by @jimklimov) |
…t to stress that "default network timeout" is about "initial connection" [networkupstools#2847] Signed-off-by: Jim Klimov <[email protected]>
…ONS" including the new "-W secs" [networkupstools#2847] Signed-off-by: Jim Klimov <[email protected]>
…onnect_timeout [networkupstools#2847] Signed-off-by: Jim Klimov <[email protected]>
|
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 <[email protected]>
|
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 <[email protected]>
|
❌ Build nut 2.8.2.2930-master failed (commit 454fc01cf8 by @jimklimov) |
|
Reports from NetBSD worker would be fixed in #2870 |
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.