Comment 4 for bug 1789545

Revision history for this message
Ian Booth (wallyworld) wrote :

I tested this on 2.9 and it *seems* to be doing the right thing.
Making the WatchAllModels call, I got a watcher delta whenever any model config attribute was changed, including the "agent-version" attribute which is incremented when a model is upgraded.

I whipped up a small libjuju script to test with. Note, there appears to be a bug in libjuju where the watcher id is not being properly set for the AllModelWatcherFacade facade, so the Next() call fails, so I had to monkey patch that (in juju/client/overrides.y). But nonetheless, the script showed that things were doing the right thing on the controller, ie

juju model-config foo-bar

on any model would fire the watcher. As would juju upgrade-model

I'll mark as Incomplete - if it's still an issue on juju 2.9, we can reopen.

#!/usr/bin/python3

import asyncio
import logging

from juju.client import client
from juju.model import Controller

async def watch():
    controller = Controller()
    await controller.connect()

    api = client.ControllerFacade.from_connection(controller.connection())
    watcher = client.AllModelWatcherFacade.from_connection(
        controller.connection())
    result = await api.WatchAllModels()
    watcher.Id = result.watcher_id

    while True:
        change = await watcher.Next()
        for delta in change.deltas:
            print("-- change --\n{}\n".format(delta))

if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    ws_logger = logging.getLogger('websockets.protocol')
    ws_logger.setLevel(logging.INFO)
    asyncio.run(watch())