)]}'
{"/PATCHSET_LEVEL":[{"author":{"_account_id":5890,"name":"Doug Goldstein","email":"cardoe@cardoe.com","username":"cardoe"},"change_message_id":"4526592066b6a80306f1dd53db825a524f65edd5","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":1,"id":"37f09fed_492abf94","updated":"2026-10-04 13:28:44.000000000","message":"Can we also backport this?","commit_id":"884537ba13fc9d9be7a42709a2cdc2ac513bcdbf"}],"neutron/common/wsgi_utils.py":[{"author":{"_account_id":16688,"name":"Rodolfo Alonso","email":"ralonsoh@redhat.com","username":"rodolfo-alonso-hernandez"},"change_message_id":"a57c0b88888058d30366c994e089a6f4468ccecc","unresolved":true,"context_lines":[{"line_number":28,"context_line":"_start_time \u003d None"},{"line_number":29,"context_line":""},{"line_number":30,"context_line":""},{"line_number":31,"context_line":"def _parent_start_time(ppid: int) -\u003e int | None:"},{"line_number":32,"context_line":"    \"\"\"Return the parent process\u0027 start time in clock ticks since boot."},{"line_number":33,"context_line":""},{"line_number":34,"context_line":"    This is read from field 22 (\"starttime\") of ``/proc/\u003cppid\u003e/stat``."}],"source_content_type":"text/x-python","patch_set":1,"id":"497c1e89_b58c4c19","line":31,"updated":"2026-10-05 09:15:55.000000000","message":"I have several comments related to this patch, in order:\n\n1) Containerized environment.\nBy default, the parent process of another inside a container will be PID 1, unless `--pid\u003dhost / hostPID: true` is passed. That means that, by default, all parent processes will be the same (1).\n\nThe `_write_temp_file` new implementation, checking first if the `\u003cpath\u003e.boot` file is stale or not, is not atomic. The initial goal of `_write_temp_file` was to only execute a command (to write a new file). If that command failed, we assumed this file was written by other process. But there is not previous read nor other process. That makes this method atomic.\n\nFor now, if the container returns PPID\u003d\u003d1, I would assume that the `hostPID` flag is not set and we cannot retrieve it. So I would fall back to the UWSGi behavior:\n* Read the first worker from the uswgi module (https://github.com/openstack/neutron/blob/stable/2026.1/neutron/common/wsgi_utils.py#L57)\n* Read the start time from the config (https://github.com/openstack/neutron/blob/stable/2026.1/neutron/common/wsgi_utils.py#L44)\n\nThat means, in a containerized environment without `hostPID` flag, we can only run with uWSGI. That must be documented.\n\nWe should re-implement again the uWSGI methods in https://github.com/openstack/neutron/blob/stable/2026.1/neutron/common/wsgi_utils.py.\n\n2) Environments able to read the PPID\nI would simplify the logic here:\n* Call a new `init` method in `api_server` [1], before `app \u003d config.load_paste_app(\u0027neutron\u0027)`.\n* This method will write the start time (or read it) and determine if the worker is the first one or not. That could be stored in constants in this file.\n\nThat will be done for any mech driver (OVN, OVS) and it will be done before starting the mech driver plugin class. But that will be done be worker, as long as we no longer support the eventlet server.\n\nThis could be done both for uWSGI (case 1) and other WSGI servers.\n\n[1]https://github.com/openstack/neutron/blob/master/neutron/server/api.py#L28","commit_id":"884537ba13fc9d9be7a42709a2cdc2ac513bcdbf"},{"author":{"_account_id":1131,"name":"Brian Haley","email":"haleyb.dev@gmail.com","username":"brian-haley"},"change_message_id":"8716018829d0e8161c3005244e3c6213d4295158","unresolved":true,"context_lines":[{"line_number":28,"context_line":"_start_time \u003d None"},{"line_number":29,"context_line":""},{"line_number":30,"context_line":""},{"line_number":31,"context_line":"def _parent_start_time(ppid: int) -\u003e int | None:"},{"line_number":32,"context_line":"    \"\"\"Return the parent process\u0027 start time in clock ticks since boot."},{"line_number":33,"context_line":""},{"line_number":34,"context_line":"    This is read from field 22 (\"starttime\") of ``/proc/\u003cppid\u003e/stat``."}],"source_content_type":"text/x-python","patch_set":1,"id":"65cc77a4_5a1bbbb2","line":31,"in_reply_to":"497c1e89_b58c4c19","updated":"2026-10-05 22:01:30.000000000","message":"I\u0027ll try and address these comments in an update.","commit_id":"884537ba13fc9d9be7a42709a2cdc2ac513bcdbf"},{"author":{"_account_id":1131,"name":"Brian Haley","email":"haleyb.dev@gmail.com","username":"brian-haley"},"change_message_id":"c5dbad38e4018d897f946099593a4a8625d60a5b","unresolved":false,"context_lines":[{"line_number":28,"context_line":"_start_time \u003d None"},{"line_number":29,"context_line":""},{"line_number":30,"context_line":""},{"line_number":31,"context_line":"def _parent_start_time(ppid: int) -\u003e int | None:"},{"line_number":32,"context_line":"    \"\"\"Return the parent process\u0027 start time in clock ticks since boot."},{"line_number":33,"context_line":""},{"line_number":34,"context_line":"    This is read from field 22 (\"starttime\") of ``/proc/\u003cppid\u003e/stat``."}],"source_content_type":"text/x-python","patch_set":1,"id":"1c29e207_4b2ea157","line":31,"in_reply_to":"65cc77a4_5a1bbbb2","updated":"2026-10-09 00:34:31.000000000","message":"Done","commit_id":"884537ba13fc9d9be7a42709a2cdc2ac513bcdbf"},{"author":{"_account_id":5890,"name":"Doug Goldstein","email":"cardoe@cardoe.com","username":"cardoe"},"change_message_id":"4526592066b6a80306f1dd53db825a524f65edd5","unresolved":true,"context_lines":[{"line_number":55,"context_line":"        fields \u003d rest.split()"},{"line_number":56,"context_line":"        # \"starttime\" is field 22 (1-indexed) overall. Fields 1 (pid) and"},{"line_number":57,"context_line":"        # 2 (comm) were stripped above, so it is at index 19 of `fields`."},{"line_number":58,"context_line":"        return int(fields[19])"},{"line_number":59,"context_line":"    except (OSError, IndexError, ValueError):"},{"line_number":60,"context_line":"        return None"},{"line_number":61,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"47b77057_faa09582","line":58,"updated":"2026-10-04 13:28:44.000000000","message":"Would it be safer to use psutils? Your comments and exception catching seem sound. Just asking.","commit_id":"884537ba13fc9d9be7a42709a2cdc2ac513bcdbf"},{"author":{"_account_id":1131,"name":"Brian Haley","email":"haleyb.dev@gmail.com","username":"brian-haley"},"change_message_id":"c5dbad38e4018d897f946099593a4a8625d60a5b","unresolved":false,"context_lines":[{"line_number":55,"context_line":"        fields \u003d rest.split()"},{"line_number":56,"context_line":"        # \"starttime\" is field 22 (1-indexed) overall. Fields 1 (pid) and"},{"line_number":57,"context_line":"        # 2 (comm) were stripped above, so it is at index 19 of `fields`."},{"line_number":58,"context_line":"        return int(fields[19])"},{"line_number":59,"context_line":"    except (OSError, IndexError, ValueError):"},{"line_number":60,"context_line":"        return None"},{"line_number":61,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"ad6b5e87_6534ac75","line":58,"in_reply_to":"304abde7_b7550bdc","updated":"2026-10-09 00:34:31.000000000","message":"Done","commit_id":"884537ba13fc9d9be7a42709a2cdc2ac513bcdbf"},{"author":{"_account_id":16688,"name":"Rodolfo Alonso","email":"ralonsoh@redhat.com","username":"rodolfo-alonso-hernandez"},"change_message_id":"a57c0b88888058d30366c994e089a6f4468ccecc","unresolved":true,"context_lines":[{"line_number":55,"context_line":"        fields \u003d rest.split()"},{"line_number":56,"context_line":"        # \"starttime\" is field 22 (1-indexed) overall. Fields 1 (pid) and"},{"line_number":57,"context_line":"        # 2 (comm) were stripped above, so it is at index 19 of `fields`."},{"line_number":58,"context_line":"        return int(fields[19])"},{"line_number":59,"context_line":"    except (OSError, IndexError, ValueError):"},{"line_number":60,"context_line":"        return None"},{"line_number":61,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"b48faa9e_2225cbb8","line":58,"in_reply_to":"47b77057_faa09582","updated":"2026-10-05 09:15:55.000000000","message":"Correct, this could be done via `psutil`:\n\n```\nproc \u003d psutil.Process(pid)          # the process we care about\nparent \u003d proc.parent()              # psutil.Process object for parent, or None\nif parent is None or parent.pid \u003d\u003d 1:\n    # Use the wWSGI default retrieval method\n    \u003csome code...\u003e\n\nstart_epoch \u003d parent.create_time()  # seconds since the Unix epoch\n```","commit_id":"884537ba13fc9d9be7a42709a2cdc2ac513bcdbf"},{"author":{"_account_id":1131,"name":"Brian Haley","email":"haleyb.dev@gmail.com","username":"brian-haley"},"change_message_id":"8716018829d0e8161c3005244e3c6213d4295158","unresolved":true,"context_lines":[{"line_number":55,"context_line":"        fields \u003d rest.split()"},{"line_number":56,"context_line":"        # \"starttime\" is field 22 (1-indexed) overall. Fields 1 (pid) and"},{"line_number":57,"context_line":"        # 2 (comm) were stripped above, so it is at index 19 of `fields`."},{"line_number":58,"context_line":"        return int(fields[19])"},{"line_number":59,"context_line":"    except (OSError, IndexError, ValueError):"},{"line_number":60,"context_line":"        return None"},{"line_number":61,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"304abde7_b7550bdc","line":58,"in_reply_to":"b48faa9e_2225cbb8","updated":"2026-10-05 22:01:30.000000000","message":"Yes, that seems a much better way will work on it.","commit_id":"884537ba13fc9d9be7a42709a2cdc2ac513bcdbf"},{"author":{"_account_id":16688,"name":"Rodolfo Alonso","email":"ralonsoh@redhat.com","username":"rodolfo-alonso-hernandez"},"change_message_id":"d09f127dae9b09b6a00f4f3a7ef70d87ee2af9f7","unresolved":true,"context_lines":[{"line_number":24,"context_line":""},{"line_number":25,"context_line":"LOG \u003d logging.getLogger(__name__)"},{"line_number":26,"context_line":""},{"line_number":27,"context_line":"_first_worker_result \u003d None"},{"line_number":28,"context_line":"_start_time \u003d None"},{"line_number":29,"context_line":""},{"line_number":30,"context_line":"# PID of the \"init\" process inside a container run without"}],"source_content_type":"text/x-python","patch_set":3,"id":"36f731ea_b590cfb7","line":27,"range":{"start_line":27,"start_character":0,"end_line":27,"end_character":20},"updated":"2026-11-12 15:54:31.000000000","message":"nit: just `_first_worker`","commit_id":"2a8b8ab0500ebf41a0efcd041c2d7a042e3b6e5e"},{"author":{"_account_id":16688,"name":"Rodolfo Alonso","email":"ralonsoh@redhat.com","username":"rodolfo-alonso-hernandez"},"change_message_id":"d09f127dae9b09b6a00f4f3a7ef70d87ee2af9f7","unresolved":true,"context_lines":[{"line_number":213,"context_line":"    PID). ``O_CREAT | O_EXCL`` is atomic: exactly one process succeeds in"},{"line_number":214,"context_line":"    creating the file and becomes the \"first\" worker."},{"line_number":215,"context_line":""},{"line_number":216,"context_line":"    When the parent is PID 1 (container without ``--pid\u003dhost``/"},{"line_number":217,"context_line":"    ``hostPID: true``), the election can only be reliably supported under"},{"line_number":218,"context_line":"    uWSGI; see :func:`get_start_time` for details."},{"line_number":219,"context_line":"    \"\"\""},{"line_number":220,"context_line":"    global _first_worker_result"},{"line_number":221,"context_line":"    if _first_worker_result is not None:"}],"source_content_type":"text/x-python","patch_set":3,"id":"2f807a5e_3665e48e","line":218,"range":{"start_line":216,"start_character":4,"end_line":218,"end_character":50},"updated":"2026-11-12 15:54:31.000000000","message":"I think we should fail in the case of:\n* Containers without hostPID\n* Not uWSGI\n\nIn that case we can\u0027t reliably determine the first worker, as long as the Neutron API container shared a permanent storage place in the host and the `neutron_first_worker` file is not deleted. In that case, when the container is restarted, none of the API workers will be defined as first.","commit_id":"2a8b8ab0500ebf41a0efcd041c2d7a042e3b6e5e"}],"neutron/server/api.py":[{"author":{"_account_id":16688,"name":"Rodolfo Alonso","email":"ralonsoh@redhat.com","username":"rodolfo-alonso-hernandez"},"change_message_id":"d09f127dae9b09b6a00f4f3a7ef70d87ee2af9f7","unresolved":true,"context_lines":[{"line_number":48,"context_line":""},{"line_number":49,"context_line":"def api_server():"},{"line_number":50,"context_line":"    profiler.setup(\u0027neutron-server\u0027, cfg.CONF.host)"},{"line_number":51,"context_line":"    init()"},{"line_number":52,"context_line":"    app \u003d config.load_paste_app(\u0027neutron\u0027)"},{"line_number":53,"context_line":"    registry.publish(resources.PROCESS, events.BEFORE_SPAWN,"},{"line_number":54,"context_line":"                     wsgi.WorkerService)"}],"source_content_type":"text/x-python","patch_set":3,"id":"19189d62_6ad37eaa","line":51,"range":{"start_line":51,"start_character":4,"end_line":51,"end_character":8},"updated":"2026-11-12 15:54:31.000000000","message":"nit: I would make this private\n\nI would also implement this method in `wsgi_utils`, not here.","commit_id":"2a8b8ab0500ebf41a0efcd041c2d7a042e3b6e5e"}]}
