Skip to content

Commit

Permalink
Merge pull request #166 from canonical/fix-juju-info-network-get
Browse files Browse the repository at this point in the history
ulterior fix
  • Loading branch information
PietroPasotti authored Aug 1, 2024
2 parents 7242fdd + de641ec commit a965323
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "ops-scenario"

version = "6.1.4"
version = "6.1.5"

authors = [
{ name = "Pietro Pasotti", email = "[email protected]" }
Expand Down
6 changes: 4 additions & 2 deletions scenario/consistency_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def check_network_consistency(
meta_bindings = set(charm_spec.meta.get("extra-bindings", ()))
# add the implicit juju-info binding so we can override its network without
# having to declare a relation for it in metadata
meta_bindings.add("juju-info")
implicit_bindings = {"juju-info"}
all_relations = charm_spec.get_all_relations()
non_sub_relations = {
endpoint
Expand All @@ -438,7 +438,9 @@ def check_network_consistency(
}

state_bindings = set(state.networks)
if diff := state_bindings.difference(meta_bindings.union(non_sub_relations)):
if diff := state_bindings.difference(
meta_bindings.union(non_sub_relations).union(implicit_bindings),
):
errors.append(
f"Some network bindings defined in State are not in metadata.yaml: {diff}.",
)
Expand Down
17 changes: 17 additions & 0 deletions tests/test_e2e/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,20 @@ def test_juju_info_network_override(mycharm):
str(mgr.charm.model.get_binding("juju-info").network.bind_address)
== "4.4.4.4"
)


def test_explicit_juju_info_network_override(mycharm):
ctx = Context(
mycharm,
meta={
"name": "foo",
# this charm for whatever reason explicitly defines a juju-info endpoint
"requires": {"juju-info": {"interface": "juju-info"}},
},
)

with ctx.manager(
"update_status",
State(),
) as mgr:
assert mgr.charm.model.get_binding("juju-info").network.bind_address

0 comments on commit a965323

Please sign in to comment.