← Back to Pull requests

Sanitize metadata.labels in direct controllers via label.GCPLabels #15528

Closed
unknown closed this pull request without merging on Nov 18, 2026 22:35 UTC
View on GitHub
unknown unknown commented on Nov 13, 2026 00:15 UTC
Author

Several direct controllers copied raw Kubernetes metadata.labels (GetLabels()) or manual map entries directly into GCP resource protobuf messages without sanitization. When GitOps tools such as Config Sync, Helm, or ArgoCD inject standard Kubernetes labels containing . or / (e.g. app.kubernetes.io/managed-by), GCP APIs reject Create and Update requests with HTTP 400.

This PR standardizes label handling across affected direct controllers using the canonical label.GCPLabels(obj) helper, which strips KRM-prefixed keys and applies managed-by-cnrm: "true".

Key Changes


  • Updated direct controllers to use label.GCPLabels(obj):

  • - NetworkSecurityAuthzPolicy (pkg/controller/direct/networksecurity)
    - NetworkServicesServiceBinding (pkg/controller/direct/networkservices)
    - ConfigDeliveryResourceBundle (pkg/controller/direct/configdelivery)
    - DataprocBatch (pkg/controller/direct/dataproc)
    - DataprocSession (pkg/controller/direct/dataproc)
    - DataprocSessionTemplate (pkg/controller/direct/dataproc/dataprocsessiontemplate)
    - WorkflowsExecution (pkg/controller/direct/workflowexecutions)
    - DataprocCluster (pkg/controller/direct/dataproc)
    - ConfigDeliveryFleetPackage (pkg/controller/direct/configdelivery/configdeliveryfleetpackage)
  • In CloudDeployDeployPolicy (pkg/controller/direct/clouddeploy/clouddeploydeploypolicy), sanitized labels via label.GCPLabels(u), populated desiredPb.Labels, and preserved GCP system labels (goog-, go-) during Update.

  • Added unit test cases verifying that KRM-prefixed labels are removed while user-defined labels and managed-by-cnrm are preserved.

  • Verified all mock GCP E2E test fixtures pass for all affected controllers.
  • Fixes #15439

    ``release-note
    Sanitize metadata.labels in direct controllers via label.GCPLabels to strip Kubernetes-specific label keys and prevent API rejection.
    ``

    This pull request was generated by an AI coding agent.

    <sub>🤖 Agent session</sub>

    <!-- factory:task-output kind=Change task=recipe-fix-20261112-220622-7b1f -->

    Diff: 277 lines (+207 / -70) across 3 files Reviewer: anhdle-sso Review duration: 8540m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 277 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    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.337
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #15528"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 39.6% (MEDIUM) · Higher = larger blast radius
    39.6%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 17.1% · Safe to merge
    17.1%