Skip to content

Remove //nolint:staticcheck suppressions for deprecated APIs introduced in go-dependencies update #11186

@brooke-hamilton

Description

@brooke-hamilton

Engineering Improvement

Area for Improvement

Code linting and static analysis quality. PR #11156 introduced //nolint:staticcheck suppressions to bypass deprecation (SA1019) warnings for deprecated Go APIs. These suppressions need to be removed by refactoring to use the recommended replacement APIs.

Observed behavior

The following deprecated API usages are currently suppressed in the codebase (17 total suppressions across 13 files):


1. Zipkin Exporter Deprecation (1 occurrence)

File Line Suppressed API
pkg/components/trace/traceservice/service.go import go.opentelemetry.io/otel/exporters/zipkin

Suppression:

//nolint:staticcheck // SA1019: Zipkin exporter is deprecated but still functional. Will migrate to OTLP in future.

2. Event Recorder API Deprecation (9 occurrences)

File Context
pkg/controller/service.go RecipeReconciler setup
pkg/controller/service.go DeploymentReconciler setup
pkg/controller/service.go DeploymentTemplateReconciler setup
pkg/controller/service.go DeploymentResourceReconciler setup
pkg/controller/reconciler/deployment_reconciler_test.go SetupDeploymentTest
pkg/controller/reconciler/deploymentresource_reconciler_test.go SetupDeploymentResourceTest
pkg/controller/reconciler/deploymenttemplate_reconciler_test.go DeploymentTemplateReconciler setup
pkg/controller/reconciler/deploymenttemplate_reconciler_test.go DeploymentResourceReconciler setup
pkg/controller/reconciler/recipe_reconciler_test.go SetupRecipeTest
pkg/controller/reconciler/recipe_webhook_test.go setupWebhookTest

Suppression:

//nolint:staticcheck // SA1019: GetEventRecorderFor is deprecated but migration to new events API requires significant refactoring

Deprecated API: mgr.GetEventRecorderFor (deprecated in favor of mgr.GetEventRecorder which uses the new events.EventRecorder interface)


3. Server-side Apply Patch Type Deprecation (7 occurrences)

File Suppressed API
pkg/corerp/handlers/kubernetes.go client.Apply
pkg/daprrp/processors/configurationstores/processor.go runtime.Apply
pkg/daprrp/processors/pubsubbrokers/processor.go runtime_client.Apply
pkg/daprrp/processors/secretstores/processor.go runtime_client.Apply
pkg/daprrp/processors/statestores/processor.go runtime_client.Apply
pkg/kubeutil/namespace.go runtime_client.Apply
test/k8sutil/fake.go client.Apply

Suppression:

//nolint:staticcheck // SA1019: client.Apply will be replaced when ApplyConfiguration support is available

or

//nolint:staticcheck // SA1019: runtime.Apply will be replaced when ApplyConfiguration support is available

or

//nolint:staticcheck // SA1019: runtime_client.Apply will be replaced when ApplyConfiguration support is available

Desired behavior

All //nolint:staticcheck suppressions should be removed by migrating to the recommended replacement APIs:

  1. Zipkin Exporter: Migrate to OTLP exporter as recommended by OpenTelemetry. See OTel deprecation blog post.

  2. Event Recorder: Refactor all 4 reconcilers and their tests to use mgr.GetEventRecorder with the events.EventRecorder interface instead of record.EventRecorder. This affects:

    • RecipeReconciler
    • DeploymentReconciler
    • DeploymentTemplateReconciler
    • DeploymentResourceReconciler
  3. Server-side Apply: Refactor to use the new strongly-typed client.Client.Apply() API with ApplyConfiguration objects. For unstructured/dynamic resources, evaluate the latest Kubernetes/client-go recommendations.

Proposed Fix

  • Zipkin: Replace go.opentelemetry.io/otel/exporters/zipkin with go.opentelemetry.io/otel/exporters/otlp/otlptrace and configure OTLP collector.
  • Event Recorder: Update all reconcilers to use the new events API. This requires:
    • Changing EventRecorder field type from record.EventRecorder to events.EventRecorder
    • Updating event emission calls (different method signatures)
  • Server-side Apply: Generate or use ApplyConfiguration types for the resources being patched, or adopt alternative patterns for dynamic resources.

System information

rad Version

N/A - this is a code quality improvement

Operating system

N/A

Additional context

Summary of suppressions:

Category Count Files Affected
Zipkin Exporter 1 1
Event Recorder API 9 6
Server-side Apply 7 7
Total 17 13

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintenanceIssue is a non-user-facing task like updating tests, improving automation, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions