← Back to Pull requests

fix(project-controller): keep namespace labels the project-controller does not own #172

Merged
blacksoxx merged 3 files (59 lines) on Nov 03, 2026 08:04 UTC
View on GitHub
blacksoxx blacksoxx commented on Oct 26, 2026 13:57 UTC
Author

Description

handleExistingNamespace replaced metadata.labels with the project and version labels on every update, because the object sent to Update is built fresh from the Project and only annotations were carried over from the existing namespace. Flipping spec.enforceKaiScheduler, or adopting a pre-created namespace, therefore removed Pod Security Admission labels, NetworkPolicy selector labels and any other label set by someone else. Existing labels are now merged in the same way as annotations: every key the handler does not set itself is kept.

Related issues

Fixes #171

Checklist

  • Self-reviewed the complete diff

  • Added or updated tests where needed

  • Updated user and developer documentation where needed (not needed)

  • Ran make validate

  • Added a changelog fragment for a behavior change, or explained why none is needed

  • Confirmed new third-party code retains provenance and licensing (no new third-party code)
  • Breaking changes

    None. The handler's own labels and the enforce-scheduler annotation are written exactly as before; only labels it never set are no longer removed.

    Additional notes

    Two new specs in namespace_resource_handler_test.go, next to the existing annotation one: a flipped EnforceKaiScheduler and the adoption of a pre-created namespace, both with a pod-security.kubernetes.io/enforce: restricted label that must survive. Both fail on main.

    Ran locally (Go 1.26.8, macOS arm64): go test ./pkg/project-controller/handlers/... (2 packages pass), golangci-lint run ./pkg/project-controller/... (0 issues). The e2e suite was not run.

    Diff: 59 lines (+59 / -0) across 3 files Reviewer: noiyemini Review duration: 11166m
    All Vouch review confidence checks passed
    Residual risk 0.05 = Change Risk (0.30) × (1 − Review Confidence (0.85)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.30 · 59 lines diff across 3 files
    0.30
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.80 · 4 substantive comment(s)
    0.80
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    85%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.245
    Real PR Conversation Timeline
    9 items
    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Oct 26, 2026 13:58 UTC
    Reviewer

    Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

    noiyemini noiyemini commented on code on Nov 01, 2026 09:17 UTC
    Code Review
    .changes/unreleased/fixed-20261026-142318.yaml:1

    Could you add Issue and Author to the changelog fragment so you're credited in the release notes?

    blacksoxx blacksoxx commented on code on Nov 02, 2026 09:24 UTC
    Code Review
    .changes/unreleased/fixed-20261026-142318.yaml:1

    Thanks @noiyemini, and for reproducing both cases on a live cluster. Added in 7a2d963.

    github-actions[bot] github-actions[bot] commented on Nov 02, 2026 10:54 UTC
    Bot

    <!-- code-coverage-report-comment -->
    Total coverage: 81.4% -> 81.4% (delta 0.00%)

    Merging this branch changes the coverage (1 decrease, 1 increase)

    | Impacted Packages | Coverage Δ | :robot: |
    |-------------------|------------|---------|
    | github.com/kai-scheduler/kai-resource-management/pkg/project-controller/handlers | 80.51% (+0.10%) | :thumbsup: |
    | github.com/kai-scheduler/kai-resource-management/pkg/project-controller/webhooks/validation | 95.24% (-0.22%) | :thumbsdown: |

    <details>

    <summary>Coverage details</summary>

    <sub>Compared to commit d83a53c (run #40174683562)</sub>

    | Changed File | Coverage Δ | Total | Covered | Missed | :robot: |
    |--------------|------------|-------|---------|--------|---------|
    | github.com/kai-scheduler/kai-resource-management/pkg/project-controller/handlers/namespace_resource_handler.go | 82.76% (+0.83%) | 87 (+4) | 72 (+4) | 15 | :thumbsup: |

    _Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code._

    Changed unit test files:

  • github.com/kai-scheduler/kai-resource-management/pkg/project-controller/handlers/handlers_test/namespace_resource_handler_test.go
  • </details>

    noiyemini noiyemini approved these changes on Nov 02, 2026 12:14 UTC
    Approved Reviewer

    Approved these changes.

    SiorMeir SiorMeir approved these changes on Nov 02, 2026 12:40 UTC
    Approved Reviewer

    Approved these changes.

    gshaibi gshaibi approved these changes on Nov 02, 2026 12:47 UTC
    Approved Reviewer

    LGTM. Thanks @blacksoxx

    blacksoxx blacksoxx commented on Nov 03, 2026 09:16 UTC
    Author

    Thanks @noiyemini, @SiorMeir and @gshaibi for the reviews and the merge.

    Reviewers
    Assignees
    blacksoxx blacksoxx
    Labels
    risk: low confidence: 85.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 30.4% (LOW) · Higher = larger blast radius
    30.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 85.2% · Lower = rushed or shallow review
    85.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 4.5% · Safe to merge
    4.5%