def stop_kafka_waiting_for_zookeeper_ready(): hookenv.status_set('maintenance', 'zookeeper not ready, stopping kafka') kafka = Kafka() kafka.close_ports() kafka.stop() remove_state('kafka.started') hookenv.status_set('waiting', 'waiting for zookeeper to become ready')
def storage_detaching(): unitdata.kv().unset('kafka.storage.log_dir') kafka = Kafka() kafka.close_ports() kafka.stop() remove_state('kafka.started') hookenv.status_set('waiting', 'reconfiguring to use temporary storage') remove_state('kafka.storage.logs.attached')
def storage_attach(): storageids = hookenv.storage_list('logs') if not storageids: hookenv.status_set('blocked', 'cannot locate attached storage') return storageid = storageids[0] mount = hookenv.storage_get('location', storageid) if not mount: hookenv.status_set('blocked', 'cannot locate attached storage mount') return log_dir = os.path.join(mount, "logs") unitdata.kv().set('kafka.storage.log_dir', log_dir) hookenv.log('Kafka logs storage attached at {}'.format(log_dir)) # Stop Kafka; removing the kafka.started state will trigger a reconfigure if/when it's ready kafka = Kafka() kafka.close_ports() kafka.stop() remove_state('kafka.started') hookenv.status_set('waiting', 'reconfiguring to use attached storage') set_state('kafka.storage.logs.attached')