Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL-router 8.0.32 pymysql.err.OperationalError: caching sha2: Unknown packet for public key: b'-' #52

Closed
gboutry opened this issue Apr 18, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@gboutry
Copy link

gboutry commented Apr 18, 2023

Steps to reproduce

  1. Deploy Keystone-k8s with mysql-router and mysql

The current keystone-k8s cannot work with mysql-router (because of interface library version). I can put up a branch with the updated keystone-k8s I use is that required

Actual behavior

The behavior I'm encoutering is the same as this one:
https://bugs.launchpad.net/ubuntu/+source/mysql-8.0/+bug/2003835

Versions

Operating system: not sure that's relevant
Channel: 8.0/edge

Log output

Full log

Logs from my client

(keystone): 2023-04-18 17:17:24,582 CRITICAL Unhandled error
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 3250, in _wrap_pool_connect
    return fn()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 310, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 868, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 476, in checkout
    rec = pool._do_get()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py", line 146, in _do_get
    self._dec_overflow()
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 207, in raise_
    raise exception
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 256, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 371, in __init__
    self.__connect()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 666, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 207, in raise_
    raise exception
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 661, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/create.py", line 590, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 597, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 353, in __init__
    self.connect()
  File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 633, in connect
    self._request_authentication()
  File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 932, in _request_authentication
    auth_packet = _auth.caching_sha2_password_auth(self, auth_packet)
  File "/usr/lib/python3/dist-packages/pymysql/_auth.py", line 257, in caching_sha2_password_auth
    raise OperationalError(
pymysql.err.OperationalError: caching sha2: Unknown packet for public key: b'-'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/keystone-manage", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python3/dist-packages/keystone/cmd/manage.py", line 41, in main
    cli.main(argv=sys.argv, developer_config_file=developer_config)
  File "/usr/lib/python3/dist-packages/keystone/cmd/cli.py", line 1374, in main
    CONF.command.cmd_class.main()
  File "/usr/lib/python3/dist-packages/keystone/cmd/cli.py", line 354, in main
    upgrades.offline_sync_database_to_version(
  File "/usr/lib/python3/dist-packages/keystone/common/sql/upgrades.py", line 255, in offline_sync_database_to_version
    expand_schema()
  File "/usr/lib/python3/dist-packages/keystone/common/sql/upgrades.py", line 216, in expand_schema
    _db_sync(branch=EXPAND_BRANCH)
  File "/usr/lib/python3/dist-packages/keystone/common/sql/upgrades.py", line 157, in _db_sync
    with sql.session_for_write() as session:
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/usr/lib/python3/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 1054, in _transaction_scope
    with current._produce_block(
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/usr/lib/python3/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 653, in _session
    self.session = self.factory._create_session(
  File "/usr/lib/python3/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 414, in _create_session
    self._start()
  File "/usr/lib/python3/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 504, in _start
    self._setup_for_connection(
  File "/usr/lib/python3/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 529, in _setup_for_connection
    engine = engines.create_engine(
  File "/usr/lib/python3/dist-packages/debtcollector/renames.py", line 43, in decorator
    return wrapped(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/oslo_db/sqlalchemy/engines.py", line 211, in create_engine
    test_conn = _test_connection(engine, max_retries, retry_interval)
  File "/usr/lib/python3/dist-packages/oslo_db/sqlalchemy/engines.py", line 386, in _test_connection
    return engine.connect()
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 3204, in connect
    return self._connection_cls(self, close_with_result=close_with_result)
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 96, in __init__
    else engine.raw_connection()
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 3283, in raw_connection
    return self._wrap_pool_connect(self.pool.connect, _connection)
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 3253, in _wrap_pool_connect
    Connection._handle_dbapi_exception_noconnection(
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 2098, in _handle_dbapi_exception_noconnection
    util.raise_(newraise, with_traceback=exc_info[2], from_=e)
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 207, in raise_
    raise exception
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 3250, in _wrap_pool_connect
    return fn()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 310, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 868, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 476, in checkout
    rec = pool._do_get()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py", line 146, in _do_get
    self._dec_overflow()
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 207, in raise_
    raise exception
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 256, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 371, in __init__
    self.__connect()
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 666, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 207, in raise_
    raise exception
  File "/usr/lib/python3/dist-packages/sqlalchemy/pool/base.py", line 661, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/create.py", line 590, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 597, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 353, in __init__
    self.connect()
  File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 633, in connect
    self._request_authentication()
  File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 932, in _request_authentication
    auth_packet = _auth.caching_sha2_password_auth(self, auth_packet)
  File "/usr/lib/python3/dist-packages/pymysql/_auth.py", line 257, in caching_sha2_password_auth
    raise OperationalError(
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) caching sha2: Unknown packet for public key: b'-'
(Background on this error at: https://sqlalche.me/e/14/e3q8)

Additional context

When attaching the following image: mysql/mysql-router:8.0.31-1.0.10-router, everything works as expected.

@gboutry gboutry added the bug Something isn't working label Apr 18, 2023
@github-actions
Copy link
Contributor

@gboutry
Copy link
Author

gboutry commented Apr 19, 2023

Building the ROCK now will get mysqlrouter MySQL Router Ver 8.0.33 for Linux on x86_64 (MySQL Community - GPL) and solves the issue

Building the Rock necessitates:

diff --git a/rockcraft.yaml b/rockcraft.yaml
index cd91fb7..e822fc7 100644
--- a/rockcraft.yaml
+++ b/rockcraft.yaml
@@ -8,15 +8,12 @@ description: |
     mysql-client.  For more information on ROCKs, visit
     the https://github.com/canonical/rockcraft.
 license: Apache-2.0 # your application's SPDX license
-cmd:
-    - /usr/bin/setpriv
-    - --clear-groups
-    - --reuid
-    - mysql
-    - --regid
-    - mysql
-    - --
-    - ./run
+
+services:
+  mysqlrouter:
+    override: replace
+    command: /usr/bin/setpriv --clear-groups --reuid mysql --regid mysql -- ./run
+
 platforms: # The platforms this ROCK should be built on and run on
     amd64:

Happy to propose a patch

@carlcsaposs-canonical
Copy link
Contributor

carlcsaposs-canonical commented May 18, 2023

Should be fixed by #51 (specifically switching from https://github.com/canonical/mysql-router-container to https://github.com/canonical/charmed-mysql-rock). Leaving open for @shayancanonical to confirm as fixed as part of DPE-1662

@shayancanonical
Copy link
Contributor

Tested the latest build of mysql-router-k8s (which has v8.0.32, as the server in mysql-k8s charm is also v8.0.32) with our test application, and can confirm that this has been fixed. @gboutry please let us know if you face any further issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants