Skip to content

Harness plan doesn't match Pebble's when merging layers: repeated list entries and a lost check level #2894

Open

Description

@aozmekik

I compared the plan ops.testing.Harness builds from two layers with the plan the real Pebble daemon (v1.33.2) builds from the same layers, over a few hundred random base/override pairs. Apart from defaults Pebble fills in (threshold, period) and the override value it reports, two things differ.

  1. Lists merged from an override layer are repeated on every render. _render_services, _render_checks and _render_log_targets in ops/_private/harness.py merge into the first layer's own object, so each get_plan() or get_services() call appends the override's after/before/requires (or a log target's services) again:
c.add_layer('base', {'services': {'s': {'override': 'replace', 'command': 'x', 'after': ['a']}}})
c.add_layer('over', {'services': {'s': {'override': 'merge', 'after': ['b']}}})
c.get_plan().services['s'].after  # ['a', 'b', 'b'], then ['a', 'b', 'b', 'b'], ...

Pebble gives ['a', 'b']. The ops.testing container already copies before merging; Harness doesn't.

  1. Merging a check layer that doesn't set level drops the existing level. Check._merge skips CheckStartup.UNSET but not CheckLevel.UNSET, and enum members are truthy, so level: ready from the base layer becomes UNSET. Pebble keeps ready. This affects ops.testing too, since both use Check._merge.

I have small fixes with tests for both and will open PRs.

Activity

  1. tonyandrewmeyer commented on Nov 15, 2026

    @tonyandrewmeyer
    Collaborator

    Hi @aozmekik ! Thanks for checking this against a real Pebble rather than just reading the code.

    We've already decided not to fix the first one (see #2830 and #2885, which reported the same duplicates). Harness only gets security fixes and significant bug fixes now, plus changes to code it shares with Scenario. Scenario already copies before merging, so I'm closing #2896.

    The second one is a real bug, and does affect Scenario as well. It's already fixed in #2872 (split out of a larger set of Pebble fixes), so I'm closing #2895 as a duplicate, and this issue will close when #2872 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions