SpriteLink / NIPAP

Neat IP Address Planner - NIPAP is the best open source IPAM in the known universe, challenging classical IP address management (IPAM) systems in many areas.
https://spritelink.github.io/NIPAP/
MIT License
539 stars 131 forks source link

Problem when updating from 0.29.6 to .9 on Ubuntu 16.04 #1292

Open GarryG opened 3 years ago

GarryG commented 3 years ago

While updating through the regular packages w/ "apt upgrade", I get these errors when a restart of the daemon is initiated:

invoke-rc.d: initscript nipapd, action "start" failed. ● nipapd.service - LSB: NIPAP XML-RPC server Loaded: loaded (/etc/init.d/nipapd; bad; vendor preset: enabled) Active: failed (Result: exit-code) since Do 2021-07-29 15:46:44 CEST; 35ms ago Docs: man:systemd-sysv-generator(8) Process: 3182 ExecStart=/etc/init.d/nipapd start (code=exited, status=1/FAILURE)

Jul 29 15:46:44 ipam1-nbg1 nipapd[3182]: 2021-07-29 15:46:44,154: backend ERROR Unable to execute query: must be owner of function calc_indent Jul 29 15:46:44 ipam1-nbg1 nipapd[3182]: 2021-07-29 15:46:44,164: backend ERROR Unable to execute query: must be owner of function calc_indent Jul 29 15:46:44 ipam1-nbg1 nipapd[3182]: 2021-07-29 15:46:44,174: backend ERROR Unable to execute query: must be owner of function calc_indent Jul 29 15:46:44 ipam1-nbg1 nipapd[3182]: 2021-07-29 15:46:44,184: backend ERROR pgsql: FATAL: remaining connection slots are reserved for non-replication superuser connections Jul 29 15:46:44 ipam1-nbg1 nipapd[3182]: ERROR: Backend unable to connect to database Jul 29 15:46:44 ipam1-nbg1 nipapd[3182]: ...fail! Jul 29 15:46:44 ipam1-nbg1 systemd[1]: nipapd.service: Control process exited, code=exited status=1 Jul 29 15:46:44 ipam1-nbg1 systemd[1]: Failed to start LSB: NIPAP XML-RPC server. Jul 29 15:46:44 ipam1-nbg1 systemd[1]: nipapd.service: Unit entered failed state. Jul 29 15:46:44 ipam1-nbg1 systemd[1]: nipapd.service: Failed with result 'exit-code'.

Is there anything obvious I might be doing wrong?

jplitza commented 2 years ago

I faced the same problem updating on Ubuntu 18.04. I guess the database initialization took place under the "postgres" user, but the schema migration 6→7 is executed as user "nipap", which doesn't work.

I found this answer on StackOverflow that shows how to mass-change the owner of functions. You also have to change the owner of the tables (although these aren't nearly as many).

mkrogh commented 2 years ago

Also had the same issue on ubuntu 18.04.

Fixed it by running the following sql in sudo -u postgres psql nipap

ALTER FUNCTION calc_indent OWNER TO nipap;
ALTER FUNCTION array_undup OWNER TO nipap;
ALTER FUNCTION calc_tags OWNER TO nipap;
ALTER FUNCTION find_free_ranges(integer) OWNER TO nipap;
ALTER FUNCTION find_free_ranges(integer[]) OWNER TO nipap;
ALTER FUNCTION iprange2cidr OWNER TO nipap;
ALTER FUNCTION calc_pool_free_prefixes(integer,integer,cidr) OWNER TO nipap;
ALTER FUNCTION calc_pool_free_prefixes(ip_net_pool,integer,cidr) OWNER TO nipap;
ALTER FUNCTION cidr_count OWNER TO nipap;
ALTER FUNCTION find_free_prefix(integer,inet[],integer) OWNER TO nipap;
ALTER FUNCTION find_free_prefix(integer,inet[],integer,integer) OWNER TO nipap;
ALTER FUNCTION get_prefix OWNER TO nipap;
ALTER FUNCTION vrf_rt_order OWNER TO nipap;
ALTER FUNCTION tf_ip_net_plan__prefix_iu_before OWNER TO nipap;
ALTER FUNCTION tf_ip_net_vrf_iu_before OWNER TO nipap;

The functions I found by brute force running sudo /usr/sbin/nipapd --auto-upgrade-db over and over seeing which new function it broke at. And when postgres complained about function names not being unique SELECT oid::regprocedure FROM pg_proc WHERE proname = 'find_free_ranges';. There is probably a smarter way to see the functions associated with nipap, but this did the trick for now.

biwhite commented 2 years ago

Also had the same issue on ubuntu 18.04.

Fixed it by running the following sql in sudo -u postgres psql nipap

ALTER FUNCTION calc_indent OWNER TO nipap;
ALTER FUNCTION array_undup OWNER TO nipap;
ALTER FUNCTION calc_tags OWNER TO nipap;
ALTER FUNCTION find_free_ranges(integer) OWNER TO nipap;
ALTER FUNCTION find_free_ranges(integer[]) OWNER TO nipap;
ALTER FUNCTION iprange2cidr OWNER TO nipap;
ALTER FUNCTION calc_pool_free_prefixes(integer,integer,cidr) OWNER TO nipap;
ALTER FUNCTION calc_pool_free_prefixes(ip_net_pool,integer,cidr) OWNER TO nipap;
ALTER FUNCTION cidr_count OWNER TO nipap;
ALTER FUNCTION find_free_prefix(integer,inet[],integer) OWNER TO nipap;
ALTER FUNCTION find_free_prefix(integer,inet[],integer,integer) OWNER TO nipap;
ALTER FUNCTION get_prefix OWNER TO nipap;
ALTER FUNCTION vrf_rt_order OWNER TO nipap;
ALTER FUNCTION tf_ip_net_plan__prefix_iu_before OWNER TO nipap;
ALTER FUNCTION tf_ip_net_vrf_iu_before OWNER TO nipap;

Same here, although I needed to tab-complete the arguments list before each OWNER, otherwise it chucked errors back. as below

nipap=#  ALTER FUNCTION calc_indent OWNER TO nipap;
ERROR:  syntax error at or near "OWNER"
LINE 1: ALTER FUNCTION calc_indent OWNER TO nipap;
                                   ^
nipap=#  ALTER FUNCTION calc_indent (integer, inet, integer) OWNER TO nipap;
ALTER FUNCTION