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

Event charm.py not defined #21

Closed
knkski opened this issue Jun 1, 2020 · 3 comments · Fixed by #23
Closed

Event charm.py not defined #21

knkski opened this issue Jun 1, 2020 · 3 comments · Fixed by #23
Assignees
Milestone

Comments

@knkski
Copy link
Contributor

knkski commented Jun 1, 2020

I have written a charm using charmcraft, found here:

https://github.com/juju-solutions/bundle-kubeflow/tree/admission-webhook-charm/charms/admission-webhook

I am deploying it like this:

charmcraft build
juju deploy ./admission-webhook.charm --resource oci-image=gcr.io/kubeflow-images-public/admission-webhook:vmaster-gaf96e4e3

This is with charmcraft 0.1.0 installed via pypi.org and juju 2.7.6. After deployment, the charm stays in unknown status, and I get this message from juju debug-log:

application-admission-webhook: 11:04:06 DEBUG unit.admission-webhook/6.juju-log Event charm.py not defined for <__main__.AdmissionWebhookCharm object at 0x7f5a3790ec18>.

I'm not sure how I'm getting an event of that name.

@jameinel
Copy link
Member

jameinel commented Jun 2, 2020 via email

@jameinel
Copy link
Member

jameinel commented Jun 3, 2020

We talked through what is happening. The issue is that 'hooks/install' is a copy of 'dispatch', which is doing an 'exec src/charm.py' to trigger the charm main. However, that sets sys.argv[0] to 'src/charm.py' rather than being 'hooks/install'.
We can use bin/bash to pass 'exec -a' in order to set argv[0], or we can just set JUJU_DISPATCH_PATH in the script.
eg:

#!/bin/sh
set -eu

dispatch=${JUJU_DISPATCH_PATH:-}
if [ -z "$dispatch" ]; then
  export JUJU_DISPATCH_PATH="$0"
fi
exec src/charm.py

That way if Juju is 2.8+ and is setting JUJU_DISPATCH_PATH then we just use it.
If it is 2.7 and we are invoking 'hooks/install' as a script, that script then tells the operator framework what hook is being run via JUJU_DISPATCH_PATH.

@chipaca chipaca linked a pull request Jun 3, 2020 that will close this issue
@chipaca chipaca self-assigned this Jun 3, 2020
@chipaca chipaca added this to the 0.1.1 milestone Jun 3, 2020
@chipaca
Copy link
Contributor

chipaca commented Jun 4, 2020

this is part of 0.1.2 (which is the same as 0.1.1 for silly reasons), already in pypi.

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.

3 participants