)]}'
{"/PATCHSET_LEVEL":[{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"b4fc5af914791e8140ca41149b05e5585f85084b","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":1,"id":"18afda2f_84ab8927","updated":"2026-11-13 16:49:09.000000000","message":"Not -1 because I\u0027m genuinely not sure about this one 😕","commit_id":"6b5b166af876d4e58315f3702a349868785c008e"}],"openstack/cloud/openstackcloud.py":[{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"b4fc5af914791e8140ca41149b05e5585f85084b","unresolved":true,"context_lines":[{"line_number":253,"context_line":"        self._pool_executor_holder: list["},{"line_number":254,"context_line":"            concurrent.futures.Executor | None"},{"line_number":255,"context_line":"        ] \u003d [pool_executor]"},{"line_number":256,"context_line":"        if session is not None and not config:"},{"line_number":257,"context_line":"            # A caller-supplied session is the session every proxy will"},{"line_number":258,"context_line":"            # actually use: from_session/from_conf route it into the"},{"line_number":259,"context_line":"            # CloudRegion and config.get_session() returns it, which"}],"source_content_type":"text/x-python","patch_set":1,"id":"d8097630_2e619d96","line":256,"updated":"2026-11-13 16:49:09.000000000","message":"I think there might be another bug here. The conditional here is because we ignore `session` entirely if `config` was passed in since that contains its own session (via `_keystone_session`). We store a reference to that in `_session_holder` if we access the `session` property. It\u0027s possible that the `CloudRegion` provided via `config` was created with a `session` argument. Should we be taking ownership of this and closing it, or is that the responsibility of the caller?","commit_id":"6b5b166af876d4e58315f3702a349868785c008e"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"9748ff8115dc5cfd5715ccc3b5952f592d45d784","unresolved":true,"context_lines":[{"line_number":253,"context_line":"        self._pool_executor_holder: list["},{"line_number":254,"context_line":"            concurrent.futures.Executor | None"},{"line_number":255,"context_line":"        ] \u003d [pool_executor]"},{"line_number":256,"context_line":"        if session is not None and not config:"},{"line_number":257,"context_line":"            # A caller-supplied session is the session every proxy will"},{"line_number":258,"context_line":"            # actually use: from_session/from_conf route it into the"},{"line_number":259,"context_line":"            # CloudRegion and config.get_session() returns it, which"}],"source_content_type":"text/x-python","patch_set":1,"id":"c690631d_fe75fd77","line":256,"in_reply_to":"462a88db_19db6259","updated":"2026-11-25 15:03:38.000000000","message":"\u003e This only populates the holder for the from_session/from_conf path: the caller-supplied session is the one the proxies actually use, and since they get it from config.get_session() directly, nothing else would ever put it in the holder — close() and the finalizer would release nothing.\n\nThis code here only populates it for those paths, but it is then populated for for all paths as soon as someone hits the `session` attribute.\n\nI\u0027m thinking we need to track ownership here. It should be as simple as storing a private attribute (e.g. `self._owns_config \u003d not config`) which we can use to determine whether we should close or leave it to the caller.\n\nIf we wanted to go the extra mile, I\u0027d likely add a `close` method on the `CloudRegion` class also. That way I think we could remove `_session_holder` and just call `config.close()` in `_run_close`?","commit_id":"6b5b166af876d4e58315f3702a349868785c008e"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"64f5fd97789b0cd1146c53cb8e19b094131585cc","unresolved":false,"context_lines":[{"line_number":253,"context_line":"        self._pool_executor_holder: list["},{"line_number":254,"context_line":"            concurrent.futures.Executor | None"},{"line_number":255,"context_line":"        ] \u003d [pool_executor]"},{"line_number":256,"context_line":"        if session is not None and not config:"},{"line_number":257,"context_line":"            # A caller-supplied session is the session every proxy will"},{"line_number":258,"context_line":"            # actually use: from_session/from_conf route it into the"},{"line_number":259,"context_line":"            # CloudRegion and config.get_session() returns it, which"}],"source_content_type":"text/x-python","patch_set":1,"id":"ff6b75d3_731597df","line":256,"in_reply_to":"4f3f47f7_c523b241","updated":"2026-11-25 17:53:00.000000000","message":"Done","commit_id":"6b5b166af876d4e58315f3702a349868785c008e"},{"author":{"_account_id":28647,"name":"David","display_name":"morenod","email":"dsanzmor@redhat.com","username":"morenod"},"change_message_id":"684702078a3eb4fe81cf773cdbdccb96d06274f2","unresolved":true,"context_lines":[{"line_number":253,"context_line":"        self._pool_executor_holder: list["},{"line_number":254,"context_line":"            concurrent.futures.Executor | None"},{"line_number":255,"context_line":"        ] \u003d [pool_executor]"},{"line_number":256,"context_line":"        if session is not None and not config:"},{"line_number":257,"context_line":"            # A caller-supplied session is the session every proxy will"},{"line_number":258,"context_line":"            # actually use: from_session/from_conf route it into the"},{"line_number":259,"context_line":"            # CloudRegion and config.get_session() returns it, which"}],"source_content_type":"text/x-python","patch_set":1,"id":"4f3f47f7_c523b241","line":256,"in_reply_to":"8f32cc91_4291d0f4","updated":"2026-11-25 17:14:46.000000000","message":"Done as suggested in PS3: the connection tracks self._owns_config \u003d not config, and both close() and the finalizer skip the session release when the region came from the caller. Your shared-region repro is now covered by test_close_keeps_config_provided_session.","commit_id":"6b5b166af876d4e58315f3702a349868785c008e"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"8317d1d17af8ce318cf9a5a2a34fbf4e12589ec7","unresolved":true,"context_lines":[{"line_number":253,"context_line":"        self._pool_executor_holder: list["},{"line_number":254,"context_line":"            concurrent.futures.Executor | None"},{"line_number":255,"context_line":"        ] \u003d [pool_executor]"},{"line_number":256,"context_line":"        if session is not None and not config:"},{"line_number":257,"context_line":"            # A caller-supplied session is the session every proxy will"},{"line_number":258,"context_line":"            # actually use: from_session/from_conf route it into the"},{"line_number":259,"context_line":"            # CloudRegion and config.get_session() returns it, which"}],"source_content_type":"text/x-python","patch_set":1,"id":"8f32cc91_4291d0f4","line":256,"in_reply_to":"c690631d_fe75fd77","updated":"2026-11-25 16:00:49.000000000","message":"\u003e If we wanted to go the extra mile, I\u0027d likely add a `close` method on the `CloudRegion` class also. That way I think we could remove `_session_holder` and just call `config.close()` in `_run_close`?\n\nI took a punt at this in https://review.opendev.org/c/openstack/openstacksdk/+/1017415","commit_id":"6b5b166af876d4e58315f3702a349868785c008e"},{"author":{"_account_id":28647,"name":"David","display_name":"morenod","email":"dsanzmor@redhat.com","username":"morenod"},"change_message_id":"44b53e222a434f0830600fff70dac1bf7716817a","unresolved":true,"context_lines":[{"line_number":253,"context_line":"        self._pool_executor_holder: list["},{"line_number":254,"context_line":"            concurrent.futures.Executor | None"},{"line_number":255,"context_line":"        ] \u003d [pool_executor]"},{"line_number":256,"context_line":"        if session is not None and not config:"},{"line_number":257,"context_line":"            # A caller-supplied session is the session every proxy will"},{"line_number":258,"context_line":"            # actually use: from_session/from_conf route it into the"},{"line_number":259,"context_line":"            # CloudRegion and config.get_session() returns it, which"}],"source_content_type":"text/x-python","patch_set":1,"id":"462a88db_19db6259","line":256,"in_reply_to":"d8097630_2e619d96","updated":"2026-11-19 10:32:43.000000000","message":"This only populates the holder for the from_session/from_conf path: the caller-supplied session is the one the proxies actually use, and since they get it from config.get_session() directly, nothing else would ever put it in the holder — close() and the finalizer would release nothing.\n\nAs for a region built with a caller session: we only close what keystoneauth1 itself created. keystoneauth1 populates Session._session only for the requests sessions it constructs; a caller-supplied one is never closed by us. The shared-region case is the separate issue in the line 341 comment.","commit_id":"6b5b166af876d4e58315f3702a349868785c008e"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"b4fc5af914791e8140ca41149b05e5585f85084b","unresolved":true,"context_lines":[{"line_number":338,"context_line":"    @property"},{"line_number":339,"context_line":"    def session(self) -\u003e \u0027ks_session.Session\u0027:"},{"line_number":340,"context_line":"        if not self._session:"},{"line_number":341,"context_line":"            self._session \u003d self.config.get_session()"},{"line_number":342,"context_line":"        # Hide a reference to the connection on the session to help with"},{"line_number":343,"context_line":"        # backwards compatibility for folks trying to just pass"},{"line_number":344,"context_line":"        # conn.session to a Resource method\u0027s session argument. Done on"}],"source_content_type":"text/x-python","patch_set":1,"id":"07545ea4_2bb04c2a","line":341,"updated":"2026-11-13 16:49:09.000000000","message":"Here:\n\n```\n\u003e\u003e\u003e from openstack import config\n\u003e\u003e\u003e from openstack import connection\n\u003e\u003e\u003e region \u003d config.get_cloud_region(cloud\u003d\u0027psi\u0027)\n\u003e\u003e\u003e conn_a \u003d connection.Connection(config\u003dregion)\n\u003e\u003e\u003e conn_b \u003d connection.Connection(config\u003dregion)\n\u003e\u003e\u003e list(conn_a.network.networks())[0]\n... \u003csnipped\u003e ...\n\u003e\u003e\u003e list(conn_b.network.networks())[0]\n... \u003csnipped\u003e ...\n\u003e\u003e\u003e # seems this is the only \"easy\" way to know \"was a session closed?\"\n\u003e\u003e\u003e len(conn_b._session.session.get_adapter(\u0027https://\u0027).poolmanager.pools)\n3\n\u003e\u003e\u003e conn_a.close()\n\u003e\u003e\u003e len(conn_b._session.session.get_adapter(\u0027https://\u0027).poolmanager.pools)\n0\n```\n\nI would assume we shouldn\u0027t be closing the config-provided session?","commit_id":"6b5b166af876d4e58315f3702a349868785c008e"},{"author":{"_account_id":28647,"name":"David","display_name":"morenod","email":"dsanzmor@redhat.com","username":"morenod"},"change_message_id":"44b53e222a434f0830600fff70dac1bf7716817a","unresolved":true,"context_lines":[{"line_number":338,"context_line":"    @property"},{"line_number":339,"context_line":"    def session(self) -\u003e \u0027ks_session.Session\u0027:"},{"line_number":340,"context_line":"        if not self._session:"},{"line_number":341,"context_line":"            self._session \u003d self.config.get_session()"},{"line_number":342,"context_line":"        # Hide a reference to the connection on the session to help with"},{"line_number":343,"context_line":"        # backwards compatibility for folks trying to just pass"},{"line_number":344,"context_line":"        # conn.session to a Resource method\u0027s session argument. Done on"}],"source_content_type":"text/x-python","patch_set":1,"id":"6213fec9_c96cc559","line":341,"in_reply_to":"07545ea4_2bb04c2a","updated":"2026-11-19 10:32:43.000000000","message":"The reason it closes at all is the default case — one Connection per region, where the region lazily creates the session and close() is what releases its pooled sockets. The shared-region case you show is the sharp edge: whoever closes first drains the pools of the rest, though pools rebuild on demand, so it\u0027s reconnect cost rather than breakage.\n\nFixing that properly needs ownership tracking — e.g. reference-counting Connections per session and only closing on the last one. I\u0027d rather do that as a follow-up","commit_id":"6b5b166af876d4e58315f3702a349868785c008e"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"64f5fd97789b0cd1146c53cb8e19b094131585cc","unresolved":false,"context_lines":[{"line_number":338,"context_line":"    @property"},{"line_number":339,"context_line":"    def session(self) -\u003e \u0027ks_session.Session\u0027:"},{"line_number":340,"context_line":"        if not self._session:"},{"line_number":341,"context_line":"            self._session \u003d self.config.get_session()"},{"line_number":342,"context_line":"        # Hide a reference to the connection on the session to help with"},{"line_number":343,"context_line":"        # backwards compatibility for folks trying to just pass"},{"line_number":344,"context_line":"        # conn.session to a Resource method\u0027s session argument. Done on"}],"source_content_type":"text/x-python","patch_set":1,"id":"7d56786a_1f06f281","line":341,"in_reply_to":"6213fec9_c96cc559","updated":"2026-11-25 17:53:00.000000000","message":"Done","commit_id":"6b5b166af876d4e58315f3702a349868785c008e"}],"openstack/tests/unit/cloud/test_cloud.py":[{"author":{"_account_id":22348,"name":"Zuul","username":"zuul","tags":["SERVICE_USER"]},"tag":"autogenerated:zuul:check","change_message_id":"6f1907f3e534e01c824631fdae00743641a26f27","unresolved":false,"context_lines":[{"line_number":140,"context_line":"        self.assertIsNotNone(requests_session)"},{"line_number":141,"context_line":"        # deliberately do NOT touch conn.session before closing"},{"line_number":142,"context_line":"        with mock.patch.object("},{"line_number":143,"context_line":"            requests_session, \u0027close\u0027, wraps\u003drequests_session.close"},{"line_number":144,"context_line":"        ) as close_mock:"},{"line_number":145,"context_line":"            conn.close()"},{"line_number":146,"context_line":"        close_mock.assert_called_once()"}],"source_content_type":"text/x-python","patch_set":1,"id":"d55860cc_7cc31f3e","line":143,"updated":"2026-11-13 16:17:33.000000000","message":"pep8: error: Item \"None\" of \"Session | None\" has no attribute \"close\"  [union-attr]","commit_id":"6b5b166af876d4e58315f3702a349868785c008e"},{"author":{"_account_id":22348,"name":"Zuul","username":"zuul","tags":["SERVICE_USER"]},"tag":"autogenerated:zuul:check","change_message_id":"6f1907f3e534e01c824631fdae00743641a26f27","unresolved":false,"context_lines":[{"line_number":153,"context_line":"        # session, so it must not depend on that code path)."},{"line_number":154,"context_line":"        ks \u003d ks_session.Session()"},{"line_number":155,"context_line":"        conn \u003d connection.Connection(session\u003dks)"},{"line_number":156,"context_line":"        self.assertEqual(ks._sdk_connection, conn)"},{"line_number":157,"context_line":""},{"line_number":158,"context_line":"    def test_close_swallows_session_close_error(self):"},{"line_number":159,"context_line":"        # close() also runs from the finalizer at interpreter shutdown and"}],"source_content_type":"text/x-python","patch_set":1,"id":"10767062_5a50abed","line":156,"updated":"2026-11-13 16:17:33.000000000","message":"pep8: error: \"Session\" has no attribute \"_sdk_connection\"  [attr-defined]","commit_id":"6b5b166af876d4e58315f3702a349868785c008e"}]}
