[WIP] improve: various simplifications - #3542
Closed
csviri wants to merge 1 commit into
Closed
Conversation
Quality-only cleanup, no behavior changes. Reuse: - PrimaryUpdateAndCacheUtils#compareResourceVersions duplicated the whole algorithm of ReconcilerUtilsInternal#validateAndCompareResourceVersions (including validateResourceVersion) with no production caller; delegate instead so the resource-version semantics live in one place. - addFinalizerWithSSA builds its bare SSA skeleton with HasMetadata#initNameAndNamespaceFrom, as ResourceOperations already does. - AbstractInformerPool formats informer identifiers via ReconcilerUtilsInternal#getResourceTypeNameWithVersion. - EventFilterWindow uses ExtendedResourceEvent#getResourceVersion. - Mappers#fromOwnerType uses ResourceID#fromOwnerReference, like its sibling fromOwnerReferences. - LocallyRunOperatorExtension instantiates reconcilers with Utils#instantiate. Efficiency: - Mappers#fromMetadata hoists the invariant GroupVersionKind out of the per-event lambda and compares the encoded string before parsing. - SecondaryToPrimaryFromDefaultAnnotation holds one delegate mapper instead of building a new one on every event. - AbstractWorkflowExecutor sizes its result map from Workflow#size instead of building a throwaway map of all dependents per reconciliation. - GenericKubernetesResourceMatcher hoists the path-prefix lists to constants and drops the stream in nodeIsChildOf; both ran per JSON-diff node. - ExternalResourceCachingEventSource and PerResourcePollingEventSource drop a duplicate cache lookup and a duplicate ResourceID.fromResource. - InformerEventSource#start only walks the informer cache when the primary-to-secondary index is not the no-op implementation. Altitude: - Move getKubernetesClient to Informable so InformerManager resolves the target client polymorphically instead of downcasting to InformerEventSourceConfiguration. - ResourceState keeps triggerOnAllEvents as a final field set once by ResourceStateManager, rather than receiving the same constant from every caller; the state machine's legal transitions are now readable on their own. - Drop the unused Options parameter threaded into desiredForJsonPatch. - Extract the volume-claim-template sanitization out of sanitizeState.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Quality-only cleanup, no behavior changes.
Reuse:
algorithm of ReconcilerUtilsInternal#validateAndCompareResourceVersions
(including validateResourceVersion) with no production caller; delegate
instead so the resource-version semantics live in one place.
HasMetadata#initNameAndNamespaceFrom, as ResourceOperations already does.
ReconcilerUtilsInternal#getResourceTypeNameWithVersion.
fromOwnerReferences.
Efficiency:
per-event lambda and compares the encoded string before parsing.
building a new one on every event.
building a throwaway map of all dependents per reconciliation.
and drops the stream in nodeIsChildOf; both ran per JSON-diff node.
duplicate cache lookup and a duplicate ResourceID.fromResource.
primary-to-secondary index is not the no-op implementation.
Altitude:
target client polymorphically instead of downcasting to
InformerEventSourceConfiguration.
ResourceStateManager, rather than receiving the same constant from every
caller; the state machine's legal transitions are now readable on their own.