GoogleCloudPlatform/cloud-sql-python-connector

system.test_connector_object: test_multiple_connectors failed

flaky-bot opened this issue · 2 comments

Note: #820 was also for this test, but it was closed more than 10 days ago. So, I didn't mark it flaky.


commit: 71b9347
buildURL: https://github.com/GoogleCloudPlatform/cloud-sql-python-connector/actions/runs/6177038374
status: failed

Test output
def test_multiple_connectors() -> None:
        """Test that same Cloud SQL instance can connect with two Connector objects."""
        first_connector = Connector()
        second_connector = Connector()
        try:
            pool = init_connection_engine(first_connector)
            pool2 = init_connection_engine(second_connector)
      with pool.connect() as conn:

tests/system/test_connector_object.py:81:


.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/engine/base.py:3264: in connect
return self._connection_cls(self)
.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/engine/base.py:145: in init
self._dbapi_connection = engine.raw_connection()
.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/engine/base.py:3288: in raw_connection
return self.pool.connect()
.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/pool/base.py:452: in connect
return _ConnectionFairy._checkout(self)
.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/pool/base.py:1267: in _checkout
fairy = _ConnectionRecord.checkout(pool)
.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/pool/base.py:716: in checkout
rec = pool._do_get()
.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/pool/impl.py:170: in _do_get
self._dec_overflow()
.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py:147: in exit
raise exc_value.with_traceback(exc_tb)
.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/pool/impl.py:167: in _do_get
return self._create_connection()
.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/pool/base.py:393: in _create_connection
return _ConnectionRecord(self)
.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/pool/base.py:678: in init
self.__connect()
.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/pool/base.py:903: in __connect
pool.logger.debug("Error on connect(): %s", e)
.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py:147: in exit
raise exc_value.with_traceback(exc_tb)
.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/pool/base.py:898: in __connect
self.dbapi_connection = connection = pool._invoke_creator(self)
.nox/system-3-8/lib/python3.8/site-packages/sqlalchemy/pool/base.py:365: in
return lambda rec: creator_fn()
tests/system/test_connector_object.py:38: in getconn
conn = custom_connector.connect(
google/cloud/sql/connector/connector.py:163: in connect
return connect_task.result()
../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/concurrent/futures/_base.py:444: in result
return self.__get_result()
../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/concurrent/futures/_base.py:389: in __get_result
raise self._exception
google/cloud/sql/connector/connector.py:208: in connect_async
instance = Instance(
google/cloud/sql/connector/instance.py:250: in init
self._credentials = _auth_init(credentials)
google/cloud/sql/connector/utils.py:124: in _auth_init
credentials, _ = default(scopes=scopes)
.nox/system-3-8/lib/python3.8/site-packages/google/auth/_default.py:675: in default
project_id = credentials.get_project_id(request=request)
.nox/system-3-8/lib/python3.8/site-packages/google/auth/external_account.py:339: in get_project_id
self.before_request(request, "GET", url, headers)
.nox/system-3-8/lib/python3.8/site-packages/google/auth/credentials.py:151: in before_request
self.refresh(request)
.nox/system-3-8/lib/python3.8/site-packages/google/auth/external_account.py:360: in refresh
self._impersonated_credentials.refresh(request)
.nox/system-3-8/lib/python3.8/site-packages/google/auth/impersonated_credentials.py:247: in refresh
self._update_token(request)
.nox/system-3-8/lib/python3.8/site-packages/google/auth/impersonated_credentials.py:260: in _update_token
self._source_credentials.refresh(request)
.nox/system-3-8/lib/python3.8/site-packages/google/auth/external_account.py:378: in refresh
subject_token=self.retrieve_subject_token(request),
.nox/system-3-8/lib/python3.8/site-packages/google/auth/identity_pool.py:158: in retrieve_subject_token
self._get_token_data(request),
.nox/system-3-8/lib/python3.8/site-packages/google/auth/identity_pool.py:167: in _get_token_data
return self._get_url_data(


self = <google.auth.identity_pool.Credentials object at 0x109be38e0>
request = <google.auth.transport.requests.Request object at 0x109be3220>
url = 'https://pipelines.actions.githubusercontent.com/umAmnh0OhcfbtGEt7J16Yga6HsgM8dYIhPxbPiOYFLVwMnfbKz/00000000-0000-0000...cations%2Fglobal%2FworkloadIdentityPools%2Fgh-13a715-cloud-sql-pyt-dd1c5f%2Fproviders%2Fgh-13a715-cloud-sql-pyt-dd1c5f'
headers = {'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImVCWl9jbjNzWFlBZDBjaDRUSEJLSElnT3dPRSJ9.eyJuYW1...EeUxTnPfX_NfTJHiP8Y9IU2iYAVMz0DfYxwhNplus2EXfJ_d4_Rx_Wp2jrxbpY5kEdOjVFDzXc-ine6fIStZAb-TEaisMCRZmdF1wKBISISZ4l0AZn34A'}

def _get_url_data(self, request, url, headers):
    response = request(url=url, method="GET", headers=headers)

    # support both string and bytes type response.data
    response_body = (
        response.data.decode("utf-8")
        if hasattr(response.data, "decode")
        else response.data
    )

    if response.status != 200:
      raise exceptions.RefreshError(
            "Unable to retrieve Identity Pool subject token", response_body
        )

E google.auth.exceptions.RefreshError: ('Unable to retrieve Identity Pool subject token', '{ "message": "GitHub Actions is temporarily unavailable. Please visit https://www.githubstatus.com/ for the status of our services.", "ref": "Ref A: 50AC209665364048B6A442D2FD9943BB Ref B: CO1EDGE2916 Ref C: 2023-09-13T19:37:05Z" }')

.nox/system-3-8/lib/python3.8/site-packages/google/auth/identity_pool.py:189: RefreshError

During handling of the above exception, another exception occurred:

def test_multiple_connectors() -> None:
    """Test that same Cloud SQL instance can connect with two Connector objects."""
    first_connector = Connector()
    second_connector = Connector()
    try:
        pool = init_connection_engine(first_connector)
        pool2 = init_connection_engine(second_connector)

        with pool.connect() as conn:
            conn.execute(sqlalchemy.text("SELECT 1"))

        with pool2.connect() as conn:
            conn.execute(sqlalchemy.text("SELECT 1"))

        instance_connection_string = os.environ["MYSQL_CONNECTION_NAME"]
        assert instance_connection_string in first_connector._instances
        assert instance_connection_string in second_connector._instances
        assert (
            first_connector._instances[instance_connection_string]
            != second_connector._instances[instance_connection_string]
        )
    except Exception as e:
      logging.exception("Failed to connect with multiple Connector objects!", e)

tests/system/test_connector_object.py:95:


../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/logging/init.py:2057: in exception
error(msg, *args, exc_info=exc_info, **kwargs)
../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/logging/init.py:2049: in error
root.error(msg, *args, **kwargs)
../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/logging/init.py:1475: in error
self._log(ERROR, msg, args, **kwargs)
../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/logging/init.py:1589: in _log
self.handle(record)
../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/logging/init.py:1599: in handle
self.callHandlers(record)
../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/logging/init.py:1661: in callHandlers
hdlr.handle(record)
../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/logging/init.py:954: in handle
self.emit(record)
.nox/system-3-8/lib/python3.8/site-packages/_pytest/logging.py:372: in emit
super().emit(record)
../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/logging/init.py:1093: in emit
self.handleError(record)
../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/logging/init.py:1085: in emit
msg = self.format(record)
../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/logging/init.py:929: in format
return fmt.format(record)
.nox/system-3-8/lib/python3.8/site-packages/_pytest/logging.py:136: in format
return super().format(record)
../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/logging/init.py:668: in format
record.message = record.getMessage()


self = <LogRecord: root, 40, /Users/runner/work/cloud-sql-python-connector/cloud-sql-python-connector/tests/system/test_connector_object.py, 95, "Failed to connect with multiple Connector objects!">

def getMessage(self):
    """
    Return the message for this LogRecord.

    Return the message for this LogRecord after merging any user-supplied
    arguments with the message.
    """
    msg = str(self.msg)
    if self.args:
      msg = msg % self.args

E TypeError: not all arguments converted during string formatting

../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/logging/init.py:373: TypeError

Looks like this issue is flaky. 😟

I'm going to leave this open and stop commenting.

A human should fix and close this.


When run at the same commit (71b9347), this test passed in one build (https://github.com/GoogleCloudPlatform/cloud-sql-python-connector/actions/runs/6177038374) and failed in another build (https://github.com/GoogleCloudPlatform/cloud-sql-python-connector/actions/runs/6177038374).

Github Actions auth issue