Skip to content

fix(k8s): k8s lint of all charts nears its 300 s limit #7900

Not planned

Description

@dan-petty

Problem

With no TARGET, devops k8s lint lints the renders of all chart sources in one kube-linter run, which has a limit of 300 s. On the environment tree of dan-petty/homelab at 795c247 the run is near that limit, and on a loaded host it ends with Kube-linter audit failed: timed out after 300 s.

Reproduction

Measured on 2026-11-30 on a host with 16 CPUs, kube-linter 0.8.3, on the folder of the 52 builds:

  • load average 3 to 5: 238 s and 247 s of wall time, 328 s and 342 s of CPU time
  • load average about 23: the command timed out after 300 s

The check make k8s-charts of that repository lints the same chart sources without their CustomResourceDefinitions. Its workflow records 30 s to 60 s for the kube-linter run.

Expected behavior

The lint of all chart sources ends well inside its limit. kube-linter has no check of a CustomResourceDefinition, so the plan must first measure how much of the time the CustomResourceDefinitions take.

Existing Tool Considered

kube-linter 0.8.3 is the linter. No tool is built here.

Alternatives check of 2026-11-30: none.
Tool: none found.
Reason: Searches found kube-linter and fast validators such as kubeconform. No tool shards or parallelizes a kube-linter run over many charts, so the fix stays in the devops CLI.

Lacks:

  • No tool splits the run per chart source
  • No kube-linter check covers CustomResourceDefinitions
  • Schema validators such as kubeconform do not run kube-linter checks

Proposed design

Problem statement

devops k8s lint with no TARGET renders each source of the environment tree and gives all renders to one kube-linter run. That run has the 300 s wall limit of the devops CLI, not a limit of kube-linter. The homelab tree needs 328 s to 342 s of CPU time for the run, so a loaded host ends it with timed out after 300 s. The change removes the rendered documents of kind CustomResourceDefinition, because no enabled check reads them, unless the config of the tree declares a check of that kind. It gives the tree lint a 900 s wall limit and prints the wall time and the skipped count. It keeps one run for the whole tree, because a run for each render gives false findings for the checks that read sibling files.

Acceptance criteria

Requirement: Skip the CustomResourceDefinition documents of the tree lint

The devops k8s lint command with no TARGET SHALL remove each rendered document with kind CustomResourceDefinition from the renders folder before it starts kube-linter, when the config of the tree declares no check scoped to that kind.

Scenario: A render with one Deployment and one CustomResourceDefinition

  • WHEN a unit test lints the tree through the fake tool executor, and the render of one source holds a Deployment and a CustomResourceDefinition
  • THEN the kube-linter request names a folder that holds only the Deployment, and the command output holds the skipped count 1.

Requirement: Keep the CustomResourceDefinition documents that the config checks

The devops k8s lint command MUST keep each rendered document with kind CustomResourceDefinition in the renders folder when the config of the tree declares a check whose scope.objectKinds names CustomResourceDefinition.

Scenario: A config with a CRD-scoped custom check

  • WHEN a unit test lints a tree whose .kube-linter.yaml declares a custom check with objectKinds: [CustomResourceDefinition]
  • THEN the kube-linter request names a folder that holds the CustomResourceDefinition document.

Requirement: A TARGET lint keeps the document that it names

The devops k8s lint command with a TARGET SHALL give kube-linter every document of that target and the 300 s wall limit.

Scenario: A TARGET folder with a CustomResourceDefinition

  • WHEN a unit test lints a folder that holds one CustomResourceDefinition as TARGET
  • THEN the kube-linter request names that folder, and its limits.wall_seconds is 300.0.

Requirement: One kube-linter run for the whole tree

The devops k8s lint command with no TARGET MUST start one kube-linter process for all renders of the tree.

Scenario: Three rendered sources

  • WHEN a unit test lints a tree whose three sources render three documents
  • THEN the fake tool executor records one kube-linter request, and the folder of that request holds three files.

Requirement: The tree lint has its own wall limit

The devops k8s lint command with no TARGET SHALL give its kube-linter run a wall limit of 900 s.

Scenario: The wall limit of the tree run

  • WHEN a unit test lints the tree through the fake tool executor
  • THEN the limits.wall_seconds of the kube-linter request is 900.0.

Requirement: A timeout names the limit and the tree

When the kube-linter run of the tree ends with a timeout, the command MUST exit non-zero with a message that holds the wall limit and the root of the tree.

Scenario: The tree run times out

  • WHEN the fake tool executor answers the kube-linter request of the tree with timed_out=True
  • THEN the command exits 1, and its output holds timed out after 900 s and the root path of the tree.

Requirement: Report the wall time and the skipped count

The devops k8s lint command with no TARGET SHALL print the wall time of the kube-linter run and the count of skipped CustomResourceDefinition documents.

Scenario: Two CRDs in three sources

  • WHEN a unit test lints a tree whose three sources hold two CustomResourceDefinition documents
  • THEN the command output holds the skipped count 2 and a wall-time line with the seconds of the run.

Requirement: Pending a person after the merge

The lint of the homelab tree MUST end inside its 900 s limit and record the time that the CustomResourceDefinitions take.

Scenario: Live check on the homelab tree

  • WHEN after the merge, a person runs uv run devops k8s lint --k8s-dir k8s in dan-petty/homelab at 795c247 at a load average of 3 to 5
  • THEN the command exits 0, its output holds a skipped count above zero and the wall time of the run, and the wall time is less than 120 s, as the make k8s-charts run of 30 s to 60 s without the CRDs predicts.

Existing Tool Considered

kube-linter 0.8.3 (stackrox/kube-linter) is the linter and stays the linter. The alternatives check of 2026-11-30 records the verdict none with no other tool, and its block records what kube-linter lacks. The change adds a filter of the rendered documents and one wall limit in the devops CLI: about 4k tokens to build, about 2k tokens to keep and fix, over about half a day.

Key questions

  • Where does the 300 s limit of devops k8s lint come from?: It is the wall limit of the devops CLI itself. DEFAULT_SECURITY_SCANNER_TIMEOUT_SECONDS is 300.0, the scanner hands it to the tool run as limits.wall_seconds, and it builds the reason timed out after 300 s from it. kube-linter sets no such limit. [sources: src/devops_cli/config/defaults.py:344, src/devops_cli/security/base.py:726, src/devops_cli/security/tool_executor.py:158]
  • Does a check of the config that the lint reads cover a CustomResourceDefinition?: No check of the config of this repository reads one. The enabled checks are workload checks, and the one custom check scopes to PersistentVolumeClaim. The tree reads its own config, so the filter reads that config for a check scoped to CustomResourceDefinition. [sources: .kube-linter.yaml:16, .kube-linter.yaml:26, .kube-linter.yaml:37, src/devops_cli/commands/k8s/security_audit.py:159]
  • Should the lint remove the CustomResourceDefinition documents before the kube-linter run?: Yes, but only when the config of the tree declares no check scoped to CustomResourceDefinition. A custom check with scope.objectKinds that names the kind keeps the documents in the run. (best practice) [sources: .kube-linter.yaml:16, .kube-linter.yaml:27, src/devops_cli/k8s/image_pins.py:455]
    • Chosen: Remove the CRD documents unless the config checks them. No enabled check of the config reads a CRD, and the make k8s-charts run without the CRDs records 30 s to 60 s. The guard keeps a config that does check CRDs.
    • Rejected: Remove the CRD documents always. A custom check with objectKinds: [CustomResourceDefinition] would lose its objects, with no message.
    • Rejected: Keep the CRD documents and only move the limit. The issue measures 238 s and 247 s with them, against 30 s to 60 s without them.
  • How does the lint keep the kube-linter run inside its limit?: It keeps one run over the whole renders folder and raises the wall limit of the tree lint to 900 s. It does not split the run, because the checks non-isolated-pod and dangling-service read sibling files, and a run for each file reports false findings. (best practice) [sources: src/devops_cli/security/kubelinter.py:25, .kube-linter.yaml:26, src/devops_cli/commands/k8s/security_audit.py:180, src/devops_cli/config/defaults.py:344]
    • Chosen: One run with a 900 s wall limit for the tree lint. The limit is the own default of the CLI, so it moves without a tool change, and one run keeps the checks that read sibling files.
    • Rejected: One run for each rendered file. dangling-service gives false findings when kube-linter does not see the pods of a sibling file (src/devops_cli/security/kubelinter.py:25), and the config enables non-isolated-pod.
    • Rejected: One run for each chart source. One chart source render is one file, so this splits the same sibling-file checks across runs.
    • Rejected: Raise the limit of kube-linter. kube-linter sets no limit here. The 300 s is the default of the devops CLI (src/devops_cli/config/defaults.py:344).
    • Rejected: Run the kube-linter processes at the same time. The issue measures the timeout on a host at load 23, so more processes add load.
  • Which wall limit does the tree lint take?: 900 s, three times the 300 s default. The reply records 363 s of wall time at a load average of 9 to 11, so 900 s covers a loaded host and still bounds a hung tool. (best practice) [sources: src/devops_cli/config/defaults.py:344, src/devops_cli/security/base.py:726]
    • Rejected: 600 s. The measured 363 s leaves little room for a higher load.
    • Chosen: 900 s. It is three times the measured wall time and keeps a bound on a hung tool.
    • Rejected: No limit. A hung kube-linter run would never end.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    scope/k8s
    source/agent
    on Nov 30, 2026
  2. dan-petty commented on Nov 30, 2026

    @dan-petty
    OwnerAuthor
  3. added
    status/new
    value/medium
    effort/medium
    priority/p1-high
    on Nov 30, 2026
  4. dan-petty commented on Nov 30, 2026

    @dan-petty
    OwnerAuthor

    More data from the work on #7889 (pull request #7901), on 2026-11-30 and main of dan-petty/homelab at 7569d2c:

    • devops k8s lint --k8s-dir k8s with all chart sources, at a load average of 9 to 11 on 16 CPUs, ended after 363 s with Kube-linter audit failed: timed out after 300 s.
    • The namespace step of fix(k8s): namespace chart renders and add lint --no-charts #7901 is not the cause: on the same renders the CPU time of kube-linter was 342 s with it and 328 s without it.
  5. devops-cli-service commented on Nov 30, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (10)

    Tools considered:

    Searches run:

    • kube-linter slow on many charts parallel lint timeout, results: 5
    • faster kube-linter alternative lint multiple helm charts performance, results: 5
    • kube-linter github stackrox, results: 5
    • kubeconform validate kubernetes manifests fast, results: 5
    • kube-linter lint timeout 300 seconds many directories, results: 5
    • kube-linter concurrency parallel workers issue, results: 5
    • kube-linter documentation lint command flags timeout, results: 5
    • kube-linter docs configuration reference, results: 5
    • kube-score vs kube-linter helm charts parallel, results: 5
    • kube-linter, results: 5

    Sources:

  6. added
    status/ready
    and removed
    status/new
    on Dec 1, 2026
  7. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  8. added
    owner/service
    on Dec 1, 2026
  9. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    Plan state: branch fix/7900-k8s-lint-of-all-charts-nears, draft pull request #8003. The pull request plans the item and closes no issue. The stage job and the step fix-plan edit this comment, and a comment of each run tells what the run did.

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

    1. Filter the CRD documents of the renders folder: 31656 tokens
    2. Give the tree lint its limit, filter and report: 54065 tokens
    3. Update the docstring and the generated documents: 43655 tokens
  10. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    The stage job staged the plan of draft pull request #8003. The plan state comment of #8003 holds the branch, the task groups and the findings.

    The runs of the planner and the review made 79 model request(s), and used 5125719 input tokens and 87738 output tokens. The tool calls, in order:

    Run 1 (stage):

    1. file_symbols({"path":"src/devops_cli/commands/k8s/security_audit.py"})
    2. read_file({"path":"src/devops_cli/commands/k8s/security_audit.py","start_line":1,"end_line":210})
    3. read_file({"path":"src/devops_cli/commands/k8s/security_audit.py","start_line":183,"end_line":210})
    4. file_symbols({"path":"src/devops_cli/security/kubelinter.py"})
    5. read_file({"path":"src/devops_cli/security/kubelinter.py","start_line":105,"end_line":200})
    6. read_file({"path":"src/devops_cli/security/base.py","start_line":640,"end_line":760})
    7. search_code({"text":"def for_tool","path":"src/devops_cli/security"})
    8. read_file({"path":"src/devops_cli/security/tool_executor.py","start_line":145,"end_line":200})
    9. search_code({"text":"CONST_TOOL_CPU_LIMIT_SECONDS"})
    10. search_code({"text":"def write_application_renders"})
    11. read_file({"path":"src/devops_cli/k8s/image_pins.py","start_line":425,"end_line":520})
    12. search_code({"text":"k8s_lint","path":"tests"})
    13. read_file({"path":"tests/commands/k8s/test_k8s.py","start_line":1540,"end_line":1735})
    14. read_spec({"capability":"k8s-lint","requirement":"The lint of the environment tree reads the build of each path source"})
    15. references({"name":"kube_linter_tree"})
    16. read_file({"path":"src/devops_cli/lang/en/messages.py","start_line":806,"end_line":830})
    17. search_code({"text":"def _has_kubernetes_object","path":"src/devops_cli/k8s"})
    18. read_file({"path":"src/devops_cli/k8s/image_pins.py","start_line":405,"end_line":426})
    19. search_code({"text":"YAML_SAFE_LOADER","path":"src/devops_cli/k8s/image_pins.py"})
    20. search_code({"text":"kube_linter_not_run"})
    21. search_code({"text":"builds in one run with the"})
    22. find_issues({"terms":"k8s lint kube-linter"})

    Run 2 (stage):

    1. read_file({"path":".kube-linter.yaml","start_line":14,"end_line":38})
    2. read_file({"path":"src/devops_cli/security/base.py","start_line":720,"end_line":728})
    3. search_code({"text":"write_application_renders","path":"src/devops_cli"})
    4. read_file({"path":"src/devops_cli/k8s/image_pins.py","start_line":440,"end_line":500})
    5. read_file({"path":"src/devops_cli/commands/k8s/security_audit.py","start_line":100,"end_line":215})
    6. read_file({"path":"src/devops_cli/security/kubelinter.py"})
    7. search_code({"text":"timeout: float","path":"src/devops_cli/security/base.py"})
    8. search_code({"text":"kube_linter_tree","path":"src/devops_cli/lang/en/messages.py"})

    Run 3 (stage):

    1. search_code({"text":"write_text(rendered, encoding=\"utf-8\")","path":"src/devops_cli/k8s/image_pins.py"})
    2. search_code({"text":"timed out after","path":"src/devops_cli/security/base.py"})
    3. file_symbols({"path":"src/devops_cli/k8s/image_pins.py"})
    4. find_issues({"terms":"k8s lint kube-linter"})

    Run 4 (stage):

    1. read_file({"path":"src/devops_cli/config/defaults.py","start_line":344,"end_line":344})
    2. read_file({"path":"src/devops_cli/security/base.py","start_line":722,"end_line":728})
    3. read_file({"path":"src/devops_cli/k8s/image_pins.py","start_line":453,"end_line":457})

    Run 5 (stage):

    1. read_file({"path":"src/devops_cli/config/defaults.py","start_line":344,"end_line":344})
    2. read_file({"path":"src/devops_cli/security/base.py","start_line":720,"end_line":730})
    3. read_file({"path":"src/devops_cli/k8s/image_pins.py","start_line":445,"end_line":462})

    Run 6 (stage):

    1. read_file({"path":"src/devops_cli/config/defaults.py","start_line":344,"end_line":344})
    2. read_file({"path":"src/devops_cli/security/base.py","start_line":722,"end_line":728})
    3. read_file({"path":"src/devops_cli/k8s/image_pins.py","start_line":450,"end_line":460})
    4. find_issues({"terms":"k8s lint kube-linter"})

    Run 7 (stage):

    1. read_file({"path":"src/devops_cli/config/defaults.py","start_line":343,"end_line":345})
    2. read_file({"path":"src/devops_cli/security/base.py","start_line":722,"end_line":728})
    3. read_file({"path":"src/devops_cli/k8s/image_pins.py","start_line":450,"end_line":458})
    4. search_code({"text":"def k8s_lint","path":"src"})
    5. read_file({"path":"src/devops_cli/commands/k8s/security_audit.py","start_line":105,"end_line":215})
    6. read_file({"path":"src/devops_cli/security/kubelinter.py","start_line":15,"end_line":40})
    7. search_code({"text":"def run_kubelinter_scan","path":"src/devops_cli/security/kubelinter.py"})
    8. read_file({"path":"src/devops_cli/security/kubelinter.py","start_line":145,"end_line":200})
    9. search_code({"text":"timeout: float = DEFAULT_SECURITY_SCANNER_TIMEOUT_SECONDS","path":"src/devops_cli/security/base.py"})
    10. read_file({"path":"src/devops_cli/security/base.py","start_line":738,"end_line":760})
    11. find_issues({"terms":"k8s lint kube-linter"})

    Run 8 (stage):

    1. search_code({"text":"timed out after {timeout:g} s","path":"src/devops_cli/security/base.py"})
    2. read_file({"path":"src/devops_cli/security/base.py","start_line":722,"end_line":746})
    3. search_code({"text":"_kube_lint(","path":"src/devops_cli/commands/k8s/security_audit.py"})
    4. read_file({"path":"src/devops_cli/commands/k8s/security_audit.py","start_line":120,"end_line":215})

    Run 9 (stage_verify):

    1. read_file({"path":"src/devops_cli/commands/k8s/security_audit.py","start_line":110,"end_line":260})
    2. read_file({"path":"src/devops_cli/security/kubelinter.py","start_line":125,"end_line":190})
    3. read_file({"path":"src/devops_cli/security/base.py","start_line":690,"end_line":800})
    4. read_comment({})
    5. read_comment({"number":2})
    6. search_code({"text":"devops ci docs"})
    7. search_code({"text":"wall_seconds","path":"src/devops_cli/security"})
    8. read_file({"path":"src/devops_cli/security/tool_executor.py","start_line":140,"end_line":180})
    9. search_code({"text":"CONST_TOOL_CPU_LIMIT_SECONDS"})
    10. find_issues({"terms":"k8s lint kube-linter"})
    11. read_spec({"capability":"k8s-lint"})

    Tool calls: file_symbols=3 (empty=0), find_issues=5 (empty=0), read_comment=2 (empty=0), read_file=36 (empty=0), read_spec=2 (empty=0), references=1 (empty=0), search_code=21 (empty=0)

    The stage job read the open pull requests and their files in 1 GraphQL request(s).

    The plan request held these comments of the item whole: #7900 (comment), #7900 (comment), #7900 (comment), #7900 (comment).

  11. added
    owner/service
    and removed
    owner/service
    on Dec 1, 2026
  12. added a commit that references this issue on Dec 1, 2026
  13. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    The stage job staged the plan of draft pull request #8003. The plan state comment of #8003 holds the branch, the task groups and the findings.

    The runs of the planner and the review made 21 model request(s), and used 1494617 input tokens and 17050 output tokens. The tool calls, in order:

    Run 1 (stage):

    1. read_file({"path":"src/devops_cli/config/defaults.py","start_line":343,"end_line":345})
    2. read_file({"path":"src/devops_cli/security/base.py","start_line":722,"end_line":746})
    3. read_file({"path":"src/devops_cli/commands/k8s/security_audit.py","start_line":120,"end_line":215})
    4. read_file({"path":"src/devops_cli/k8s/image_pins.py","start_line":440,"end_line":462})
    5. find_issues({"terms":"k8s lint kube-linter"})
    6. references({"name":"Lint Kubernetes manifests with kube-linter. With no TARGET"})
    7. read_spec({"capability":"k8s-lint","requirement":"The lint of the environment tree reads the build of each path source"})
    8. search_code({"text":"def test_k8s_lint_of_the_tree_lints_the_build_of_each_application","path":"tests"})

    Run 2 (stage_verify):

    1. read_spec({"capability":"k8s-lint"})
    2. read_file({"path":"src/devops_cli/commands/k8s/security_audit.py","start_line":120,"end_line":260})
    3. read_file({"path":"src/devops_cli/security/kubelinter.py","start_line":140,"end_line":200})
    4. read_file({"path":"src/devops_cli/security/base.py","start_line":690,"end_line":800})
    5. search_code({"text":"ci docs"})
    6. search_code({"text":"CustomResourceDefinition","path":"src"})
    7. search_code({"text":"wall_seconds","path":"src/devops_cli/security"})
    8. read_comment({})
    9. read_comment({"number":2})
    10. search_code({"text":"test_the_tool_listing_matches_the_snapshot"})
    11. search_code({"text":"write_text(rendered","path":"src/devops_cli/k8s/image_pins.py"})

    Tool calls: find_issues=1 (empty=0), read_comment=2 (empty=0), read_file=7 (empty=0), read_spec=2 (empty=0), references=1 (empty=0), search_code=6 (empty=0)

    The stage job read the open pull requests and their files in 1 GraphQL request(s).

    The plan request held these comments of the item whole: #7900 (comment), #7900 (comment), #7900 (comment), #7900 (comment), #7900 (comment), #7900 (comment).

    This run replaced the plan of draft pull request #8003 on the same branch, and opened no second pull request.

  14. removed
    owner/service
    on Dec 1, 2026
  15. dan-petty commented on Dec 1, 2026

    @dan-petty
    OwnerAuthor

    Replaced by dan-petty/github-workflows#69. The measurement on #8003 shows that the cause is the scope objectKinds: [Any] of the check network-policy-egress-alone in the shared kube-linter config. With the scope NetworkPolicy, the run takes 56.4 s in place of 283.5 s, with the same 153 errors. This repository needs no change. The acceptance criterion that excludes CustomResourceDefinitions cannot pass, because kube-linter refuses that object kind.

  16. removed
    status/ready
    on Dec 1, 2026
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/mediumpriority/p1-highscope/k8ssource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions