Bug #112413 kubectl describe innodbcluster throws Python exception
Submitted: 21 Sep 2023 11:20 Modified: 22 Sep 2023 16:34
Reporter: Lukas Lösche Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Operator Severity:S2 (Serious)
Version:8.1.0 OS:Ubuntu
Assigned to: CPU Architecture:x86

[21 Sep 2023 11:20] Lukas Lösche
Description:
When trying to run `kubectl describe innodbcluster mydbcluster` kubectl throws the following exception:

```
  Normal  Logging  68s  kopf  Propagating spec.version=None for db/database (was 8.1.0)
  Normal  Logging  8s   kopf  Propagating spec.version=None for db/database (was 8.1.0)
  Error   Logging  8s   kopf  Handler 'on_innodbcluster_field_version/spec.version' failed with an exception. Will retry.
Traceback (most recent call last):
  File "/usr/lib/mysqlsh/python-packages/kopf/_core/actions/execution.py", line 279, in execute_handler_once
    result = await invoke_handler(
  File "/usr/lib/mysqlsh/python-packages/kopf/_core/actions/execution.py", line 374, in invoke_handler
    result = await invocation.invoke(
  File "/usr/lib/mysqlsh/python-packages/kopf/_core/actions/invocation.py", line 139, in invoke
   ...n-packages/mysqloperator/controller/innodbcluster/cluster_controller.py", line 805, in on_upgrade
    [version_valid, version_error] = utils.version_in_range(version)
  File "/usr/lib/mysqlsh/python-packages/mysqloperator/controller/utils.py", line 169, in version_in_range
    version_int = version_to_int(version)
  File "/usr/lib/mysqlsh/python-packages/mysqloperator/controller/utils.py", line 144, in version_to_int
    parts = version.split(".")
AttributeError: 'NoneType' object has no attribute 'split'
```

How to repeat:
Run kubectl describe innodbcluster on any cluster.

Suggested fix:
Add type checking to make sure the CRD's version is actually a string, before calling split on it. Seems like for whatever reason the version is "None" which in itself sounds like a bug.
[22 Sep 2023 12:54] MySQL Verification Team
What version of python you have installed?

Thank you for report
[22 Sep 2023 16:31] Lukas Lösche
> What version of python you have installed?

That's a question for your developers I guess? It's whatever version of python you have installed in the container that is running the operator.

To clarify: the Python error is thrown by the MySQL K8s operator. The Python interpreter was not installed by myself. It comes as part of the operator container: container-registry.oracle.com/mysql/community-operator:8.1.0-2.1.0
[22 Sep 2023 16:34] Lukas Lösche
I did some more debugging and found out that the error only happens when you specify the `version` property as part of the helm charts values.yaml.