Skip to content

Issue #213 nut-upsd image - version 2.8.3 with ulimit#220

Merged
instantlinux merged 1 commit into
mainfrom
ISSUE-213_nut_trixie
Aug 30, 2025
Merged

Issue #213 nut-upsd image - version 2.8.3 with ulimit#220
instantlinux merged 1 commit into
mainfrom
ISSUE-213_nut_trixie

Conversation

@instantlinux

@instantlinux instantlinux commented Aug 30, 2025

Copy link
Copy Markdown
Owner

Summary of Changes

Updates nut-upsd to version 2.8.3-r2 and adds a ULIMIT parameter to set maximum open files (default 2048).

Why is this change being made?

Under Debian trixie, an issue #1672 causes an out-of-memory error due to a high system default value for this parameter. Reported here as issue #213 by @Certain1989.

How was this tested? How can the reviewer verify your testing?

Local testing. Started a container and viewed the limits applied to upsd:

/ # ulimit -n
1048576
/ # echo $ULIMIT
2048
/ # ps aux
PID   USER     TIME  COMMAND
    1 root      0:00 /usr/sbin/upsmon -D
   22 root      0:00 /usr/lib/nut/usbhid-ups -a ups -u root
   24 nut       0:00 /usr/sbin/upsd -u nut
   25 nut       0:00 /usr/sbin/upsmon -D
   46 root      0:00 sh
   71 root      0:00 ps aux
/ # cat /proc/24/limits
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            8388608              unlimited            bytes     
Max core file size        unlimited            unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             unlimited            unlimited            processes 
Max open files            2048                 2048                 files     <--- note new reduced value
Max locked memory         8388608              8388608              bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       62785                62785                signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us        

Completion checklist

  • The pull request is linked to all related issues
  • This change has unit test coverage
  • Documentation has been updated
  • Dependencies have been updated and verified

@instantlinux instantlinux merged commit 11725e3 into main Aug 30, 2025
1 check passed
@instantlinux instantlinux deleted the ISSUE-213_nut_trixie branch August 30, 2025 01:27
@instantlinux instantlinux changed the title Issue 213 nut trixie Issue #213 nut-upsd image - version 2.8.3 with ulimit Aug 30, 2025
@alec-pinson

alec-pinson commented Aug 31, 2025

Copy link
Copy Markdown

Mine broke after upgrading to this version, not worked out why yet.

Network UPS Tools upsdrvctl - UPS driver controller 2.8.3 release
Network UPS Tools 2.8.3 release - Generic HID driver 0.62
USB communication driver (libusb 1.0) 0.50
Duplicate driver instance detected (PID file /var/run/nut/usbhid-ups-ups.pid exists)! Terminating other driver!
HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be incorrect; interpreting LogMax -1 as 255 in ReportID: 0x0c
HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be incorrect; interpreting LogMax -1 as 255 in ReportID: 0x22
HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be incorrect; interpreting LogMax -1 as 255 in ReportID: 0x40
Using subdriver: APC HID 0.100
Listening on socket /var/run/nut/usbhid-ups-ups
Network UPS Tools upsd 2.8.3 release
Ignoring invalid pid number 0
listening on 0.0.0.0 port 3493
Connected to UPS [ups]: usbhid-ups-ups
Found 1 UPS defined in ups.conf
Network UPS Tools upsmon 2.8.3 release
   0.000000	[D1] upscli_init_default_connect_timeout: upscli_default_connect_timeout=10.000000 sec assigned from: default_secs
   0.000000	Ignoring invalid pid number 0
   0.000046	[D1] Just failed to send signal, no daemon was running
   0.000106	[D1] loadconfig: Loading /etc/nut/upsmon.conf
   0.000312	Using power down flag file /etc/killpower
   0.000508	Unable to use old-style MONITOR line without a username
   0.000547	Convert it and add a username to upsd.users - see the documentation
   0.000572	Fatal error: unusable configuration

More info, I run this on Kubernetes and these are the only env variables I set

  SERIAL: "9B2507A0XXXX"
  SDORDER: "-1"
  VENDORID: "051d"
  API_PASSWORD: '${UPS_NUT_API_PASSWORD}'

For now I've rolled back to previous verison but will check more when I get chance.

@instantlinux

instantlinux commented Aug 31, 2025

Copy link
Copy Markdown
Owner Author

Mine broke after upgrading to this version, not worked out why yet.

   0.000312	Using power down flag file /etc/killpower
   0.000508	Unable to use old-style MONITOR line without a username
   0.000547	Convert it and add a username to upsd.users - see the documentation
   0.000572	Fatal error: unusable configuration

More info, I run this on Kubernetes and these are the only env variables I set

The changelog for 2.8.3 is pretty long -- there could be a breaking-change among the item list -- but the entrypoint script here has long been designed to avoid that error (old-style MONITOR line). Entrypoint creates both: a upsd.users file for user upsmon, and a upsmon.conf that sets this line:

MONITOR ups@localhost 1 upsmon xxxx master

I can think of two ways you might've been tripped up: either you've set up a volume-mount under /etc/nut/local that contains an older format of this directive, or there's a special-character in the password that's interfering with the parser in some new way. There's probably a third way you've been tripped up, though. Here's a troubleshooting suggestion: if you can start it up with the entrypoint command overridden (to just invoke /bin/sh with a long sleep command), and then invoke /usr/local/bin/entrypoint.sh within a root shell, the generated files in /etc/nut can be viewed to see where the problem is. Filter out comments thus:

/etc/nut # egrep -v "^#|^$" upsmon.conf
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG "/etc/killpower"
OFFDURATION 30
OVERDURATION -1
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5
ALARMCRITICAL 1
MONITOR ups@localhost 1 upsmon xxxx master
RUN_AS_USER nut

Docs now specify role name primary rather than master, but the latter hasn't been deprecated yet -- will adjust this in a future PR.

@alec-pinson

Copy link
Copy Markdown

I thought i'd take a look at this again, rolled out the new version and now I'm not getting any issues.

Thanks for looking into it though!

Log from new version:

Network UPS Tools upsdrvctl - UPS driver controller 2.8.3 release
Network UPS Tools 2.8.3 release - Generic HID driver 0.62
USB communication driver (libusb 1.0) 0.50
HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be incorrect; interpreting LogMax -1 as 255 in ReportID: 0x0c
HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be incorrect; interpreting LogMax -1 as 255 in ReportID: 0x22
HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be incorrect; interpreting LogMax -1 as 255 in ReportID: 0x40
Using subdriver: APC HID 0.100
Listening on socket /var/run/nut/usbhid-ups-ups
Network UPS Tools upsd 2.8.3 release
Ignoring invalid pid number 0
listening on 0.0.0.0 port 3493
Connected to UPS [ups]: usbhid-ups-ups
Found 1 UPS defined in ups.conf
   0.000000	[D1] upscli_init_default_connect_timeout: upscli_default_connect_timeout=10.000000 sec assigned from: default_secs
   0.000000	Ignoring invalid pid number 0
   0.000009	[D1] Just failed to send signal, no daemon was running
   0.000041	[D1] loadconfig: Loading /etc/nut/upsmon.conf
   0.000185	Using power down flag file /etc/killpower
   0.000327	UPS: ups@localhost (primary) (power value 1)
   0.000342	[D1] debug level is '1'
Network UPS Tools upsmon 2.8.3 release
   0.002613	[D1] Saving PID 23 into /run/upsmon.pid
   0.002859	[D1] Succeeded to become_user(nut): now UID=100 GID=101
   0.003048	Init SSL without certificate database
   0.013314	upsnotify: failed to notify about state NOTIFY_STATE_READY_WITH_PID: no notification tech defined, will not spam more about it
   0.013331	[D1] On systems without service units, consider `export NUT_QUIET_INIT_UPSNOTIFY=true`
   0.013336	[D1] Trying to connect to UPS [ups@localhost]
   0.013803	[D1] Logged into UPS ups@localhost
   0.014066	UPS ups@localhost: has at least one unclassified status token: [WAIT]
   5.014678	UPS ups@localhost has no unclassified status tokens anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants