You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Per our discussions with the Juju and Observability teams, Juju 3.6.2 will be coming out with a new hook tool, relation-model-get (Juju code change). It returns the model info (just the UUID right now) of the model on other side of the relation. You can -- among other things -- compare it to the current model UUID to determine whether the relation is cross-model or not. The hook tool works as follows:
# -r required if not in a relation hook context
relation-model-get [-r <relation-id>] [--format yaml|json]
# example:
$ relation-model-get -r 3 --format json
{"uuid":"deadbeef-0bad-400d-8000-4b1d0d06f00d"}
We'd like to add first-class support for this in Ops. Presumably this will belong on the ops.Relation object. Perhaps a remote_model property which returns a RemoteModelInfo dataclass with a uuid: str field. (I thought about returning a Model instance, but that has a ton of other stuff, so seems wrong to type it as that.) That would call relation-model-get -r {self.id} --format json and cache it on the Relation instance.
It's an open question what we should do if the Juju version is too old to support relation-model-get. I'd recommend just have it raise the ModelError. Alternatively we could have remote_model typed as RemoteModelInfo | None, but that doesn't seem right in the long term. We could also consider adding a property to JujuVersion like supports_relation_model_get -- worth talking to charmers about this.
The text was updated successfully, but these errors were encountered:
Per Ian, if a charm needs this feature it'll just say assumes: juju>=3.6.2 (or whatever the syntax) in charmcraft.yaml, so we don't need special handling in Ops.
Per our discussions with the Juju and Observability teams, Juju 3.6.2 will be coming out with a new hook tool,
relation-model-get
(Juju code change). It returns the model info (just the UUID right now) of the model on other side of the relation. You can -- among other things -- compare it to the current model UUID to determine whether the relation is cross-model or not. The hook tool works as follows:We'd like to add first-class support for this in Ops. Presumably this will belong on the
ops.Relation
object. Perhaps aremote_model
property which returns aRemoteModelInfo
dataclass with auuid: str
field. (I thought about returning aModel
instance, but that has a ton of other stuff, so seems wrong to type it as that.) That would callrelation-model-get -r {self.id} --format json
and cache it on theRelation
instance.It's an open question what we should do if the Juju version is too old to support
relation-model-get
. I'd recommend just have it raise theModelError
. Alternatively we could haveremote_model
typed asRemoteModelInfo | None
, but that doesn't seem right in the long term. We could also consider adding a property toJujuVersion
likesupports_relation_model_get
-- worth talking to charmers about this.The text was updated successfully, but these errors were encountered: