Charm Interface - MySQL InnoDB Cluster
0340770712
The mock third party library was needed for mock support in py2 runtimes. Since we now only support py36 and later, we can use the standard lib unittest.mock module instead. Note that https://github.com/openstack/charms.openstack is used during tests and he need `mock`, unfortunatelly it doesn't declare `mock` in its requirements so it retrieve mock from other charm project (cross dependency). So we depend on charms.openstack first and when Ib1ed5b598a52375e29e247db9ab4786df5b6d142 will be merged then CI will pass without errors. Depends-On: Ib1ed5b598a52375e29e247db9ab4786df5b6d142 Change-Id: I5212f10fed28ad11f123b0c4210be0f232b3a38a |
||
---|---|---|
unit_tests | ||
.gitignore | ||
.gitreview | ||
.stestr.conf | ||
.travis.yml | ||
.zuul.yaml | ||
interface.yaml | ||
LICENSE | ||
peers.py | ||
README.md | ||
test-requirements.txt | ||
tox.ini |
Overview
This interface layer handles the intra-cluster relations for msyql-innodb-cluster.
Usage
Peers
The interface layer will set the following state:
{relation_name}.connected
The cluster relation is established.{relation_name}.available
The cluster relation data is complete.{relation_name}.clustered
All cluster units are clustered.
Cluster relation information can be set on the relation with the following methods:
Set the cluster relation information to connect to this unit:
def cluster.set_cluster_connection_info(
"192.168.1.5", "clusteruser", "passwd")
Indicate this unit's readiness for clustering:
cluster.set_unit_configure_ready():
Indicate this unit has been clustered:
cluster.set_unit_clustered(self):
cluster.set_unit_configure_ready(self):
For example:
@reactive.when('cluster.connected')
@reactive.when_not('cluster.available')
def send_cluster_connection_info(cluster):
with charm.provide_charm_instance() as instance:
cluster.set_cluster_connection_info(
instance.cluster_address,
instance.cluster_user,
instance.cluster_password)
@reactive.when('cluster.available')
def create_remote_cluster_user(cluster):
with charm.provide_charm_instance() as instance:
for unit in cluster.all_joined_units:
instance.create_cluster_user(
unit.received['cluster-address'],
unit.received['cluster-user'],
unit.received['cluster-password'])
cluster.set_unit_configure_ready()
@reactive.when('leadership.set.cluster-created')
@reactive.when('cluster.available')
def signal_clustered(cluster):
# Optimize clustering by causing a cluster relation changed
with charm.provide_charm_instance() as instance:
if reactive.is_flag_set(
"leadership.set.cluster-instance-clustered-{}"
.format(instance.cluster_address)):
cluster.set_unit_clustered()
instance.assess_status()
The interface will automatically determine the network space binding on the local unit to present to the MySQL InnoDB cluster based on the name of the relation. This can be overridden using the cluster_host parameter of the set_cluster_connection_info method.