Page MenuHomePhabricator

`webservice` (build 0.103.8) crashes on login-buster.toolforge.org (python 3.7)
Closed, ResolvedPublicBUG REPORT

Description

$ ssh login-buster.toolforge.org
$ become bd808-test
$ webservice shell
Traceback (most recent call last):
  File "/usr/local/bin/webservice", line 33, in <module>
    sys.exit(load_entry_point('toolforge-webservice==0.103.8', 'console_scripts', 'webservice')())
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2793, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2411, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2417, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/toolsws/cli/webservice.py", line 12, in <module>
    from toolsws.backends import Backend, KubernetesBackend
  File "/usr/lib/python3/dist-packages/toolsws/backends/__init__.py", line 2, in <module>
    from .kubernetes import KubernetesBackend
  File "/usr/lib/python3/dist-packages/toolsws/backends/kubernetes.py", line 201, in <module>
    class KubernetesBackend(Backend):
  File "/usr/lib/python3/dist-packages/toolsws/backends/kubernetes.py", line 396, in KubernetesBackend
    def _get_pod_security_context(self) -> dict[str, Any]:
TypeError: 'type' object is not subscriptable
$ python3 --version
Python 3.7.3

The mypy type annotations are causing Python 3.7 to crash. This can be recreated with any webservice ... command under Python 3.7.

Details

TitleReferenceAuthorSource BranchDest Branch
d/changelog: bump to 0.103.9repos/cloud/toolforge/tools-webservice!47aborreroarturo-114-d-changelog-bump-tomain
Replace Python 3.9 type aliases with 3.7-compatible aliasesrepos/cloud/toolforge/tools-webservice!46anticompositework/anticomposite/T368463main
Customize query in GitLab

Event Timeline

(snark injected into a discussion of strong typing in python)
<bd808> are y'all staring at the overlay of strong type checking to a duck typed language and wondering why it looks like a platypus and not a swan?

bd808 renamed this task from `webservice shell` (build 0.103.8) crashes on login-buster.toolforge.org (python 3.7) to `webservice` (build 0.103.8) crashes on login-buster.toolforge.org (python 3.7).Tue, Jun 25, 9:47 PM
bd808 updated the task description. (Show Details)

Mentioned in SAL (#wikimedia-cloud) [2024-06-25T21:50:21Z] <bd808> Live hacked /usr/lib/python3/dist-packages/toolsws/backends/kubernetes.py on login-buster.toolforge.org to remove the -> dict[str, Any] type annotations causing T368463

bd808 triaged this task as High priority.Tue, Jun 25, 9:52 PM

A live hack is in place that makes webservice work under Python 3.7 again, but it will break if a newer toolforge-webservice is pushed to apt without correcting the type hints.

Looks like the 3.9 type aliases were introduced in c1b3523e by @aborrero. I've opened an MR to replace them with python 3.7-compatible type aliases.

taavi assigned this task to AntiCompositeNumber.
taavi subscribed.

The patch was merged. Given that the local hack is fixing the issue for now and the next tagged version includes the fix, I'm closing this task.

Mentioned in SAL (#wikimedia-cloud) [2024-06-26T10:17:42Z] <arturo> deploying toolforge-webservice 0.103.9 (T368463)

Mentioned in SAL (#wikimedia-cloud) [2024-06-26T10:18:24Z] <arturo> deploying toolforge-webservice 0.103.9 (T368463)