✨ feat: Implement typed error classification for pod lifecycle events#10
Merged
SebastienLaurent-CF merged 1 commit intomainfrom Nov 23, 2025
Merged
Conversation
Add type-aware error handling to locators for intelligent retry strategies. Instead of treating all errors identically, distinguish between transient errors (retry with backoff) and permanent errors (fail fast). ## Implementation **New Error Package** (internal/locator/errors.go) - ErrorType enum with 10 classified error types: - Transient: NetworkTransient, APITransient, (pod initializing) - Permanent: ResourceNotFound, PodNotRunning, PodFailed, ConfigInvalid, PermissionDenied - Uncertain: NoPodAvailable (might retry longer based on context) - LocateError wrapper with type info + error unwrapping - Helper functions for creating typed errors: NewResourceNotFoundError(), NewPodFailedError(), etc. **Updated Locators** (pod.go, service.go, selector_based_locator.go) - Detect error types using Kubernetes API predicates (IsNotFound, IsTimeout, IsForbidden, etc.) - Return typed LocateError instead of generic fmt.Errorf - Classify API errors (timeout, forbidden, not found) separately from resource state errors - Port mapping errors classified as ConfigInvalid (user configuration issues) **Test Updates** (locator_test.go) - Updated assertions to match new error messages (more specific, less generic) - All 129 tests passing with zero regressions - Error messages now clearly indicate error type: "X not found" vs "X is in failed state" ## Benefits ✅ Enables forwarder to implement intelligent retry strategies per error type ✅ Transient errors: exponential backoff retry ✅ Permanent errors: fail fast or give up after few attempts ✅ Better error messages: developers see what went wrong (config vs API vs resource) ✅ Foundation for improved observability: errors can be classified and monitored
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add type-aware error handling to locators for intelligent retry strategies. Instead of treating all errors identically, distinguish between transient errors (retry with backoff) and permanent errors (fail fast).
Implementation
New Error Package (internal/locator/errors.go)
Updated Locators (pod.go, service.go, selector_based_locator.go)
Test Updates (locator_test.go)
Benefits
✅ Enables forwarder to implement intelligent retry strategies per error type ✅ Transient errors: exponential backoff retry
✅ Permanent errors: fail fast or give up after few attempts ✅ Better error messages: developers see what went wrong (config vs API vs resource) ✅ Foundation for improved observability: errors can be classified and monitored