rockstor / rockstor-rpmbuild

RPM build specifications used to create the distributed 'rockstor' package from rockstor-core and rockstor-jslibs GitHub releases.
GNU General Public License v3.0
2 stars 3 forks source link

resolve indeterminate or inappropriate postgresql alternative config #34

Closed phillxnet closed 1 year ago

phillxnet commented 1 year ago

Thanks to @FroggyFlox & forum members agjbond007 & anborn; for helping to identify this issue. It is currently supposed that, as a result of zypper dup OS version transitions, given examples were (15.3->15.4) & (15.2->15.3->15.4) the, required for Poetry venv build, pg_config file can become unrepresented: i.e. no longer having an alternatives link. This file, as installed by our dependence on:

postgresql13-server-devel

Is normally available via:

rleap15-5:~ # rpm -q --whatprovides /usr/bin/pg_config
postgresql13-server-devel-13.10-150200.5.37.1.x86_64

rleap15-4:~ # ls -lah /usr/bin/pg_config
lrwxrwxrwx 1 root root 27 Nov 14  2022 /usr/bin/pg_config -> /etc/alternatives/pg_config
rleap15-4:~ # ls -lah /etc/alternatives/pg_config
lrwxrwxrwx 1 root root 35 Nov 14  2022 /etc/alternatives/pg_config -> /usr/lib/postgresql13/bin/pg_config
rleap15-4:~ # update-alternatives --list postgresql
/usr/lib/postgresql13

However, during a zypper dup, the new default postgresql version of 14 is installed as per agjbond007 report in the linked forum thread:

i  | postgresql                            | Basic Clients and Utilities for PostgreSQL                                                                                                                                                            | package
i  | postgresql-devel                      | PostgreSQL development header files and libraries                                                                                                                                                     | package
i  | postgresql-llvmjit                    | Just-in-time compilation support for PostgreSQL                                                                                                                                                       | package
i  | postgresql-llvmjit-devel              | Helper package to pull all dependencies to build with llvm support                                                                                                                                    | package
i  | postgresql-server                     | The Programs Needed to Create and Run a PostgreSQL Server                                                                                                                                             | package
i  | postgresql-server-devel               | PostgreSQL server development header files and utilities                                                                                                                                              | package
i  | postgresql13                          | Basic Clients and Utilities for PostgreSQL                                                                                                                                                            | package
i  | postgresql13-devel                    | PostgreSQL client development header files and libraries                                                                                                                                              | package
i  | postgresql13-llvmjit                  | Just-in-time compilation support for PostgreSQL                                                                                                                                                       | package
i  | postgresql13-llvmjit-devel            | PostgreSQL development files for extensions with LLVM support                                                                                                                                         | package
i  | postgresql13-server                   | The Programs Needed to Create and Run a PostgreSQL Server                                                                                                                                             | package
i  | postgresql13-server-devel             | PostgreSQL server development header files and utilities                                                                                                                                              | package
i  | postgresql14                          | Basic Clients and Utilities for PostgreSQL                                                                                                                                                            | package
i  | postgresql14-llvmjit                  | Just-in-time compilation support for PostgreSQL                                                                                                                                                       | package
i  | postgresql14-server                   | The Programs Needed to Create and Run a PostgreSQL Server 

But in the above we see that there is no counterpart to the postgresql13-server-devel installed in the 14 variant, and thus no counterpart provider (via alternatives) of our required pg_config - used by our Poetry dependencies manager to build our Python dependencies upon install/update.

The fix provided by @FroggyFlox in the linked forum thread is to re-assert our dependency upon postgresql13 (and it's server-devel counterpart) via a move away from the auto alternative (as higher priority due to newer) which has unfortunately obscured (removed from alternative managed path) the requried for venv build 'pg_config' utility.

The following shows the by-hand intervention currently required for installs that have previously been 'zypper dup' (distribution updated) from a prior Leap version:

alternatives --config postgresql
There are 2 choices for the alternative postgresql (providing /usr/lib/postgresql).

  Selection    Path                   Priority   Status
------------------------------------------------------------
* 0            /usr/lib/postgresql14   140       auto mode
  1            /usr/lib/postgresql13   130       manual mode
  2            /usr/lib/postgresql14   140       manual mode

Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/lib/postgresql13 to provide /usr/lib/postgresql (postgresql) in manual mode

alternatives --config postgresql
There are 2 choices for the alternative postgresql (providing /usr/lib/postgresql).

  Selection    Path                   Priority   Status
------------------------------------------------------------
  0            /usr/lib/postgresql14   140       auto mode
* 1            /usr/lib/postgresql13   130       manual mode
  2            /usr/lib/postgresql14   140       manual mode

Press <enter> to keep the current choice[*], or type selection number: 

Proposal

We currently have an rpm defined dependency on postresql13 and it's associated server and server-devel packages so rather than move all these dependency over the the newer, OS default, of 14, we should assert our system requirement via the alternative system. At least until we update our own client library of (from pyproject.toml):

psycopg2 = "==2.8.6" # last Python 2.7 version, PostgreSQL 13 errorcodes map?

This older dependency, that is questionable re Postgresql 13, should likely not be tried further with postgresql 14. In the context of our master and testing branches currently span Python 2.7 / 3.6.

This proposed postgresql alternatives assertion could be accomplished within a scriptlet, prior to our Poetry venv build, and post our new rpm/scriptlets install (which would have already installed our dependencies): e.g. %post.

Referenced:

phillxnet commented 1 year ago

For this we need the 'alternatives' command line that selects, non interactively, our postgresql13 requirement.

phillxnet commented 1 year ago

Using an aging system (Leap 15.3) with already 2 alternatives we have:

update-alternatives --set postgresql /usr/lib/postgresql13

which was the default anyway:

rleap15-3:~ # update-alternatives --display postgresql
postgresql - manual mode
  link best version is /usr/lib/postgresql13
  link currently points to /usr/lib/postgresql13
  link postgresql is /usr/lib/postgresql
  slave clusterdb is /usr/bin/clusterdb
  slave createdb is /usr/bin/createdb
  slave createuser is /usr/bin/createuser
  slave dropdb is /usr/bin/dropdb
  slave dropuser is /usr/bin/dropuser
  slave ecpg is /usr/bin/ecpg
  slave initdb is /usr/bin/initdb
  slave pg_basebackup is /usr/bin/pg_basebackup
  slave pg_checksums is /usr/bin/pg_checksums
  slave pg_config is /usr/bin/pg_config
  slave pg_controldata is /usr/bin/pg_controldata
  slave pg_ctl is /usr/bin/pg_ctl
  slave pg_dump is /usr/bin/pg_dump
  slave pg_dumpall is /usr/bin/pg_dumpall
  slave pg_isready is /usr/bin/pg_isready
  slave pg_receivewal is /usr/bin/pg_receivewal
  slave pg_recvlogical is /usr/bin/pg_recvlogical
  slave pg_resetwal is /usr/bin/pg_resetwal
  slave pg_restore is /usr/bin/pg_restore
  slave pg_rewind is /usr/bin/pg_rewind
  slave pg_verifybackup is /usr/bin/pg_verifybackup
  slave pg_waldump is /usr/bin/pg_waldump
  slave postgres is /usr/bin/postgres
  slave postmaster is /usr/bin/postmaster
  slave psql is /usr/bin/psql
  slave reindexdb is /usr/bin/reindexdb
  slave vacuumdb is /usr/bin/vacuumdb
/usr/lib/postgresql10 - priority 100
  slave clusterdb: /usr/lib/postgresql10/bin/clusterdb
  slave createdb: /usr/lib/postgresql10/bin/createdb
  slave createuser: /usr/lib/postgresql10/bin/createuser
  slave dropdb: /usr/lib/postgresql10/bin/dropdb
  slave dropuser: /usr/lib/postgresql10/bin/dropuser
  slave initdb: /usr/lib/postgresql10/bin/initdb
  slave pg_basebackup: /usr/lib/postgresql10/bin/pg_basebackup
  slave pg_controldata: /usr/lib/postgresql10/bin/pg_controldata
  slave pg_ctl: /usr/lib/postgresql10/bin/pg_ctl
  slave pg_dump: /usr/lib/postgresql10/bin/pg_dump
  slave pg_dumpall: /usr/lib/postgresql10/bin/pg_dumpall
  slave pg_isready: /usr/lib/postgresql10/bin/pg_isready
  slave pg_receivewal: /usr/lib/postgresql10/bin/pg_receivewal
  slave pg_recvlogical: /usr/lib/postgresql10/bin/pg_recvlogical
  slave pg_resetwal: /usr/lib/postgresql10/bin/pg_resetwal
  slave pg_restore: /usr/lib/postgresql10/bin/pg_restore
  slave pg_rewind: /usr/lib/postgresql10/bin/pg_rewind
  slave pg_waldump: /usr/lib/postgresql10/bin/pg_waldump
  slave postgres: /usr/lib/postgresql10/bin/postgres
  slave postmaster: /usr/lib/postgresql10/bin/postmaster
  slave psql: /usr/lib/postgresql10/bin/psql
  slave reindexdb: /usr/lib/postgresql10/bin/reindexdb
  slave vacuumdb: /usr/lib/postgresql10/bin/vacuumdb
/usr/lib/postgresql13 - priority 130
  slave clusterdb: /usr/lib/postgresql13/bin/clusterdb
  slave createdb: /usr/lib/postgresql13/bin/createdb
  slave createuser: /usr/lib/postgresql13/bin/createuser
  slave dropdb: /usr/lib/postgresql13/bin/dropdb
  slave dropuser: /usr/lib/postgresql13/bin/dropuser
  slave ecpg: /usr/lib/postgresql13/bin/ecpg
  slave initdb: /usr/lib/postgresql13/bin/initdb
  slave pg_basebackup: /usr/lib/postgresql13/bin/pg_basebackup
  slave pg_checksums: /usr/lib/postgresql13/bin/pg_checksums
  slave pg_config: /usr/lib/postgresql13/bin/pg_config
  slave pg_controldata: /usr/lib/postgresql13/bin/pg_controldata
  slave pg_ctl: /usr/lib/postgresql13/bin/pg_ctl
  slave pg_dump: /usr/lib/postgresql13/bin/pg_dump
  slave pg_dumpall: /usr/lib/postgresql13/bin/pg_dumpall
  slave pg_isready: /usr/lib/postgresql13/bin/pg_isready
  slave pg_receivewal: /usr/lib/postgresql13/bin/pg_receivewal
  slave pg_recvlogical: /usr/lib/postgresql13/bin/pg_recvlogical
  slave pg_resetwal: /usr/lib/postgresql13/bin/pg_resetwal
  slave pg_restore: /usr/lib/postgresql13/bin/pg_restore
  slave pg_rewind: /usr/lib/postgresql13/bin/pg_rewind
  slave pg_verifybackup: /usr/lib/postgresql13/bin/pg_verifybackup
  slave pg_waldump: /usr/lib/postgresql13/bin/pg_waldump
  slave postgres: /usr/lib/postgresql13/bin/postgres
  slave postmaster: /usr/lib/postgresql13/bin/postmaster
  slave psql: /usr/lib/postgresql13/bin/psql
  slave reindexdb: /usr/lib/postgresql13/bin/reindexdb
  slave vacuumdb: /usr/lib/postgresql13/bin/vacuumdb
phillxnet commented 1 year ago
rleap15-3:~ # pg_config --version
PostgreSQL 13.9
rleap15-3:~ # ls -la /etc/alternatives/pg_config
lrwxrwxrwx 1 root root 35 Jul 25 20:27 /etc/alternatives/pg_config -> /usr/lib/postgresql13/bin/pg_config

Switch to postgresql10:

rleap15-3:~ # update-alternatives --set postgresql /usr/lib/postgresql10
update-alternatives: using /usr/lib/postgresql10 to provide /usr/lib/postgresql (postgresql) in manual mode
rleap15-3:~ # which pg_config
which: no pg_config in (/sbin:/usr/sbin:/usr/local/sbin:/root/.local/bin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin)
rleap15-3:~ # pg_config --version
-bash: /usr/bin/pg_config: No such file or directory
rleap15-3:~ # ls -la /etc/alternatives/pg_config
ls: cannot access '/etc/alternatives/pg_config': No such file or directory

With the following slave settings to the master postgresql10 binary index:

rleap15-3:~ # update-alternatives --display postgresql
postgresql - manual mode
  link best version is /usr/lib/postgresql13
  link currently points to /usr/lib/postgresql10
  link postgresql is /usr/lib/postgresql
  slave clusterdb is /usr/bin/clusterdb
  slave createdb is /usr/bin/createdb
  slave createuser is /usr/bin/createuser
  slave dropdb is /usr/bin/dropdb
  slave dropuser is /usr/bin/dropuser
  slave ecpg is /usr/bin/ecpg
  slave initdb is /usr/bin/initdb
  slave pg_basebackup is /usr/bin/pg_basebackup
  slave pg_checksums is /usr/bin/pg_checksums
  slave pg_config is /usr/bin/pg_config
  slave pg_controldata is /usr/bin/pg_controldata
  slave pg_ctl is /usr/bin/pg_ctl
  slave pg_dump is /usr/bin/pg_dump
  slave pg_dumpall is /usr/bin/pg_dumpall
  slave pg_isready is /usr/bin/pg_isready
  slave pg_receivewal is /usr/bin/pg_receivewal
  slave pg_recvlogical is /usr/bin/pg_recvlogical
  slave pg_resetwal is /usr/bin/pg_resetwal
  slave pg_restore is /usr/bin/pg_restore
  slave pg_rewind is /usr/bin/pg_rewind
  slave pg_verifybackup is /usr/bin/pg_verifybackup
  slave pg_waldump is /usr/bin/pg_waldump
  slave postgres is /usr/bin/postgres
  slave postmaster is /usr/bin/postmaster
  slave psql is /usr/bin/psql
  slave reindexdb is /usr/bin/reindexdb
  slave vacuumdb is /usr/bin/vacuumdb
/usr/lib/postgresql10 - priority 100
  slave clusterdb: /usr/lib/postgresql10/bin/clusterdb
  slave createdb: /usr/lib/postgresql10/bin/createdb
  slave createuser: /usr/lib/postgresql10/bin/createuser
  slave dropdb: /usr/lib/postgresql10/bin/dropdb
  slave dropuser: /usr/lib/postgresql10/bin/dropuser
  slave initdb: /usr/lib/postgresql10/bin/initdb
  slave pg_basebackup: /usr/lib/postgresql10/bin/pg_basebackup
  slave pg_controldata: /usr/lib/postgresql10/bin/pg_controldata
  slave pg_ctl: /usr/lib/postgresql10/bin/pg_ctl
  slave pg_dump: /usr/lib/postgresql10/bin/pg_dump
  slave pg_dumpall: /usr/lib/postgresql10/bin/pg_dumpall
  slave pg_isready: /usr/lib/postgresql10/bin/pg_isready
  slave pg_receivewal: /usr/lib/postgresql10/bin/pg_receivewal
  slave pg_recvlogical: /usr/lib/postgresql10/bin/pg_recvlogical
  slave pg_resetwal: /usr/lib/postgresql10/bin/pg_resetwal
  slave pg_restore: /usr/lib/postgresql10/bin/pg_restore
  slave pg_rewind: /usr/lib/postgresql10/bin/pg_rewind
  slave pg_waldump: /usr/lib/postgresql10/bin/pg_waldump
  slave postgres: /usr/lib/postgresql10/bin/postgres
  slave postmaster: /usr/lib/postgresql10/bin/postmaster
  slave psql: /usr/lib/postgresql10/bin/psql
  slave reindexdb: /usr/lib/postgresql10/bin/reindexdb
  slave vacuumdb: /usr/lib/postgresql10/bin/vacuumdb
/usr/lib/postgresql13 - priority 130
  slave clusterdb: /usr/lib/postgresql13/bin/clusterdb
  slave createdb: /usr/lib/postgresql13/bin/createdb
  slave createuser: /usr/lib/postgresql13/bin/createuser
  slave dropdb: /usr/lib/postgresql13/bin/dropdb
  slave dropuser: /usr/lib/postgresql13/bin/dropuser
  slave ecpg: /usr/lib/postgresql13/bin/ecpg
  slave initdb: /usr/lib/postgresql13/bin/initdb
  slave pg_basebackup: /usr/lib/postgresql13/bin/pg_basebackup
  slave pg_checksums: /usr/lib/postgresql13/bin/pg_checksums
  slave pg_config: /usr/lib/postgresql13/bin/pg_config
  slave pg_controldata: /usr/lib/postgresql13/bin/pg_controldata
  slave pg_ctl: /usr/lib/postgresql13/bin/pg_ctl
  slave pg_dump: /usr/lib/postgresql13/bin/pg_dump
  slave pg_dumpall: /usr/lib/postgresql13/bin/pg_dumpall
  slave pg_isready: /usr/lib/postgresql13/bin/pg_isready
  slave pg_receivewal: /usr/lib/postgresql13/bin/pg_receivewal
  slave pg_recvlogical: /usr/lib/postgresql13/bin/pg_recvlogical
  slave pg_resetwal: /usr/lib/postgresql13/bin/pg_resetwal
  slave pg_restore: /usr/lib/postgresql13/bin/pg_restore
  slave pg_rewind: /usr/lib/postgresql13/bin/pg_rewind
  slave pg_verifybackup: /usr/lib/postgresql13/bin/pg_verifybackup
  slave pg_waldump: /usr/lib/postgresql13/bin/pg_waldump
  slave postgres: /usr/lib/postgresql13/bin/postgres
  slave postmaster: /usr/lib/postgresql13/bin/postmaster
  slave psql: /usr/lib/postgresql13/bin/psql
  slave reindexdb: /usr/lib/postgresql13/bin/reindexdb
  slave vacuumdb: /usr/lib/postgresql13/bin/vacuumdb

So in the above we see the equivalent of pg_config not being available as our example systems '10' packages do not provide it, at least under the configuration of alternatives in the 'postgresql10' setting.

Switch back to postgresql13 alternative.

Our supported and previously working (with pg_config) package set:

rleap15-3:~ # update-alternatives --set postgresql /usr/lib/postgresql13
update-alternatives: using /usr/lib/postgresql13 to provide /usr/lib/postgresql (postgresql) in manual mode

rleap15-3:~ # update-alternatives --display postgresql                  
postgresql - manual mode
  link best version is /usr/lib/postgresql13
  link currently points to /usr/lib/postgresql13
  link postgresql is /usr/lib/postgresql
  slave clusterdb is /usr/bin/clusterdb
  slave createdb is /usr/bin/createdb
  slave createuser is /usr/bin/createuser
  slave dropdb is /usr/bin/dropdb
  slave dropuser is /usr/bin/dropuser
  slave ecpg is /usr/bin/ecpg
  slave initdb is /usr/bin/initdb
  slave pg_basebackup is /usr/bin/pg_basebackup
  slave pg_checksums is /usr/bin/pg_checksums
  slave pg_config is /usr/bin/pg_config
  slave pg_controldata is /usr/bin/pg_controldata
  slave pg_ctl is /usr/bin/pg_ctl
  slave pg_dump is /usr/bin/pg_dump
  slave pg_dumpall is /usr/bin/pg_dumpall
  slave pg_isready is /usr/bin/pg_isready
  slave pg_receivewal is /usr/bin/pg_receivewal
  slave pg_recvlogical is /usr/bin/pg_recvlogical
  slave pg_resetwal is /usr/bin/pg_resetwal
  slave pg_restore is /usr/bin/pg_restore
  slave pg_rewind is /usr/bin/pg_rewind
  slave pg_verifybackup is /usr/bin/pg_verifybackup
  slave pg_waldump is /usr/bin/pg_waldump
  slave postgres is /usr/bin/postgres
  slave postmaster is /usr/bin/postmaster
  slave psql is /usr/bin/psql
  slave reindexdb is /usr/bin/reindexdb
  slave vacuumdb is /usr/bin/vacuumdb
/usr/lib/postgresql10 - priority 100
  slave clusterdb: /usr/lib/postgresql10/bin/clusterdb
  slave createdb: /usr/lib/postgresql10/bin/createdb
  slave createuser: /usr/lib/postgresql10/bin/createuser
  slave dropdb: /usr/lib/postgresql10/bin/dropdb
  slave dropuser: /usr/lib/postgresql10/bin/dropuser
  slave initdb: /usr/lib/postgresql10/bin/initdb
  slave pg_basebackup: /usr/lib/postgresql10/bin/pg_basebackup
  slave pg_controldata: /usr/lib/postgresql10/bin/pg_controldata
  slave pg_ctl: /usr/lib/postgresql10/bin/pg_ctl
  slave pg_dump: /usr/lib/postgresql10/bin/pg_dump
  slave pg_dumpall: /usr/lib/postgresql10/bin/pg_dumpall
  slave pg_isready: /usr/lib/postgresql10/bin/pg_isready
  slave pg_receivewal: /usr/lib/postgresql10/bin/pg_receivewal
  slave pg_recvlogical: /usr/lib/postgresql10/bin/pg_recvlogical
  slave pg_resetwal: /usr/lib/postgresql10/bin/pg_resetwal
  slave pg_restore: /usr/lib/postgresql10/bin/pg_restore
  slave pg_rewind: /usr/lib/postgresql10/bin/pg_rewind
  slave pg_waldump: /usr/lib/postgresql10/bin/pg_waldump
  slave postgres: /usr/lib/postgresql10/bin/postgres
  slave postmaster: /usr/lib/postgresql10/bin/postmaster
  slave psql: /usr/lib/postgresql10/bin/psql
  slave reindexdb: /usr/lib/postgresql10/bin/reindexdb
  slave vacuumdb: /usr/lib/postgresql10/bin/vacuumdb
/usr/lib/postgresql13 - priority 130
  slave clusterdb: /usr/lib/postgresql13/bin/clusterdb
  slave createdb: /usr/lib/postgresql13/bin/createdb
  slave createuser: /usr/lib/postgresql13/bin/createuser
  slave dropdb: /usr/lib/postgresql13/bin/dropdb
  slave dropuser: /usr/lib/postgresql13/bin/dropuser
  slave ecpg: /usr/lib/postgresql13/bin/ecpg
  slave initdb: /usr/lib/postgresql13/bin/initdb
  slave pg_basebackup: /usr/lib/postgresql13/bin/pg_basebackup
  slave pg_checksums: /usr/lib/postgresql13/bin/pg_checksums
  slave pg_config: /usr/lib/postgresql13/bin/pg_config
  slave pg_controldata: /usr/lib/postgresql13/bin/pg_controldata
  slave pg_ctl: /usr/lib/postgresql13/bin/pg_ctl
  slave pg_dump: /usr/lib/postgresql13/bin/pg_dump
  slave pg_dumpall: /usr/lib/postgresql13/bin/pg_dumpall
  slave pg_isready: /usr/lib/postgresql13/bin/pg_isready
  slave pg_receivewal: /usr/lib/postgresql13/bin/pg_receivewal
  slave pg_recvlogical: /usr/lib/postgresql13/bin/pg_recvlogical
  slave pg_resetwal: /usr/lib/postgresql13/bin/pg_resetwal
  slave pg_restore: /usr/lib/postgresql13/bin/pg_restore
  slave pg_rewind: /usr/lib/postgresql13/bin/pg_rewind
  slave pg_verifybackup: /usr/lib/postgresql13/bin/pg_verifybackup
  slave pg_waldump: /usr/lib/postgresql13/bin/pg_waldump
  slave postgres: /usr/lib/postgresql13/bin/postgres
  slave postmaster: /usr/lib/postgresql13/bin/postmaster
  slave psql: /usr/lib/postgresql13/bin/psql
  slave reindexdb: /usr/lib/postgresql13/bin/reindexdb
  slave vacuumdb: /usr/lib/postgresql13/bin/vacuumdb

And we have:

rleap15-3:~ # which pg_config
/usr/bin/pg_config
rleap15-3:~ # pg_config --version
PostgreSQL 13.9
phillxnet commented 1 year ago

Closing as: Fixed by #38