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

OF should gracefully handle blank application names in relation-broken hooks #693

Closed
pengale opened this issue Feb 15, 2022 · 4 comments · Fixed by #765
Closed

OF should gracefully handle blank application names in relation-broken hooks #693

pengale opened this issue Feb 15, 2022 · 4 comments · Fixed by #765
Assignees

Comments

@pengale
Copy link
Contributor

pengale commented Feb 15, 2022

See the discussion here: https://bugs.launchpad.net/juju/+bug/1960934

In a relation-broken hook, Juju does not set JUJU_REMOTE_APP. This is Working as Intended for Juju, but it raises an exception in the framework, when iterating through relations.

We need to refactor so that we handle the empty value without throwing the exception.

@jameinel
Copy link
Member

jameinel commented Feb 15, 2022 via email

mmanciop pushed a commit to canonical/traefik-k8s-operator that referenced this issue Apr 5, 2022
Juju does not expose the RELATION_NAME over the
relation_broken events (see $1) and that causes
bad behaviors with OF (see $2), that we need to
guard against.

Closes #34

$1 https://bugs.launchpad.net/juju/+bug/1960934
$2 canonical/operator#693
mmanciop pushed a commit to canonical/traefik-k8s-operator that referenced this issue Apr 5, 2022
Juju does not expose the RELATION_NAME over the
relation_broken events (see $1) and that causes
bad behaviors with OF (see $2), that we need to
guard against.

Closes #34

$1 https://bugs.launchpad.net/juju/+bug/1960934
$2 canonical/operator#693
@claudiubelu
Copy link

I want to mention that I've encountered this type of errors before [1], and that they still happen for the nginx-ingress-integrator charm when a related application is removed (the charm iterates over its relations in order to establish what Kubernetes Services and Ingress Resources need to be created / removed).

[1] finos/legend-juju-gitlab-integrator#6

@rwcarlsen rwcarlsen self-assigned this Apr 18, 2022
@rwcarlsen
Copy link
Contributor

rwcarlsen commented Apr 21, 2022

If someone is e.g. using the remote app name to access relation data (relation.data[relation.app].get(...)), what should happen? Should we just have relation.data[relation.app] return an empty dictionary and log an error? Or something else...

@rwcarlsen
Copy link
Contributor

rwcarlsen commented Apr 21, 2022

According to the traceback (why does python reverse the compound word convention from c/c++?) in the linked juju issue, and relation.data[relation.app].get(...) is failing in the .get(...) call. And the relation-get hook tool is failing with an empty app name. This means that relation.app is an existing instance with an empty app name. I've traced this issue to

return os.environ['JUJU_REMOTE_APP']
where we end up returning an empty string instead of None. The calling code for this function only checks for None (not empty string) as a special case. I would argue that this is a bug that we can fix easily. However, this doesn't really resolve the question I asked above - users will instead just get a keyerror for e.g. relation.data[relation.app] because now relation.app will be None. If the actual relation data still does exist and relation-get calls can succeed, how can ops get access to the (gone?) remote app's name?

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

Successfully merging a pull request may close this issue.

4 participants