Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for new relation-model-get hook tool #1525

Open
benhoyt opened this issue Jan 9, 2025 · 2 comments
Open

Support for new relation-model-get hook tool #1525

benhoyt opened this issue Jan 9, 2025 · 2 comments
Labels

Comments

@benhoyt
Copy link
Collaborator

benhoyt commented Jan 9, 2025

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.

@benhoyt benhoyt added the 25.04 label Jan 9, 2025
@benhoyt
Copy link
Collaborator Author

benhoyt commented Jan 9, 2025

@wallyworld Ops tracking item for your info.

@benhoyt benhoyt changed the title Support for new remote-model-get hook tool Support for new relation-model-get hook tool Jan 10, 2025
@benhoyt
Copy link
Collaborator Author

benhoyt commented Jan 13, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant