-
Notifications
You must be signed in to change notification settings - Fork 120
Description
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 refactoringDeprecated 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 availableor
//nolint:staticcheck // SA1019: runtime.Apply will be replaced when ApplyConfiguration support is availableor
//nolint:staticcheck // SA1019: runtime_client.Apply will be replaced when ApplyConfiguration support is availableDesired behavior
All //nolint:staticcheck suppressions should be removed by migrating to the recommended replacement APIs:
-
Zipkin Exporter: Migrate to OTLP exporter as recommended by OpenTelemetry. See OTel deprecation blog post.
-
Event Recorder: Refactor all 4 reconcilers and their tests to use
mgr.GetEventRecorderwith theevents.EventRecorderinterface instead ofrecord.EventRecorder. This affects:- RecipeReconciler
- DeploymentReconciler
- DeploymentTemplateReconciler
- DeploymentResourceReconciler
-
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/zipkinwithgo.opentelemetry.io/otel/exporters/otlp/otlptraceand configure OTLP collector. - Event Recorder: Update all reconcilers to use the new events API. This requires:
- Changing
EventRecorderfield type fromrecord.EventRecordertoevents.EventRecorder - Updating event emission calls (different method signatures)
- Changing
- 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
- Related PR: Bump the go-dependencies group across 1 directory with 16 updates #11156
- controller-runtime v0.23.1 changelog: https://github.com/kubernetes-sigs/controller-runtime/releases
- OpenTelemetry Go v1.40.0 changelog: https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md
Summary of suppressions:
| Category | Count | Files Affected |
|---|---|---|
| Zipkin Exporter | 1 | 1 |
| Event Recorder API | 9 | 6 |
| Server-side Apply | 7 | 7 |
| Total | 17 | 13 |