Skip to content

fix(k8s): key claim table by chart version #2519

Closed

Description

@dan-petty

Problem Description

CHART_CLAIMS in tests/test_k8s_local_path_placement.py (#1634) has one entry for each chart that an Argo CD Application installs. Each entry names the values that turn on a claim and the value path of the pod's affinity. The key is the chart name only. No check ties an entry to the chart version that the Application pins.

A chart release can move a value. Loki did this in 20.0.2 (#1632): it moved the pod field of the token from serviceAccount.automountServiceAccountToken to defaults.automountServiceAccountToken. If a release moves the claim switch or the affinity path, the test reads a value that the chart no longer uses. The test then passes, and the pod can bind its volume on the control-plane node.

The token test of #1652 has the same kind of table, _CHART_TOKENS in tests/invariants/test_k8s_manifests.py. Its key is the chart and the version, and a test fails when an Application pins another version. pinned_charts() in tests/support/k8s_tree.py reads the pinned versions.

Reproduction Steps

  1. Change targetRevision of the chart source in k8s/argocd/apps/grafana.yaml to a later grafana chart version. Change the deploy-stack release to the same version.
  2. In that later version, suppose that the chart reads the claim switch from another value than persistence.enabled.
  3. Run uv run devops ci test tests/test_k8s_local_path_placement.py.

Expected vs Actual Behavior

Expected: the test fails when an Application pins a chart version that CHART_CLAIMS was not read from. The person who bumps the chart then reads the claim values of the new version again.

Actual: the test passes at each chart version, because the key of CHART_CLAIMS is the chart name only.

Environment Diagnostics

Not applicable. The defect is in a test table of the repository. Found in the review of #1652.

Logs, Traces, or Terminal Output

None.

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Proposed design

Problem statement

The CHART_CLAIMS table in tests/test_k8s_local_path_placement.py is keyed by chart name only. When a chart release moves a value path, the test reads a stale path and passes silently. A pod can then bind its volume on the control-plane node. The fix adds the pinned chart version to each key and a test that fails when an Application pins a version the table was not read from. The pattern already exists in _CHART_TOKENS in tests/invariants/test_k8s_manifests.py.

Acceptance criteria

Requirement: version-keyed table

CHART_CLAIMS SHALL use a tuple of chart name and pinned version as its key type.

Scenario: key type check

  • WHEN the test module is imported and CHART_CLAIMS is inspected
  • THEN every key is a tuple of two strings, and the set of keys equals the set returned by pinned_charts()

Requirement: version mismatch fails

A test SHALL fail when an Application pins a chart version that CHART_CLAIMS does not name.

Scenario: pinned version not in table

  • WHEN pinned_charts() returns a (chart, version) pair that is not a key of CHART_CLAIMS
  • THEN the test asserts a non-empty symmetric difference and fails

Requirement: placement checks unchanged

The existing placement checks SHALL pass with the new key structure.

Scenario: all placement tests pass

  • WHEN uv run devops ci test tests/test_k8s_local_path_placement.py is run
  • THEN every test in the module passes

Existing Tool Considered

No external tool covers this need. The fix is a repository-internal test change. It reuses pinned_charts() from tests/support/k8s_tree.py and copies the tuple key pattern from _CHART_TOKENS in tests/invariants/test_k8s_manifests.py. The written cost is the tokens to change the CHART_CLAIMS key type from str to tuple[str, str], update the _chart_sites lookup, add one test function, and update the existing coverage test. No new dependency is added.

Key questions

  • What key structure does CHART_CLAIMS use after the fix?: tuple[str, str], the same as _CHART_TOKENS. Each key is (chart_name, pinned_version). (best practice) [sources: tests/invariants/test_k8s_manifests.py, openspec/changes/archive/2026-10-28-1652-no-unused-service-account-token/design.md]
    • Chosen: tuple[str, str] matching _CHART_TOKENS. The pattern already exists in the same codebase. The token test's design document records the decision to name the version so a chart bump fails until the entry is re-read.
    • Rejected: keep str key and add a separate version list. Two structures to keep in sync. The token test already proved the tuple key is simpler and the symmetric-difference check is one line.
  • How does the test obtain the pinned chart versions?: pinned_charts() in tests/support/k8s_tree.py already returns frozenset[tuple[str, str]] of (chart, targetRevision) for every Application source that has a chart. [sources: tests/support/k8s_tree.py]
  • How does _chart_sites look up a chart when the key is a tuple?: Match by chart name only, ignoring the version in the key, exactly as _chart_sites in test_k8s_manifests.py does: (sites for (name, _), sites in CHART_CLAIMS.items() if name == chart). (best practice) [sources: tests/invariants/test_k8s_manifests.py]
    • Chosen: match by name only, like the token test. The version is checked by the separate symmetric-difference test. The lookup only needs the chart name to find the right entry.
    • Rejected: match by full tuple including version. Would require chart_values() to yield the version, changing the shared helper. The token test does not do this.
  • Which test asserts the version match?: A new test in test_k8s_local_path_placement.py asserts sorted(pinned_charts() ^ CHART_CLAIMS.keys(), key=str) == [], mirroring test_the_chart_table_names_each_chart_at_the_version_that_an_application_pins in test_k8s_manifests.py. (best practice) [sources: tests/invariants/test_k8s_manifests.py]
    • Chosen: symmetric difference with pinned_charts(). Catches both a missing entry and a stale version. The token test uses this exact assertion.
    • Rejected: subset check only (pinned_charts() - CHART_CLAIMS.keys()). Would miss a stale entry for a chart that is no longer installed. The symmetric difference is stricter and matches the existing pattern.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/test
    status/new
    value/medium
    effort/low
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/test. The change fixes a test table so it fails when a chart version moves a value path.
    • Priority: P2-Medium. A silent test pass could let a pod bind a volume on the control-plane node, but no live incident is reported.
    • Value: Medium. It closes a gap where a chart release can move a claim switch and the test still passes.
    • Effort: Low. The pattern already exists in _CHART_TOKENS; the fix copies that key structure and adds a version check.
    • Related: fix(k8s): the volumes of grafana, the prometheus server and loki move off the control-plane node, and their placement exemptions go #2147, which asks for a different change. Both items work on the local-path placement test area of #1634, but #2147 moves volumes off the control-plane node while the candidate fixes the test table to be version-aware.
  3. added
    priority/p2-medium
    on Oct 28, 2026
  4. added
    status/ready
    and removed
    status/new
    on Oct 29, 2026
  5. devops-cli-service commented on Oct 29, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 0f7bc26 (see proposed design in issue body).

  6. added
    type/bug
    scope/k8s
    and removed
    type/test
    on Oct 30, 2026
  7. devops-cli-service commented on Nov 1, 2026

    @devops-cli-service
    Contributor

    Staged: branch fix/2519-the-claim-table-of-the-local, draft pull request #3001. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Key CHART_CLAIMS by chart version and add the mismatch test: 3306 tokens
  8. added a commit that references this issue on Nov 1, 2026
  9. 187 remaining items

  10. added
    status/planned
    on Nov 5, 2026
  11. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Cleared the stop at group 1 by the rule digest: the runner image changed since the stop, from sha256:b161a617dc04fdc13d2c96b33b2a4acbfe6bebfae21942588aa7201250eb6e29 to sha256:6e4db5c738b1a1dced0e45de878bce280ec69321cebc5bb7cdfe0a06fe074b6f, and the class tests_lost of the stop is one that a new attempt can fix. The item is Planned again, and the Service takes it in the next round. The Service clears at most 1 for each class and 3 for each item by digest. A stop of another class, a new stop on this image, and a stop over a limit wait for a comment implement: retry.

  12. changed the title [-]fix(k8s): the claim table of the local-path placement test names the chart version that it was read from[/-] [+]fix(k8s): key claim table by chart version[/+] on Nov 6, 2026
  13. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    The job shortened the title of this item. The summary had 94 characters, and the limit is 60. The type and the scope stay.

  14. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/planned
    status/in-progress
    on Nov 6, 2026
  15. removed
    status/in-review
    owner/agent
    on Nov 6, 2026
  16. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-06 18:04 UTC

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

    effort/lowpriority/p2-mediumscope/k8ssource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions