← Back to Pull requests

cleanup: remove use of deprecated Go APIs #4791

Open
unknown opened this pull request with 424 lines diff across 5 files
View on GitHub
unknown unknown commented on Oct 19, 2026 18:01 UTC
Author

What type of PR is this?

/kind cleanup

What this PR does / Why we need it:

Removes our use of deprecated Go APIs.

staticcheck's SA1019, which reports deprecated APIs, was already enabled through checks: [all] in .golangci.yml. //nolint:staticcheck directives hid some deprecated calls, and SA1019 missed others entirely. Upstream doc comments that put Deprecated: on the line right after the summary, instead of in its own paragraph, aren't recognised as deprecations, so SA1019 can't see them. This PR:

  • Replaces deprecated calls:

  • - grpc.DialContext + WithBlock → grpc.NewClient, plus a wait-for-ready loop in the Go SDK. NewSDK still blocks until connected and still times out after 30s.
    - workqueue.NewNamedRateLimitingQueue → NewTypedRateLimitingQueueWithConfig
    - intstr.FromInt → FromInt32
    - field.TooLongMaxLength → field.TooLong
    - integer.IntMin → the min builtin
    - intstr.GetValueFromIntOrPercent → GetScaledValueFromIntOrPercent (see the breaking change below)
  • Gives each remaining intentional use of a deprecated field a // SA1019: <reason> explanation. These are the backward-compatible Required/Preferred allocation fields.

  • Fixes a defer reader.Close() in localsdk.go that ran before the os.Open error check (SA5001). A staticcheck suppression on that line was hiding it.

  • Notes in .golangci.yml that all already includes SA1019.
  • Which issue(s) this PR fixes:

    N/A

    Did you use AI tools in preparing this PR?:

    Y

    Special notes for your reviewer:

    :warning: Breaking change: Fleet maxSurge / maxUnavailable percentages now require a trailing %.

    Fleet spec.strategy.rollingUpdate.maxSurge and maxUnavailable used to be parsed with the deprecated intstr.GetValueFromIntOrPercent. That function reads any string as a percentage, so maxSurge: "25" was silently treated as 25%. These fields now use intstr.GetScaledValueFromIntOrPercent, which rejects a numeric string without a trailing %.

  • This is how Kubernetes handles the same fields. Deployments reject "25" for maxSurge/maxUnavailable. Fleet's strategy is appsv1.DeploymentStrategy, and its API reference already describes the value as "an absolute number (ex: 5) or a percentage of desired pods (ex: 10%)".

  • The %-less form was never documented. Every example and reference under site/ uses 25%.

  • FleetAutoscaler bufferSize already works this way. Its validation has used GetScaledValueFromIntOrPercent for some time.

  • Upgrade impact: a Fleet created or updated after upgrading is rejected at validation if it uses "25". A Fleet already stored* with "25" isn't re-validated, so its rolling updates will fail in the Fleet controller with an "error parsing MaxSurge/MaxUnavailable value" error until the value is changed to "25%". This needs to be in the release notes.
  • Other notes:

  • The Go SDK change uses ClientConn.Connect(), which grpc-go marks experimental but documents as the replacement for WithBlock. NewClient also uses the dns resolver by default, where DialContext used passthrough.

  • examples/allocation-endpoint/server still uses grpc.DialContext. The examples are separate Go modules that golangci-lint run ./examples/... doesn't actually lint, and changing one means bumping its image version, so it's left for a follow-up.
  • Diff: 424 lines (+318 / -106) across 5 files Reviewer: markmandel Review duration: 4012m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 424 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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.362
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #4791"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 45.1% (MEDIUM) · Higher = larger blast radius
    45.1%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 24% · Safe to merge
    24%