Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to remove legacy poetry version in 5.0.6-0 rpm #2782 #2783

Conversation

phillxnet
Copy link
Member

@phillxnet phillxnet commented Jan 22, 2024

Add legacy poetry install path to avoid failing its uninstall. Without this additional path, when build.sh is run from within RPM's constrained %posttrans scriptlet, we fail to find and uninstall our prior 1.1.15 poetry version. This leads to having both poetry 1.1.15 (via upstream installer) and our new pipx installed poetry 1.7.1. After having checked-for/uninstalled this legacy version we then need to remove the associated legacy path.

Fixes #2782

Add legacy poetry install path to avoid failing its uninstall.
Without this additional path, when build.sh is run from within
RPM's constrained %posttrans scriptlet, we fail to find and
uninstall our prior 1.1.15 poetry version. This leads to having
both poetry 1.1.15 (via upstream installer) and our new pipx
installed poetry 1.7.1.
@phillxnet
Copy link
Member Author

phillxnet commented Jan 22, 2024

Testing

Using an rpm build for 15.4 with the proposed patch included, we now have a successful legacy poetry identification and removal on a system with only the legacy Poetry installed.

# 2024-01-22 16:50:27 %posttrans(rockstor-5.0.6-2783.x86_64) script output:
# /root/.local/bin/poetry
# Poetry version 1.1.15 found - UNINSTALLING
# Removing Poetry (1.1.15)
# creating virtual environment...
# creating shared libraries...
# upgrading shared libraries...
# installing poetry from spec 'poetry==1.7.1'...
# done! ✨ 🌟 ✨#   installed package poetry 1.7.1, installed using Python 3.11.5
#   These apps are now globally available
#     - poetry
# No config-backups-rpmsave directory found.

And a subsequent which confirms this:

installer:~ # which poetry 
/usr/local/bin/poetry

But we still have a dangling reference, as if we call on the poetry binary:

installer:~ # poetry --version
-bash: /root/.local/bin/poetry: No such file or directory

We see a reference to the following now dead link:

installer:~ # ls -la /root/.local/bin/poetry
lrwxrwxrwx 1 root root 43 Jan 19 16:37 /root/.local/bin/poetry -> /root/.local/share/pypoetry/venv/bin/poetry

It would seem the legacy upstream install/uninstall script has not completely removed what it had previously installed.

We also have not affected the issue detailed failed venv creation.

However if we re-run build.sh all is then well:

installer:/opt/rockstor # ./build.sh
...
installer:/opt/rockstor # cat poetry-install.txt 
Installing dependencies from lock file

Package operations: 50 installs, 0 updates, 0 removals

  • Installing pycparser (2.21)
  • Installing cffi (1.16.0)
...
  • Installing supervisor (4.2.4)
  • Installing urlobject (2.1.1)

Installing the current project: rockstor (5.0.6)

with a successfully established (from build.sh) password-store config also (pre initrock):

installer:/opt/rockstor # pass
Password Store
└── python-keyring
    └── rockstor
        └── SECRET_KEY

@phillxnet
Copy link
Member Author

phillxnet commented Jan 22, 2024

When removing the legacy installer 'dead link' via:

rm --force /root/.local/bin/poetry

we still experience:

installer:~ # poetry --version
-bash: /root/.local/bin/poetry: No such file or directory

However if we reset path to it's exact same value at the time:

export PATH="/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"

this 'artifact'/ghost/in-memory cached binary reference or what-ever goes away.

installer:~ # poetry --version
Poetry (version 1.7.1)

…ckstor#2782

- Remove dangling legacy poetry symlink - apparently
neglected by legacy poetry installer/uninstaller.
- After the above there is an in-memory 'poetry'
resolution to `/root/.local/bin/poetry' until path
is reset. So use reset as opportunity to remove
legacy path.
…ockstor#2782

- Fix location of our temp legacy poetry path removal.
- Add echo of PATH used by rest of build.sh.
@phillxnet phillxnet marked this pull request as draft January 22, 2024 19:42
@phillxnet
Copy link
Member Author

phillxnet commented Jan 23, 2024

Retest of branch to-date:

# 2024-01-23 14:33:07 rockstor-5.0.6-2783.x86_64.rpm installed ok
# Additional rpm output:
# No static/config-backups directory found.
# 
2024-01-23 14:33:07|install|rockstor|5.0.6-2783|x86_64|root@installer|Buildbot-Testing|6910eabc750440c832d86c1c1bb224524b86128d77ca933ec034bdd72613adac|
# 2024-01-23 14:33:07 %posttrans(rockstor-5.0.6-2783.x86_64) script output:
# /root/.local/bin/poetry
# Poetry version 1.1.15 found - UNINSTALLING
# Removing Poetry (1.1.15)
# build.sh has PATH=/root/.local/bin:/usr/local/bin:/opt/rockstor/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# creating virtual environment...
# creating shared libraries...
# upgrading shared libraries...
# installing poetry from spec 'poetry==1.7.1'...
# done! ✨ 🌟 ✨#   installed package poetry 1.7.1, installed using Python 3.11.5
#   These apps are now globally available
#     - poetry
# No config-backups-rpmsave directory found.

Our path modification looks to be malfunctioning when our to-be-removed path is at the front !!

installer:~ # printenv PATH
/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
installer:~ # PATH="${PATH//':/root/.local/bin'/''}"
installer:~ # printenv PATH
/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin

But when it leads, as in our current case:

installer:~ # PATH="/root/.local/bin:/usr/local/bin:/opt/rockstor/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
installer:~ # printenv PATH
/root/.local/bin:/usr/local/bin:/opt/rockstor/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
installer:~ # PATH="${PATH//':/root/.local/bin'/''}"
installer:~ # printenv PATH
/root/.local/bin:/usr/local/bin:/opt/rockstor/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Substring fails us. So we also need the following to remove our just-added (front of path) temp legacy poetry path:

installer:~ # printenv PATH
/root/.local/bin:/usr/local/bin:/opt/rockstor/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
installer:~ # echo "${PATH#'/root/.local/bin:'}"
/usr/local/bin:/opt/rockstor/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

[EDIT] Looks like I missed the miss-match here: will re-visit and test:

PATH="${PATH//'/root/.local/bin:'/''}"

…ockstor#2782

- remove not only substring instance of legacy Poetry path,
but also our temp front-of-path entry.
@phillxnet
Copy link
Member Author

Legacy path removed:

# 2024-01-23 15:22:54 rockstor-5.0.6-2783.x86_64.rpm installed ok
# Additional rpm output:
# No static/config-backups directory found.
# 
2024-01-23 15:22:54|install|rockstor|5.0.6-2783|x86_64|root@installer|Buildbot-Testing|cab0adddd6e586c36ac385ae5f2dd4d28c54f2799300c1403cc188cdb62c35d6|
# 2024-01-23 15:22:54 %posttrans(rockstor-5.0.6-2783.x86_64) script output:
# /root/.local/bin/poetry
# Poetry version 1.1.15 found - UNINSTALLING
# Removing Poetry (1.1.15)
# build.sh has PATH=/usr/local/bin:/opt/rockstor/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# creating virtual environment...
# creating shared libraries...
# upgrading shared libraries...
# installing poetry from spec 'poetry==1.7.1'...
# done! ✨ 🌟 ✨#   installed package poetry 1.7.1, installed using Python 3.11.5
#   These apps are now globally available
#     - poetry
# No config-backups-rpmsave directory found.
2024-01-23 15:23:22|patch  |openSUSE-SLE-15.4-2022-2593|1|noarch|repo-sle-update|moderate|recommended|not-needed|applied|

So our last stable to pending testing RC2 has successful legacy poetry removal now, but we have an unchanged outcome re new Poetry establishing our .venv:

installer:~ # which poetry
/usr/local/bin/poetry
installer:~ # poetry --version
Poetry (version 1.7.1)

and

installer:/opt/rockstor # poetry env list
.venv (Activated)
installer:/opt/rockstor # poetry env info

Virtualenv
Python:         3.11.5
Implementation: CPython
Path:           /opt/rockstor/.venv
Executable:     /opt/rockstor/.venv/bin/python
Valid:          True

System
Platform:   linux
OS:         posix
Python:     3.11.5
Path:       /usr
Executable: /usr/bin/python3.11

installer:/opt/rockstor # ls -la /opt/rockstor/.venv/bin/python
lrwxrwxrwx 1 root root 19 Jan 23 15:23 /opt/rockstor/.venv/bin/python -> /usr/bin/python3.11

…ockstor#2782

- remove deleted-in-%post RPM scriptlet .venv related path.
@phillxnet
Copy link
Member Author

phillxnet commented Jan 23, 2024

Final state pre-squash and re-presenting this draft PR.

We now have a successful legacy poetry removal:

2024-01-23 18:06:25|install|password-store|1.7.4-bp154.1.24|noarch||Leap_15_4|5475457a60b3a03c9b3c25e569b495579b52c107f2e8540cffd6388c51087423|
# 2024-01-23 18:06:27 rockstor-5.0.6-2783.x86_64.rpm installed ok
# Additional rpm output:
# No static/config-backups directory found.
# 
2024-01-23 18:06:27|install|rockstor|5.0.6-2783|x86_64|root@installer|Buildbot-Testing|66b2a1d0fa9f0fdbb17442adf31fb5eff3b05f80445fb12874d7ed7a1bef6d1a|
# 2024-01-23 18:06:27 %posttrans(rockstor-5.0.6-2783.x86_64) script output:
# /root/.local/bin/poetry
# Poetry version 1.1.15 found - UNINSTALLING
# Removing Poetry (1.1.15)
# build.sh has PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# creating virtual environment...
# creating shared libraries...
# upgrading shared libraries...
# installing poetry from spec 'poetry==1.7.1'...
# done! ✨ 🌟 ✨#   installed package poetry 1.7.1, installed using Python 3.11.5
#   These apps are now globally available
#     - poetry
# No config-backups-rpmsave directory found.

But have yet to establish why our new .venv is not successfully recreated from within RPM's invocation of build.sh:

installer:~ # cat /opt/rockstor/poetry-install.txt 

Command ['python', '-I', '-W', 'ignore', '-c', 'import sys\n\nif hasattr(sys, "real_prefix"):\n    print(sys.real_prefix)\nelif hasattr(sys, "base_prefix"):\n    print(sys.base_prefix)\nelse:\n    print(sys.prefix)\n'] errored with the following return code 2

Error output:
Unknown option: -I
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

However a re-run from the shell of build.sh:

cd /opt/rockstor/
./build.sh 
...
cat /opt/rockstor/poetry-install.txt 
...
  • Installing psycopg (3.1.13)
  • Installing python-socketio (5.9.0)
  • Installing pyzmq (25.1.1)
  • Installing six (1.16.0)
  • Installing supervisor (4.2.4)
  • Installing urlobject (2.1.1)

Installing the current project: rockstor (5.0.6)

Note that when run under a regular root shell we have the following PATH report:
via ./build.sh > build-out.txt 2>&1

cat build-out.txt

/usr/local/bin/poetry
build.sh has PATH=/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
'poetry' already seems to be installed. Not modifying existing installation in
'/opt/pipx/venvs/poetry'. Pass '--force' to force installation.

Path env comparisons:

  • PR RPM: build.sh has
    PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  • shell : build.sh has PATH=/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin

@phillxnet phillxnet closed this Jan 23, 2024
@phillxnet phillxnet deleted the 2782-Failure-to-remove-legacy-poetry-version-in-5.0.6-0-rpm branch January 23, 2024 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant