Skip to content

[Bug]: is_subordinate() returns wrong result if subordinate:false is explicitly specified in charm's metadata #750

@agileshaw

Description

@agileshaw

Description

Currently, is_subordinate() function determines if a charm is subordinate by retrieving information from Charmhub API and checking if a subordinate key exists.

return 'subordinate' in response['default-release']['revision']

However, for charms that explicitly specify subordinate:false in their metadata, e.g. mysql-innodb-cluster, the subordinate key would exist in the Charmhuib API response with a value of false.

{"default-release":{"channel":{"base":{"architecture":"s390x","channel":"22.04","name":"ubuntu"},"name":"8.0/stable","released-at":"2022-08-05T19:05:33.053108+00:00","risk":"stable","track":"8.0"},"revision":{"subordinate":false}},"id":"i5HWuKoEat09854Sz0qXHOjmr4wwHLfP","name":"mysql-innodb-cluster","type":"charm"}

In such a case, the is_subordinate() function would return wrong result because it only checks the existence of the subordinate key but not its value.

Urgency

Blocker for our release

Python-libjuju version

3.0.2

Juju version

2.9

Reproduce / Test

from juju.model import Model
import asyncio

async def deploy_mysql():
    model = Model()
    await model.connect("test")
    mysql_innodb_app = await model.deploy(
        "mysql-innodb-cluster", application_name="mysql", series="focal", channel="stable", num_units=3
    )
    return mysql_innodb_app

asyncio.run(deploy_mysql())

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugindicates a bug in the project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions