gravitl / netmaker

Netmaker makes networks with WireGuard. Netmaker automates fast, secure, and distributed virtual networks.
https://netmaker.io
Other
9.4k stars 547 forks source link

[Bug]: Key: 'Network.NetID' Error:Field validation for 'NetID' failed on the 'netid_valid' tag #1611

Closed alcroito closed 3 months ago

alcroito commented 1 year ago

Contact Details

No response

What happened?

A bug happened!

Hi. recently I upgraded the netmaker server from v0.11 to 0.16, and upon start up of the netmaker docker container i always get an error as shown in the log snippet. Connections ends up working, but trying to edit and save the network settings causes a panic, as shown in the log snippet.

Perhaps I can modify the sqlite database directly to fix this?

Version

v0.16.0

What OS are you using?

Linux

Relevant log output

netmaker       | [netmaker] 2022-09-28 01:23:07 connecting to sqlite
netmaker       | [netmaker] 2022-09-28 01:23:07 database successfully connected
netmaker       | [netmaker] 2022-09-28 01:23:07 no OAuth provider found or not configured, continuing without OAuth
netmaker       | Key: 'Network.NetID' Error:Field validation for 'NetID' failed on the 'netid_valid' tag
netmaker       | Key: 'Network.DefaultACL' Error:Field validation for 'DefaultACL' failed on the 'checkyesorno' tag
netmaker       | [netmaker] 2022-09-28 01:23:07 could not set defaults on network XTSYakwp
netmaker       | Key: 'Network.DefaultACL' Error:Field validation for 'DefaultACL' failed on the 'checkyesorno' tag
netmaker       | [netmaker] 2022-09-28 01:23:07 could not set defaults on network my-network

...

netmaker       | 2022/09/28 01:26:45 http: panic serving 172.21.0.1:55530: runtime error: invalid memory address or nil pointer dereference
netmaker       | goroutine 278 [running]:
netmaker       | net/http.(*conn).serve.func1()
netmaker       |    /usr/local/go/src/net/http/server.go:1825 +0xbf
netmaker       | panic({0xaf1c80, 0x100f030})
netmaker       |    /usr/local/go/src/runtime/panic.go:844 +0x258
netmaker       | github.com/gravitl/netmaker/logic.UpdateNetwork(0xc0004833f8, 0xc000346a00)
netmaker       |    /app/logic/networks.go:559 +0x1c8
netmaker       | github.com/gravitl/netmaker/controllers.updateNetwork({0xc948d0, 0xc000450460}, 0xc00045af00)
netmaker       |    /app/controllers/network.go:196 +0x36c
netmaker       | net/http.HandlerFunc.ServeHTTP(0xb3d860?, {0xc948d0?, 0xc000450460?}, 0x8?)
netmaker       |    /usr/local/go/src/net/http/server.go:2084 +0x2f
netmaker       | github.com/gravitl/netmaker/logic.SecurityCheck.func1({0xc948d0, 0xc000450460}, 0xc00045af00)
netmaker       |    /app/logic/security.go:61 +0x627
netmaker       | net/http.HandlerFunc.ServeHTTP(0xc00045ae00?, {0xc948d0?, 0xc000450460?}, 0x0?)
netmaker       |    /usr/local/go/src/net/http/server.go:2084 +0x2f
netmaker       | github.com/gorilla/mux.(*Router).ServeHTTP(0xc000446540, {0xc948d0, 0xc000450460}, 0xc00045ad00)
netmaker       |    /go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1cf
netmaker       | github.com/gorilla/handlers.(*cors).ServeHTTP(0xc0000f8480, {0xc948d0, 0xc000450460}, 0xc00045ad00)
netmaker       |    /go/pkg/mod/github.com/gorilla/handlers@v1.5.1/cors.go:138 +0x6e7
netmaker       | net/http.serverHandler.ServeHTTP({0xc93528?}, {0xc948d0, 0xc000450460}, 0xc00045ad00)
netmaker       |    /usr/local/go/src/net/http/server.go:2916 +0x43b
netmaker       | net/http.(*conn).serve(0xc000270be0, {0xc94e28, 0xc000464d20})
netmaker       |    /usr/local/go/src/net/http/server.go:1966 +0x5d7
netmaker       | created by net/http.(*Server).Serve
netmaker       |    /usr/local/go/src/net/http/server.go:3071 +0x4db

Contributing guidelines

afeiszli commented 1 year ago

Have you tried updating the network ID via API directly?

https://app.swaggerhub.com/apis-docs/Netmaker/netmaker/0.15.2#/networks/updateNetwork

mattkasun commented 1 year ago

updating infrastructure was added in v0.14.0; upgrading from earlier versions to the latest is not directly supported currently

you would have to update the database and change the network name(s)/defaultinterface to lower case and set the DefaultACL to 'yes'

PR #1613 fixes

alcroito commented 1 year ago

Thank you for your time and advice, I will try it out.

alcroito commented 1 year ago

Aside from the netid and defaultacl, i was also missing the prosettings dictionary. It doesn't seem like it's possible to add / edit that in the free version of netmaker, so i had to create a new network, and directly update the sqlite value for my existing network with a copy of prosettings