-
-
Notifications
You must be signed in to change notification settings - Fork 390
failover.c - UPS Failover Driver #2962
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
Signed-off-by: Sebastian Kuttnig <[email protected]>
Signed-off-by: Sebastian Kuttnig <[email protected]>
Signed-off-by: Sebastian Kuttnig <[email protected]>
This comment was marked as resolved.
This comment was marked as resolved.
…mber to news entry [networkupstools#2962] Signed-off-by: Sebastian Kuttnig <[email protected]>
Signed-off-by: Sebastian Kuttnig <[email protected]>
…etworkupstools#2962] Signed-off-by: Sebastian Kuttnig <[email protected]>
…r from exit debug Signed-off-by: Sebastian Kuttnig <[email protected]>
…sing process Signed-off-by: Sebastian Kuttnig <[email protected]>
…file Signed-off-by: Sebastian Kuttnig <[email protected]>
Signed-off-by: Sebastian Kuttnig <[email protected]>
Wow. IIRC I never managed to get that really passing for NUT CI farm, as many OS headers are not compatible with the stricter Which system did you build on? Were there additional defines used to enable this or that code path in system headers, or was it really strict C89? Did all of NUT pass with I suppose there is value to have a test environment in the NUT CI farm to ensure, for benefit of older or embedded systems, that our efforts to keep code features/markup similar to C89 (and e.g. avoid shorter UPDATE: Haha, I stand corrected. At least with whatever the CI and configure scripts do, on Ubuntu 22.04 the FWIW, in those runs, NUT Compiler settings:NOTE: Settings for C and C++ compilers are adjusted for debugging (and minimal optimizations)
|
Sorry, I should've clarified some more,
|
That is actually really impressive for a project of this size and portability and maybe even worthy of a |
UPDATE2: tried It warns about many non-C89/non-ANSI features in our code at least, some of which are relatively easy to fix and others may be detected in
... and others' code:
... and numerous
....and probably more that I've missed (not all fit in the scrollback buffer); so I guess the documented stance remains valid. A build with It may make sense to add regular CI runs for non-regression of C89 markup with toolkits that do work though, to help maintain the portability where we have it already. But anyhow, this theme is an off-topic for this PR discussion ;) |
So... according to https://ci.networkupstools.org/job/nut/job/nut/job/master/lastBuild/artifact/.ci.slowBuildStages-list.txt we do run
Oddly enough, the runs which do happen did not complain about comments syntax which I did hit locally; maybe those pipeline settings are older and too relaxed :) |
Compilers there seem more forgiving than me as far as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable, but there are some nits about documentation (maybe not all are relevant upon reading the code, which I started diligently but had to rush the end of...)
Thanks for the detailed feedback, I appreciate it and hope to get into it in detail this weekend. |
Ok, I'll post a couple more commits until then :) |
Sure thing, and appreciate the feedback, tried to address everything until I can touch the code. Fwiw, if you're unclear about anything while doing that, in doubt follow and trust the code paths... the documentation came later and has some rough edges still.... especially visible now through your fresh eyes 😉 Reading more into your feedback and your initial thought process of this being a non-multiplexed failover driver for same-UPS connections (with different drivers), I wonder if it might actually make sense here to do a EDIT: With today's fresher perspective, I guess with the driver already at 2.5k lines as it is, perhaps better split into a |
…places Signed-off-by: Sebastian Kuttnig <[email protected]>
Signed-off-by: Sebastian Kuttnig <[email protected]>
Signed-off-by: Sebastian Kuttnig <[email protected]>
…ing instead Signed-off-by: Sebastian Kuttnig <[email protected]>
Signed-off-by: Sebastian Kuttnig <[email protected]>
Signed-off-by: Sebastian Kuttnig <[email protected]>
…ble promotion Signed-off-by: Sebastian Kuttnig <[email protected]>
Signed-off-by: Sebastian Kuttnig <[email protected]>
…ice uses unexpected driver [networkupstools#2962] Signed-off-by: Jim Klimov <[email protected]>
Signed-off-by: Sebastian Kuttnig <[email protected]>
✅ Build nut 2.8.3.3224-master completed (commit 3e1e8a6d54 by @sebastiankuttnig) |
Signed-off-by: Sebastian Kuttnig <[email protected]>
…shot connections This change removes the dependency on splitting socket names into UPS and driver names. We now rely on the user to provide valid sockets: if it connects, it connects. This enables the use of full paths in the port argument also, improving flexibility and enhancing scriptability. Signed-off-by: Sebastian Kuttnig <[email protected]>
If the CI permits it, this would be complete for I decided to push the runtime tie-breaker at Of course, happy to fine-tune further on the existing documentation or code, should something else surface. @jimklimov : Would you like to add a docs/ |
…s in test expectations [networkupstools#2962] Signed-off-by: Sebastian Kuttnig <[email protected]>
Good point, on it. |
…rkupstools#2962] Signed-off-by: Jim Klimov <[email protected]>
…rver dependencies [networkupstools#2962] Signed-off-by: Jim Klimov <[email protected]>
❌ Build nut 2.8.3.3236-master failed (commit e6fccc733a by @jimklimov) |
Signed-off-by: Sebastian Kuttnig <[email protected]>
Signed-off-by: Sebastian Kuttnig <[email protected]>
Thanks, that simplifies the logic, I've added and tested the optional
As well as the following information to the
I hope that should complement nicely the configurational toggles that are already in place. 🙂 |
Signed-off-by: Sebastian Kuttnig <[email protected]>
These changes avoid constant lookups in the variable table for better performance. Signed-off-by: Sebastian Kuttnig <[email protected]>
…ference Adds checks to ensure ups->status is not NULL before use, preventing a possible NULL pointer dereference. Signed-off-by: Sebastian Kuttnig <[email protected]>
Signed-off-by: Sebastian Kuttnig <[email protected]>
✅ Build nut 2.8.3.3239-master completed (commit 8cca59e2b7 by @sebastiankuttnig) |
Good to merge from my side if nothing else surfaces, CI seems content. 🙂 |
`battery.runtime.low` is assumed to be **seconds**. UPS drivers that report | ||
these values using different units are considered non-compliant with the NUT | ||
variable standards and should be reported to the NUT developers as faulty. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General note for posterity: not all NUT drivers provide a battery.runtime
, some might only have a battery.charge
(or neither estimate/measurement).
For the purpose here, comparing charges is probably rather useless (unless the UPSes have similar capacity so runtimes would happen to compare similarly); but it may be productive to eventually focus on generalizing the runtimecal
fallback, for these time numbers to be available in all/most drivers => #2420
- `2`: *Compare `battery.runtime.low`.* The UPS with the higher value is | ||
preferred. If the value is missing or invalid, the UPS cannot win the tie-break. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how useful this one is for such comparisons, being a fixed value that may be (derived from) a user setting:
Remaining battery runtime when UPS switches to LB (seconds)
It may also be irrelevant if e.g. upssched
is used with upsmon
for a custom shutdown strategy like "if OB took longer than 5 min to recover from" regardless of battery charge/runtime remaining.
But for some users their (own or device's) setting may be a measure of UPS reliability, so why not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I understood this as: this is the seconds left (timer) before the UPS switches to LB
. Want me to remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it can stay, just needed a second glance at usefulness. This can be a factor for some shutdown scenarios - "this UPS will give me a 5-minute FSD window to shut down gracefully (because that's when it becomes OB+LB)", although for specifically shutdowns with upsmon
- more likely the "real" driver would be consulted as one of several supplies, than the failover one. But as you said, for single-UPS clients this may still be relevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks for the double check. 👍
Thanks again for the hard work and a lot of patience :) |
I'd like to present my
failover
driver, which includes various configurable options that I believe will be useful.All code paths have been manually tested and verified using Valgrind, AddressSanitizer (ASan), UndefinedBehaviorSanitizer (UBSan), and LeakSanitizer (LSan). The code builds cleanly and without warnings on all systems available to me, passes
make distcheck
as well as compilation with-std=c89
. For more details, please refer to the source code and the man page.Significant thought and effort went into this, so I’m happy to discuss any necessary changes - ideally before direct patching. Naturally, I’ll also address any warnings or issues flagged by the CI farm to the best of my ability.
MAINTAINER NOTE: Also includes NDE script enhancements to define driver-on-driver dependencies (dummy, clone, failover).