openwrt / luci

LuCI - OpenWrt Configuration Interface
Apache License 2.0
6.11k stars 2.48k forks source link

/usr/lib/lua/luci/dispatcher.lua:370: /etc/config/luci seems to be corrupt, unable to find section 'main' #4758

Closed rozhuk-im closed 3 years ago

rozhuk-im commented 3 years ago

Update to latest master and restore config from backup (~6 month old), got error: /usr/lib/lua/luci/dispatcher.lua:370: /etc/config/luci seems to be corrupt, unable to find section 'main'

2885, #2799, #2231 - this is not first time.

Workaroud in this message: https://github.com/openwrt/luci/issues/2231#issuecomment-663915276 work for me: if I run rpcd from ssh then error gone.

I dig inside and found that in my backup /etc/config/rpcd

config rpcd
    option socket /var/run/ubus.sock
    option timeout 30

config login
    option username 'root'
    option password '$p$root'
    list read '*'
    list write '*'

This is from default config after reset:

config rpcd
    option socket /var/run/ubus/ubus.sock
    option timeout 30

config login
    option username 'root'
    option password '$p$root'
    list read '*'
    list write '*'

As you can see:

  1. option socket is different.
  2. if rpcd started without options - if uses proper path to socket, at least GUI works.

Why not remove option socket handling from /etc/config/rpcd and /etc/init.d/rpcd ?

jow- commented 3 years ago

Not a LuCI bug. Your config need to be updated.

mmokrejs commented 3 years ago
/usr/lib/lua/luci/dispatcher.lua:427: /etc/config/luci seems to be corrupt, unable to find section 'main'

Same issue after upgrade from 19.07 to Powered by LuCI openwrt-21.02 branch (git-21.163.64918-ba57ec5) / OpenWrt 21.02.0-rc3 r16172-2aba3e9784:

# cat /etc/config/rpcd
config rpcd
    option socket /var/run/ubus.sock
    option timeout 30

config login
    option username 'root'
    option password '$p$root'
    list read '*'
    list write '*'

#
# ls -latr /var/run/ubus.sock
ls: /var/run/ubus.sock: No such file or directory
# ls -latr /var/run/ubus/
srw-rw-rw-    1 root     root             0 Jan  1  1970 ubus.sock
drwxr-xr-x    2 root     root            60 Jan  1  1970 .
drwxr-xr-x    7 root     root           420 Jun 26 02:26 ..
# 

Editiing the config file to match the /var/run/ubus/ubus.sock and service rpcd restart fixed the issue for me.

HubKing commented 2 years ago

/var/run/ubus/ubus.sock

I upgraded to 21.02 and this happened. changing /var/run/ubus.sock to /var/run/ubus/ubus.sock fixed it, but isn't this a bug? I don't know who is to blame, but either the OpenWRT or Luci needs to fix this, so that users don't have to do this manually.

SmallAndSoft commented 2 years ago

I have been watching real time graphs in luci and top over ssh. CPU eating luci subprocess quit and now I have this error. Restarting rpcd helped.

Cadair commented 2 years ago

I too got this after using the real time graphs.

n-pat commented 2 years ago

I can confirm that I also got this when using real time graphs of connections (with about 5000 open connections). rpcd seems to crash reproducable. A restart of rpcd helps.

The second problem was a wrong config file (/var/run/ubus.sock), which perhaps happened because of my non-standard upgrade-path. I could solve this by manually adjusting the ubus path in the rpcd config.

I did update by importing a config file from a 19.01 installation into a new 21.02.1 installation. It worked about 10 days until I got the problem when using the real time graphs (which I also used before). Perhaps the rpcd was not restarted, so I noticed the wrong path error very late when it crashed.

From NanoPi-R1 Friendly WRT based on 19.01 OpenWRT (special version by NanoPi from 2021/May/12) to 21.02.1 r16325-88151b8303 official OpenWRT for NanoPi-R1.

mmokrejs commented 2 years ago

@n-pat Please include release version numbers in your above answer. Thanks.

exaghost commented 2 years ago

Hi! I have the same issue. To reproduce: login to Luci, and browse the graphs. I also have many connections. Then the corruption occurs. To fix it, I can restart the service over SSH (service rpcd restart), and everything works normal. This problem exists in 21.02.1 (fresh OpenWRT install from stock FW) and 21.02.2. (upgrade) I think it's not a Luci bug. I have not alter any config files when this happened.

davidtwgit commented 2 years ago

Same issue when I flash 19.x from luci on 21.02.2 with router r4ac 100m

IOsetting commented 2 years ago

I can confirm that I also got this when using real time graphs of connections (with about 5000 open connections). rpcd seems to crash reproducable. A restart of rpcd helps.

I got this same error, after visiting the connections page of real time graphs.

The firmware version:

Firmware Version    OpenWrt 21.02.2 r16495-bf0c965af0 / LuCI openwrt-21.02 branch git-22.046.85957-59c3392
dseven commented 2 years ago

I also encountered this symtom after attempting to view the "Connections" real-time graphs, and a restart of rpcd made it work again.

Although there's apparently an underlying issue with rpcd, it seems that the error presented by Luci is bogus - it suggests that the 'main' section is missing from /etc/config/luci, which is, in fact, not the case. From reading above, it appears that this error is also presented when an incorrect rpcd socket path is configured. Apparently this is actually a general "oh crap, something bad happened [when trying to talk to rpcd?]" condition. The bogus error message seems like a Luci bug, albeit a somewhat cosmetic one.

beadon commented 1 year ago

Reporting that I also have the same problem with a large number of connections, crash happens after enabling the DNS resolution in the connections display via LUCI web interface.

mmokrejs commented 1 year ago

@dseven

I also encountered this symtom after attempting to view the "Connections" real-time graphs, and a restart of rpcd made it work again.

Although there's apparently an underlying issue with rpcd, it seems that the error presented by Luci is bogus - it suggests that the 'main' section is missing from /etc/config/luci, which is, in fact, not the case. From reading above, it appears that this error is also presented when an incorrect rpcd socket path is configured. Apparently this is actually a general "oh crap, something bad happened [when trying to talk to rpcd?]" condition. The bogus error message seems like a Luci bug, albeit a somewhat cosmetic one.

Well, maybe in your case it was cosmetis issue but in my case it was a fatal error. The path to the socket was just wrong causing rpcd to exit. But I agree the other situations should be covered a different, more descriptive error message.

HubKing commented 1 year ago

I bought a new router yesterday. After uploading the initial ROM to convert stock->OpenWRT, I straightly installed the latest OpenWRT. I am not sure if that counts as an upgrade or not, but this problem randomly happened today. That is, OpenWRT had been working find for hours and when I was browsing the real-time graph tab,s it happened

/usr/lib/lua/luci/dispatcher.lua:431: /etc/config/luci seems to be corrupt, unable to find section 'main'

This time, there was no /var/run/ubus.sock and /var/run/ubus/ubus.sock was already there, so I am not sure sure how to solve this.

PS: After browsing other comments, I ran /etc/init.d/rpcd restart in the SSH terminal and that made the web UI work again.

mmokrejs commented 1 year ago

@HubKing Please include above which OpenWRT version you installed and filname if of imge you flashed.

HubKing commented 1 year ago

Please include above which OpenWRT version you installed and filname if of imge you flashed.

Actually, the same error happened again randomly a while after I solved that, so my guess is that it was only a temporary solution and that the same error will keep happening.

emhamm commented 1 year ago

Although this was closed long ago this bug is still relevant and reproducible. My first step while debugging was to make sure the ubus path is the right one.

how to reproduce this:

OpenWrt version: OpenWrt 22.03.4 r20123-38ccc47687 Architecture: ARMv8 Processor rev 4 Target Platform: mediatek/mt7622 Model: Linksys E8450 (UBI)

dseven commented 1 year ago

IMO there should be two separate new issues opened for this problem:

1) RPC dies when there are lots of connections (not a Luci issue, so won't he addressed here) 2) Luci presents a misleading error message when RPC dies (this is a Luci issue, IMO)

emhamm commented 1 year ago

You are right, i will open those issues now.