Testing Pebble keeps a check `threshold` of 0 rather than defaulting it to 3

Open Beginner friendly
#2,924 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
71/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
testing

Research direction

Read the threshold defaulting checks in ops/_private/harness.py and testing/src/scenario/_consistency_checker.py, then compare them with the Pebble behavior linked in the issue. Reproduce the layer with threshold 0, combine=True, and replan(); done means the charm and consistency checker report the same default threshold as real Pebble. The issue suggests handling this once as part of #2923.

Written by the indexing model from the issue text.

Description

rainy day small item

Pebble treats a check threshold of 0 the same as an unset one, and replaces it with the default of 3 when it combines the layers. Our testing Pebble only fills in the default for None, so with threshold: 0 in a layer the charm sees a threshold of 0, and the consistency checker then rejects a CheckInfo that has the value real Pebble would report:

$ python threshold.py
charm sees threshold: 0
output state CheckInfo threshold: [0]
InconsistentScenarioError Inconsistent scenario. The following errors were found: container 'foo' has a check 'c' with a different 'threshold' (3) than the plan (0).

The layer is {'checks': {'c': {'override': 'replace', 'threshold': 0, 'exec': {'command': 'true'}}}}, added with combine=True and then replan().

The is None checks are in Harness (and twice more in the same file) and in the consistency checker. Changing them to treat 0 as unset should be enough, although it would be better done once, as part of #2923.

A threshold of 0 doesn't do anything useful, so I doubt any charm sets it, hence rainy day.

Dominant language
Python
Stars
267
Forks
156
Avg merge
5d 3h
Merged PRs (30d)
43

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from canonical/operator

All issues in canonical/operator

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.