Skip to content

feat(k8s): cluster-wide cpu budget env, and events RBAC for the pod-warning watcher - #1184

Open
PatrickKalkman wants to merge 1 commit into
jayminwest:mainfrom
PatrickKalkman:feat/k8s-cpu-rbac
Open

feat(k8s): cluster-wide cpu budget env, and events RBAC for the pod-warning watcher#1184
PatrickKalkman wants to merge 1 commit into
jayminwest:mainfrom
PatrickKalkman:feat/k8s-cpu-rbac

Conversation

@PatrickKalkman

Copy link
Copy Markdown

Two small K8s-runtime fixes, found while bringing warren up on a laptop cluster (Rancher Desktop, k3s, 2 allocatable cores) to drive Azure DevOps repos.

Why we needed it

  • A run pod requests 1 CPU by default. On a 2-core node where the system pods already hold ~1.2 cores, the pod sat in Pending with FailedScheduling: Insufficient cpu and the run was eventually cancelled. Memory and ephemeral storage already have cluster-wide WARREN_K8S_* env defaults; CPU did not. The only override was a resources block in the target repo's .warren/config.yaml, which is not always possible when the repo is not yours to change (or is a mirror).
  • The FailedScheduling was also invisible from warren: the pod-warning-events watcher (warren-32f8) logged pod-event-watch disconnected; backing off before resume in a loop. The base Role grants pods/pods.log/configmaps but never events, so every list-watch got 403. Anyone deploying from deploy/k8s/base has a dead watcher today.

Changes

  • WARREN_K8S_CPU_REQUEST_MILLICORES / WARREN_K8S_CPU_LIMIT_MILLICORES (src/runtime/k8s/pod-resources.tsresolveCpuMillicores), same precedence as the memory knob: per-project resources block > env > compiled defaults (1000/4000). Validated to the same 10m..64 CPU bounds the config schema uses; invalid values fall back, like pickMiB. pod-spec.ts consumes it.
  • deploy/k8s/base/rbac.yaml: get/list/watch on core events for the runs-namespace Role.
  • docs/RUNBOOK-K8S.md: rows for the new CPU knob and for the existing WARREN_K8S_MEMORY_* knob, which was missing from the env table.
  • Tests: pod-resources.test.ts covers env override, per-project precedence, and invalid-value fallback.

Verified on the cluster above: with WARREN_K8S_CPU_REQUEST_MILLICORES=250 the pod schedules, and with the RBAC change the watcher connects and FailedScheduling/image-pull warnings land on the run's event stream.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rf5tbgdUDmHzKnNXpiJLvg

…-warning watcher

WARREN_K8S_CPU_REQUEST_MILLICORES / _LIMIT_MILLICORES mirror the memory knob: a run pod on a two-core node never scheduled the 1-CPU default request, and the repo cannot always carry a .warren/ resources block. The base Role never granted list/watch on core Events, so the pod-warning watcher (warren-32f8) reconnected on 403 forever.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rf5tbgdUDmHzKnNXpiJLvg
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T08:53:48.188750Z 830e5aa PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 830e5aa345

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread deploy/k8s/base/rbac.yaml
Comment on lines +50 to +51
resources: ["events"]
verbs: ["get", "list", "watch"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Document the Events grant in the RBAC matrix

When an operator audits or recreates the minimal Role from docs/RUNBOOK-K8S.md §4, the table—explicitly described there as the exact set of resources Warren exercises—still lists only pods, pod logs, and ConfigMaps. Omitting this new events dependency would leave the warning watcher receiving 403 responses again, so add an events row with its get, list, watch verbs and watcher rationale.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant