question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Charm should be reinitialized at every hook execution in Harness

See original GitHub issue

More specifically, before every hook execution. Point is: when a ‘real’ charm runs, it is reinitialized afresh. While if you do fire eventA and eventB on the harness, the harness won’t reinitialize the charm it holds in between, which may result in some major behavioural differences between a live charm and a harness’d charm.

Use cases include:

class Charm(CharmBase):
     def __init__(self):
         self.relation1 = relation1 = RelationRequirer()
         self.relation2 = RelationProvider(relation1.data[self.unit])

class Charm(CharmBase):
     def __init__(self):
         if self.container.can_connect():
             self.framework.observe(self.on.foo, self._foo)

Concrete example of an affected charm: https://github.com/canonical/prometheus-k8s-operator/blob/main/src/charm.py

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
rwcarlsencommented, Apr 14, 2022

Defer also sneaks its way into this. Deferred evens are run together on the same charm instance/setup as the event that comes in and triggers them.

0reactions
jameinelcommented, Sep 30, 2022

(at a minimum, relating A to B should not require that B knows the names of the endpoints of charm A. That is certainly an abstraction break)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - Harness.io Docs
This section lists common errors you might receive when Harness attempts to collect artifacts. Workflow Hanging on Artifact Collection. If ...
Read more >
Charm hooks - doc - Charmhub - Juju Discourse
All the hooks must be written to be idempotent, meaning that there should be no different from running the hook once from running...
Read more >
Integration - Juju
Peer integrations. Charms can declare peer integrations, which causes each unit of an application to respond to the other units deployed in the...
Read more >
moving squid NS/KNF to magma folder (fd7b74ee) · Commits · vnf ...
Now when executing `curl https://www.google.com` squid will block access to the url ... magma/hackfest_squid_cnf/charms/squid/hooks/install 0 → 120000.
Read more >
Leading Blog: A Leadership Blog - LeadershipNow.com
Charming, kind, soft-spoken, and very approachable—in a word, humble. ... All relationships can change over time, even the good ones.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found