Conversation
Signed-off-by: Arnaud Quette <ArnaudQuette@Eaton.com>
…o allow starting with 0 ups.conf sections
boricj
left a comment
There was a problem hiding this comment.
Great idea, but shouldn't the configuration be handled inside server/conf.c like any other global setting? Also I'll bike-shed the name: there is (possibly) a configuration but there are no devices, so the case-insensitive name should probably be startWithoutDevices or something like that.
|
As for an option in NUT config - it was a big harder for me to implement so I left it as a reasonable future expansion. First gotta check the idea works at all, and no code elsewhere would explode looping over 0 UPSes etc. :) Also, I think a valid possibility here can be initial absence (or emptiness) of an ups.conf, so where would the option to agree with such situation be? A likely future would be the config option in the file indeed, and the envvar to override if set. Or a command-line option for the daemon... |
|
Practical test results surmised in networkupstools#766 |
aquette
left a comment
There was a problem hiding this comment.
@jimklimov is right here, and @boricj found the light ;)
the "numbered" variant is to be preferred.
As for the implementation:
- this should go into upsd.conf (not nut.conf), since upsd specific, and should be handled as a global arg / flag (I can help in implementing if needed Jim)
- the name: good question :D ALLOW_NO_DEVICE would be good, with the inline comment that goes along
that said, good to know that the current PR already provides the expected behavior.
|
Note: during live-testing, a caveat was found that I am not readily sure how to address: the C++ nutclient library at e.g. https://github.com/42ity/nut/blob/FTY/clients/nutclient.cpp#L702 expects to find some devices in the response or throws an exception. There does not seem to be a problem for C upsclient.c library. It should be somehow changed now that still an exception is not getting a response from
This is a separate issue from this PR (per discussion, there may be several ways to reach the goal of running and having no device sections in the server config). It is not "critical" (as in breaking stuff), but spews red errors in the product journal regularly: Technically the protocol can be checked to have sent a response: Though maybe could use some command to send a count of known devices (re-confirm that it is zero), and maybe do so atomically (respond with list of devices and a count in same operation, to make sure the shipping manifest corresponds to the crate). |
|
Regarding nutclient, I would remove the throw. It's inconsistent with the rest of the API (https://github.com/42ity/nut/blob/FTY/clients/nutclient.cpp#L433-L444 does not throw an exception on an empty driver list among many others) and while there is the possibility that this change will break clients, I doubt that it will be the case in practice. |
|
Actually, I see |
|
Although thanks for discussion. I tried to trace up in source where it would |
|
As a side note, while upsd would not start without drivers, it can nevertheless be tricked into this state. It will return an empty LIST UPS once a configuration reload happens with no drivers. |
|
This PR adds the option to start without drivers from the get-go :) Although your point is also valid, for talking to other NUT versions whose servers can end up in this state indeed. |
|
Testing such sanity check in the feature image branch... |
… with empty device list
|
So, this removed the Invalid Device errors happening every half a minute while there are not devices. Hypothesizing, could it be with a device for which no dstate was yet collected by the server so vars are unknown, for example? In any case, I guess we can live with that if this is indeed the only occurrence and seen only in such edge conditions. |
|
The decision was made to merge the feature to our common baseline. Further improvement (refine the config toggle for device-less startup, and possibly further review exceptions of nutclient) can be done in other PRs. |
Adaptation of networkupstools#766
Equivalent code will be tested in featureimage/systemd-deps-agents to check for proper behavior