-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Create k8s-log-reviewer.md for logging review process #9037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
CatherineF-dev
wants to merge
4
commits into
kubernetes:main
Choose a base branch
from
CatherineF-dev:log-reviewer-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+102
−0
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
31df1c2
Create k8s-log-reviewer and k8s-log-instrumenter skills
CatherineF-dev 5c6a312
Refactor folder structure to align with https://agentskills.io/specif…
CatherineF-dev c19e6c2
Update contributors/devel/sig-instrumentation/k8s-log-reviewer/SKILL.md
CatherineF-dev c5172fc
Update contributors/devel/sig-instrumentation/k8s-log-reviewer/SKILL.md
CatherineF-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...tors/devel/sig-instrumentation/logging.md → ...rumentation/k8s-log-instrumenter/SKILL.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
contributors/devel/sig-instrumentation/k8s-log-reviewer/SKILL.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| --- | ||
| name: k8s-log-reviewer | ||
| description: Review a kubernetes/kubernetes pull request that changes logging code, applying SIG-Instrumentation approver standards for structured logging (klog InfoS/ErrorS), contextual logging (logr via context, klog.FromContext, WithLogger variants), logcheck enforcement, key/value and verbosity conventions, and ktesting. Use when asked to review a k8s PR/diff that touches logging, klog, structured/contextual logging, or logcheck.conf. Trigger phrases: "review this logging PR", "sig-instrumentation log review", "is this structured/contextual logging correct". | ||
| --- | ||
|
|
||
| # SIG-Instrumentation Logging Review | ||
|
|
||
| Review a `kubernetes/kubernetes` PR the way a **SIG-Instrumentation approver** would for **logging** | ||
| changes. | ||
|
|
||
| This skill reviews **only** logging-relevant changes. If the PR doesn't touch logging, say so and stop. | ||
| (For metrics, use `sig-instrumentation-metrics-review` instead.) | ||
|
|
||
| ## Step 1 — Get the change | ||
| - A PR number/URL → `gh pr view <n> --repo kubernetes/kubernetes` + `gh pr diff <n> --repo kubernetes/kubernetes`. | ||
| - A local branch → `git diff` against the merge base. A pasted diff → use directly. | ||
| - No `gh`/auth → GitHub API (`/repos/kubernetes/kubernetes/pulls/<n>/files`) or ask for the diff. | ||
|
|
||
| ## Step 2 — Scope to logging | ||
| In-scope signals (any of): | ||
| - Adds/changes `klog.*` calls (`InfoS`, `ErrorS`, `Info`, `Infof`, `V(n)`, `KObj`, `KRef`, | ||
| `FromContext`, `Background`, `TODO`), or `logr.Logger` usage. | ||
| - Adds a `logger`/`ctx` parameter or a `…WithLogger` variant for contextual logging. | ||
| - Edits `hack/logcheck.conf`, `hack/tools` logcheck/logtools versions, or golangci-lint logging linters. | ||
| - Touches `k8s.io/component-base/logs` (incl. JSON logging) or `ktesting`. | ||
|
|
||
| If none apply, report "not a logging change — out of scope" and stop. | ||
|
|
||
| ## Step 3 — Review checklist | ||
| For each finding cite file:line and tag **BLOCKER** / **NIT** / **QUESTION**. | ||
|
|
||
| ### A. Structured form | ||
| - **BLOCKER**: new unstructured `klog.Info/Infof/Errorf/Warningf` in a migrated package — use | ||
| `InfoS`/`ErrorS`. `ErrorS(err, msg, kv...)` takes the error **first**. Use it for log output that needs admin attention, otherwise prefer `InfoS`. `ErrorS` may be called with nil error. `InfoS` may be called with `"err": err` to log an error. | ||
| genuinely no error). | ||
| - Message must be a **constant string** (no `fmt.Sprintf`), capitalized, no trailing punctuation/newline. | ||
| - Keys are **lowerCamelCase**, stable, and reused (don't invent a new key for an existing concept). | ||
| - Object values use `klog.KObj(obj)` / `klog.KRef(ns, name)`, not `%s`/`%v` formatting. | ||
|
|
||
| ### B. Contextual logging (KEP-3077) | ||
| - Obtain the logger from context: `logger := klog.FromContext(ctx)`; libraries receive a logger via | ||
| ctx rather than calling `klog.Background()`. | ||
| - New public functions that log should accept `ctx`/`logger`. A `ctx` is preferred if the function supports cancellation, otherwise a `logger`. | ||
| - `WithValues` for repeated key/value pairs; `WithName` to scope a component's logger. | ||
| - **QUESTION/BLOCKER** on `context.Background()`/`context.TODO()` in new code without a justifying | ||
| comment + tracking issue. | ||
|
|
||
| ### C. logcheck / tooling | ||
| - If the PR migrates a package, it must **add that package to `hack/logcheck.conf`** so enforcement | ||
| sticks; conversely, don't enable a directory whose prerequisites aren't met. | ||
| - logcheck runs via golangci-lint; logtools/logcheck version bumps live in `hack/tools`. Confirm CI | ||
| (`pull-kubernetes-verify` / golangci-lint) covers the change. | ||
|
|
||
| ### D. Verbosity | ||
| - Right `V()` level: `V(0)` important/always, `V(2)` useful steady-state, `V(4)` debug, `V(5)` trace. | ||
| Flag high-cost values logged at low verbosity, and secrets/PII logged at any level. | ||
|
|
||
| ### E. Events | ||
| - Contextual event migration is **all-or-nothing** per area; grep for stragglers. Plugins should be | ||
| able to attach key/values via `EventRecorderLogger`. | ||
|
|
||
| ### F. Tests | ||
| - Log-output assertions use `ktesting` with per-test isolation, not the global logger. Behavior tests | ||
| should still exercise the real code path. | ||
|
|
||
| ## Step 4 — Output | ||
| ``` | ||
| ## SIG-Instrumentation Logging Review — PR #<n>: <title> | ||
|
|
||
| **Scope:** <which logging/files this touches> | ||
| **Verdict:** /lgtm | /approve | changes requested | needs SIG discussion | ||
|
|
||
| ### Blockers | ||
| - [file:line] <issue> — <why> → <fix> | ||
|
|
||
| ### Nits | ||
| - [file:line] <suggestion> | ||
|
|
||
| ### Questions for author | ||
| - <question> | ||
|
|
||
| ### Required before merge | ||
| - make verify WHAT=verify-golangci-lint (logcheck runs here) | ||
| - ensure migrated packages are added to hack/logcheck.conf | ||
| ``` | ||
| Be concrete, cite lines, explain the *why* (JSON searchability, contextual-logging correctness, | ||
| cancellation propagation) — not just the rule. | ||
|
|
||
| ## Reference | ||
| - `OWNERS_ALIASES` → `sig-instrumentation-approvers`. | ||
| - Structured logging: `kubernetes/community` → `contributors/devel/sig-instrumentation/migration-to-structured-logging.md` | ||
| (KEP-1602); contextual logging: `…/contextual-logging.md` (KEP-3077). | ||
| - logcheck lives in `sigs.k8s.io/logtools`; config at `hack/logcheck.conf`. | ||
| - klog API & `ktesting`: `k8s.io/klog/v2`. | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker for this PR, just a general observation: people dumping a single AI review back into a top-level comment put the work of correlating the finding back to source code on the
maintainerdeveloper. It also doesn't enable per-finding discussion threads in the PR review.If this becomes more common, we may have to make it clear that such reviews are not desirable.
OTOH, they offload work from the bottleneck (maintainer) to the person who presumably has more time (contributor).
🤷
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As just added here,
Human Review Required: All suggestions, checklists, and reports generated by these agent skills must be reviewed and verified by a human before being posted as comments on any pull request.
Inline comments are possible.
Currently, sig-instrumentation reviewers will choose and post comments after manual review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can
gh apialso start a review, i.e. keep the comment pending?The perfect workflow would be:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the workflow we plan to use since github supports draft/pending comments. We want to evaluate its values first. We will update the skill over time to optimize the review flow.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pohly
I created a review tool that it loads related review skills based on context and added draft comment. Then I can accept/edit/reject the comment, then these comments will be posted into github. We might switch review tool to another one, but the review skills keep the same.