From t.stark at f5.com Thu Dec 15 21:51:48 2022 From: t.stark at f5.com (Timo Stark) Date: Thu, 15 Dec 2022 21:51:48 +0000 Subject: Unit 1.29. released Message-ID: Hi, NGINX Unit community, We are happy to announce Unit 1.29.0! This release sets the first milestone for NGINX's JavaScript runtime, njs, on Unit and also introduces the first version of a Unit-specific CLI. Now you can use njs to define JavaScript-based template literals in the configuration; evaluated at run time, they can be anywhere that supports variables to customize Unit's behavior. This is only the beginning of a new feature series based on the NGINX JavaScript project. Next, we introduce the very first of Unit-related tools to assist new users. If you want to fast-track to get your first configuration up and running or use Unit’s control API as intended, the “curl wrapper” command-line script, unitc, will surely help. In addition, version 1.29.0 also adds: *) per-application cgroups; now, you can place each app into a separate cgroup or tie them together. *) new "prefix" attribute for Python applications. *) new $request_time variable. *) fixes for a few community-reported bugs. For more information about the new features, visit: https://unit.nginx.org/news/2022/unit-1.29.0-released/ Changes with Unit 1.29.0 15 Dec 2022 *) Change: removed $uri auto-append for "share" when loading configuration. *) Change: prefer system crypto policy instead of hardcoding a default. *) Feature: njs support with the basic syntax of JS template literals. *) Feature: support per-application cgroups on Linux. *) Feature: the $request_time variable contains the request processing time. *) Feature: "prefix" option in Python applications to set WSGI "SCRIPT_NAME" and ASGI root-path variables. *) Feature: compatibility with Python 3.11. *) Feature: compatibility with OpenSSL 3. *) Feature: compatibility with PHP 8.2. *) Feature: compatibility with Node.js 19.0. *) Feature: Ruby Rack v3 support. *) Bugfix: fix error in connection statistics when using proxy. *) Bugfix: fix HTTP cookie parsing when the value contains an equals sign. *) Bugfix: PHP directory URLs without a trailing '/' would give a 503 error (fixed with a 301 re-direct). *) Bugfix: missing error checks in the C API. *) Bugfix: report the regex status in configure summary. Platform Updates *) Added support for Ubuntu 22.10 *) Added support for Fedora 37 Wbr, Timo & the Unit team From tobias.genannt at kappa-velorum.net Fri Dec 16 12:28:24 2022 From: tobias.genannt at kappa-velorum.net (Tobias Genannt) Date: Fri, 16 Dec 2022 13:28:24 +0100 Subject: UnicodeEncodeError in Python application Message-ID: <0ea768ea-d611-b894-d4aa-e6b58574449f@kappa-velorum.net> Hello, I'm seeing a crash in a Python application with Unit 1.29 which is not happening in Unit 1.28. I'm not sure if I have to change the configuration for this version bump because I didn't find an entry in the changelog which would point to the problem. This is the stack trace: 2022/12/16 10:03:34 [alert] 29#29 Python failed to import module "netbox.wsgi" Traceback (most recent call last): File "/opt/netbox/netbox/netbox/wsgi.py", line 7, in application = get_wsgi_application() File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application django.setup(set_prefix=False) File "/opt/netbox/venv/lib/python3.10/site-packages/django/__init__.py", line 19, in setup configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) File "/opt/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 92, in __getattr__ self._setup(name) File "/opt/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 79, in _setup self._wrapped = Settings(settings_module) File "/opt/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 190, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/opt/netbox/netbox/netbox/settings.py", line 50, in configuration = importlib.import_module(config_path) File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/opt/netbox/netbox/netbox/configuration.py", line 71, in _loaded_configurations = read_configurations( File "/opt/netbox/netbox/netbox/configuration.py", line 33, in read_configurations _import(f"{config_module}.{main_config}", main_config_path, loaded_configurations) File "/opt/netbox/netbox/netbox/configuration.py", line 25, in _import print(f"\U0001f9ec loaded config '{path}'") UnicodeEncodeError: 'ascii' codec can't encode character '\U0001f9ec' in position 0: ordinal not in range(128) You can find the contents of the problematic file (last strack trace entry) here: https://github.com/tobiasge/netbox-docker/blob/new-unit/docker/configuration.docker.py I'm using this configuration for Unit: https://github.com/tobiasge/netbox-docker/blob/new-unit/docker/nginx-unit.json In the image I have the LANG variable set to 'C.utf8'. The output of 'locale -a' is this: C C.utf8 POSIX Thanks in advance for any hints on how to fix this. Greetings, Tobias From andrew at digital-domain.net Wed Dec 21 14:41:47 2022 From: andrew at digital-domain.net (Andrew Clayton) Date: Wed, 21 Dec 2022 14:41:47 +0000 Subject: UnicodeEncodeError in Python application In-Reply-To: <0ea768ea-d611-b894-d4aa-e6b58574449f@kappa-velorum.net> References: <0ea768ea-d611-b894-d4aa-e6b58574449f@kappa-velorum.net> Message-ID: <20221221144147.222362e1@kappa.digital-domain.net> On Fri, 16 Dec 2022 13:28:24 +0100 Tobias Genannt wrote: > Hello, Hi!, > I'm seeing a crash in a Python application with Unit 1.29 which is not > happening in Unit 1.28. I'm not sure if I have to change the > configuration for this version bump because I didn't find an entry in No, you shouldn't. > the changelog which would point to the problem. > This is the stack trace: [...] > print(f"\U0001f9ec loaded config '{path}'") > UnicodeEncodeError: 'ascii' codec can't encode character '\U0001f9ec' in > position 0: ordinal not in range(128) OK, so looks like a unicode issue. > You can find the contents of the problematic file (last strack trace > entry) here: > https://github.com/tobiasge/netbox-docker/blob/new-unit/docker/configuration.docker.py I did quickly try reproducing this using current unit master and Python 3.11 { "listeners": { "[::1]:8080": { "pass": "applications/python" } }, "applications": { "python": { "type": "python", "path": "/srv/unit/python/app/", "module": "app" } } } $ cat /srv/unit/python/app/app.py def application(environ, start_response): start_response("200 OK", [("Content-Type", "text/plain")]) print("⚠️ test\n"); return (b"Hello, Python on Unit!\n") which works OK. There aren't that many Python changes since 1.28.0 $ git log --oneline 1.28.0.. src/python/ 6dae517e Python: Added "prefix" to configuration. 491d0f70 Python: Added support for Python 3.11. 6902cd14 Refactored functions that set WSGI variables. 3b970ed9 Removed dead code. 40d75c94 Optimization for the "--no-unix-sockets" case. b0098336 Renamed a couple of members of nxt_unit_request_t. If you're up for it, could you try reverting 491d0f70 ("Python: Added support for Python 3.11.")? $ git clone https://github.com/nginx/unit.git $ cd unit $ git revert -n 491d0f70 (ignore the warnings...) build unit and the python module etc and test. If things are still broken $ git reset --hard $ git revert -n 6902cd14 build/install and test again. If things are still broken, you could repeat the above with the other commits. Alternatively, if you have a simple bare minimum reproducer... > Greetings, > Tobias Cheers, Andrew From andrew at digital-domain.net Wed Dec 21 14:50:01 2022 From: andrew at digital-domain.net (Andrew Clayton) Date: Wed, 21 Dec 2022 14:50:01 +0000 Subject: [info] SSL_read(...) failed (104: Connection reset by peer) In-Reply-To: <6BCC34C8-7D5F-45AC-BB52-DDFB3AB4F00F@gmail.com> References: <4988E1FB-49F3-4453-89D2-A1A239C756C6@nginx.com> <45C8FB3D-820A-4B5C-90FA-933B2D40DB91@gmail.com> <20221101190747.340e37de@kappa.digital-domain.net> <6BCC34C8-7D5F-45AC-BB52-DDFB3AB4F00F@gmail.com> Message-ID: <20221221145001.5d3e207e@kappa.digital-domain.net> On Fri, 11 Nov 2022 10:25:34 +0100 Ariel Goyeneche wrote: > Hi Team, > > I am running Nginx Unit 1.28 with Python 3.9.12 as embedded language. All seems fine, except a random entry in the logs saying > > [info] SSL_read(...) failed (104: Connection reset by peer) > > I don’t see neither receive any feedback that the web servers are dropping any calls, but I wonder what may produce this info line? > Does anyone experienced this before? It's something you'll see from time to time. It just means the other end terminated the connection by sending a RST packet rather than doing a clean shutdown of the connection. > Thanks in advance, > AG Andrew From tobias.genannt at kappa-velorum.net Wed Dec 21 20:40:59 2022 From: tobias.genannt at kappa-velorum.net (Tobias Genannt) Date: Wed, 21 Dec 2022 21:40:59 +0100 Subject: UnicodeEncodeError in Python application In-Reply-To: <20221221144147.222362e1@kappa.digital-domain.net> References: <0ea768ea-d611-b894-d4aa-e6b58574449f@kappa-velorum.net> <20221221144147.222362e1@kappa.digital-domain.net> Message-ID: <8033b370-fd32-8e8a-fcde-f0745cb7af06@kappa-velorum.net> Hi Andrew, thanks for the instructions those tests. I managed to run the build of Unit directly in the container image I'm using. After I reverted the commit 491d0f70 and started the newly build Unit the application loaded without problems. Greetings Tobias On 21/12/2022 15:41, Andrew Clayton wrote: > On Fri, 16 Dec 2022 13:28:24 +0100 > Tobias Genannt wrote: > >> Hello, > > Hi!, > >> I'm seeing a crash in a Python application with Unit 1.29 which is not >> happening in Unit 1.28. I'm not sure if I have to change the >> configuration for this version bump because I didn't find an entry in > > No, you shouldn't. > >> the changelog which would point to the problem. >> This is the stack trace: > > [...] > >> print(f"\U0001f9ec loaded config '{path}'") >> UnicodeEncodeError: 'ascii' codec can't encode character '\U0001f9ec' in >> position 0: ordinal not in range(128) > > OK, so looks like a unicode issue. > >> You can find the contents of the problematic file (last strack trace >> entry) here: >> https://github.com/tobiasge/netbox-docker/blob/new-unit/docker/configuration.docker.py > > I did quickly try reproducing this using current unit master and Python > 3.11 > > { > "listeners": { > "[::1]:8080": { > "pass": "applications/python" > } > }, > > "applications": { > "python": { > "type": "python", > "path": "/srv/unit/python/app/", > "module": "app" > } > } > } > > $ cat /srv/unit/python/app/app.py > def application(environ, start_response): > start_response("200 OK", [("Content-Type", "text/plain")]) > print("⚠️ test\n"); > return (b"Hello, Python on Unit!\n") > > which works OK. > > There aren't that many Python changes since 1.28.0 > > $ git log --oneline 1.28.0.. src/python/ > 6dae517e Python: Added "prefix" to configuration. > 491d0f70 Python: Added support for Python 3.11. > 6902cd14 Refactored functions that set WSGI variables. > 3b970ed9 Removed dead code. > 40d75c94 Optimization for the "--no-unix-sockets" case. > b0098336 Renamed a couple of members of nxt_unit_request_t. > > If you're up for it, could you try reverting 491d0f70 ("Python: Added > support for Python 3.11.")? > > $ git clone https://github.com/nginx/unit.git > $ cd unit > > $ git revert -n 491d0f70 > > (ignore the warnings...) > > build unit and the python module etc and test. > > If things are still broken > > $ git reset --hard > $ git revert -n 6902cd14 > > build/install and test again. > > If things are still broken, you could repeat the above with the other > commits. > > Alternatively, if you have a simple bare minimum reproducer... > >> Greetings, >> Tobias > > Cheers, > Andrew From andrew at digital-domain.net Thu Dec 22 01:19:23 2022 From: andrew at digital-domain.net (Andrew Clayton) Date: Thu, 22 Dec 2022 01:19:23 +0000 Subject: UnicodeEncodeError in Python application In-Reply-To: <8033b370-fd32-8e8a-fcde-f0745cb7af06@kappa-velorum.net> References: <0ea768ea-d611-b894-d4aa-e6b58574449f@kappa-velorum.net> <20221221144147.222362e1@kappa.digital-domain.net> <8033b370-fd32-8e8a-fcde-f0745cb7af06@kappa-velorum.net> Message-ID: <20221222011923.00abaee6@kappa.digital-domain.net> On Wed, 21 Dec 2022 21:40:59 +0100 Tobias Genannt wrote: > Hi Andrew, Hi Tobias, > thanks for the instructions those tests. I managed to run the build of > Unit directly in the container image I'm using. After I reverted the > commit 491d0f70 and started the newly build Unit the application loaded > without problems. Thanks for testing. Looks like I'll have to dig around and and try and see what's going on here. I may have some patches for you to test at some point... Cheers, Andrew From andrew at digital-domain.net Fri Dec 30 15:46:23 2022 From: andrew at digital-domain.net (Andrew Clayton) Date: Fri, 30 Dec 2022 15:46:23 +0000 Subject: UnicodeEncodeError in Python application In-Reply-To: <20221222011923.00abaee6@kappa.digital-domain.net> References: <0ea768ea-d611-b894-d4aa-e6b58574449f@kappa-velorum.net> <20221221144147.222362e1@kappa.digital-domain.net> <8033b370-fd32-8e8a-fcde-f0745cb7af06@kappa-velorum.net> <20221222011923.00abaee6@kappa.digital-domain.net> Message-ID: <20221230154623.64959ec9@kappa.digital-domain.net> On Thu, 22 Dec 2022 01:19:23 +0000 Andrew Clayton wrote: Hi Tobias, > I may have some patches for you to test at some point... You could try this simple test/debug patch to see if it fixes the issue diff --git a/src/python/nxt_python.c b/src/python/nxt_python.c index bdb04579..0f9b373e 100644 --- a/src/python/nxt_python.c +++ b/src/python/nxt_python.c @@ -94,6 +94,8 @@ nxt_python3_init_config(nxt_int_t pep405) } } + PyConfig_SetString(&config, &config.filesystem_encoding, L"utf-8"); + status = Py_InitializeFromConfig(&config); if (PyStatus_Exception(status)) { goto pyinit_exception; You can also follow along @ https://github.com/nginx/unit/issues/817 Cheers, Andrew