Zookeeper

Channel Revision Published Runs on
latest/stable 53 29 Nov 2021
Ubuntu 16.04
latest/candidate 56 29 Nov 2021
Ubuntu 16.04
latest/beta 56 29 Nov 2021
Ubuntu 16.04
latest/edge 98 20 Apr 2023
Ubuntu 22.04
3/stable 126 27 Feb 2024
Ubuntu 22.04
3/candidate 126 27 Feb 2024
Ubuntu 22.04
3/beta 126 27 Feb 2024
Ubuntu 22.04
3/edge 131 24 Apr 2024
Ubuntu 22.04
juju deploy zookeeper --channel 3/stable
Show information

Platform:

Ubuntu
22.04

charms.zookeeper.v0.zookeeper_provider

ZooKeeperProvider class and methods.

ZooKeeperProvider handles the provider side abstraction for ZooKeeper client relations.

It abstracts the updating the ZK quorum of authorised users and their ACLs during zookeeper_relation_updated/joined and zookeeper_relation_broken events.

During these events, ACLs and user zNodes are updated on the leader for all related applications, client and peer relation data is set with the necessary information on both side, and new users are added to the unit's JAAS config file, whereupon which a rolling restart of the ZooKeeper service is triggered.

Example usage for ZooKeeperProvider:


class ZooKeeperCharm(CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self.provider = ZooKeeperProvider(self)
        self.restart = RollingOpsManager(self, relation="restart", callback=self._on_start)

    def _on_start(self, event):

        # event is passed here to check for RelationBrokenEvents
        # in which case that relation will be removed
        users = self.provider.build_jaas_users(event=event)

        # get_passwords()
        # set_zookeeper_auth_config(passwords, users)
        # restart_snap_service()

class ZooKeeperProvider

Methods

ZooKeeperProvider. __init__( self , charm )

ZooKeeperProvider. app_relation( self )

Description

Gets the current ZK peer relation. None

ZooKeeperProvider. client_relations( self )

Description

Gets the relations for all related client applications. None

ZooKeeperProvider. relation_config( self , relation: Relation , event )

Gets the auth config for a currently related application.

Arguments

relation

the relation you want to build config for

event (optional)

the corresponding event. If passed and is RelationBrokenEvent, will skip and return None

Returns

Dict containing relation username, password, chroot, acl None if RelationBrokenEvent is passed as event

ZooKeeperProvider. build_jaas_users( self , event )

Builds the necessary user strings to add to ZK JAAS config files.

Arguments

event (optional)

used for checking RelationBrokenEvent

Returns

Newline delimited string of JAAS users from relation data

ZooKeeperProvider. relations_config( self , event )

Gets auth configs for all currently related applications.

Arguments

event (optional)

used for checking RelationBrokenEvent

Returns

Dict of key = relation_id, value = relations_config() for all related apps

ZooKeeperProvider. build_acls( self , event )

Gets ACLs for all currently related applications.

Arguments

event (optional)

used for checking RelationBrokenEvent

Returns

Dict of chroots with value as list of ACLs for the chroot

ZooKeeperProvider. relations_config_values_for_key( self , key: str , event )

Grabs a specific auth config value from all related applications.

Arguments

event (optional)

used for checking RelationBrokenEvent

Returns

Set of all app values matching a specific key from relations_config()

ZooKeeperProvider. update_acls( self , event )

Compares leader auth config to incoming relation config, applies necessary add/update/remove actions.

Arguments

event (optional)

used for checking RelationBrokenEvent

ZooKeeperProvider. apply_relation_data( self , event )

Updates relation data with new auth values upon concluded client_relation events.

Arguments

event (optional)

used for checking RelationBrokenEvent