ipam: Return error from instance (re)sync instead of sentinel time.Time#45153
Open
HadrienPatte wants to merge 1 commit intomainfrom
Open
ipam: Return error from instance (re)sync instead of sentinel time.Time#45153HadrienPatte wants to merge 1 commit intomainfrom
HadrienPatte wants to merge 1 commit intomainfrom
Conversation
The `AllocationImplementation` interface used `time.Time{}` as a sentinel
value to signal failure from `Resync` and `InstanceSync`, forcing every
caller to decode the convention via `.IsZero()` and discarding error
context at the interface boundary.
This PR changes both methods signature to return `(time.Time, error)`,
and propagate errors to callers, this avoids the previous situations
where in case of sync failure, we'd get one warning log from the sync
method with the actual low level error and then a fatal log from the
higher level calling code but without the context of the lower error.
Now that the error is properly forwarded up the call chain, we get a
single log with all the appropriate context.
Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
1743f85 to
0f35b36
Compare
Member
Author
|
/test |
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.
The
AllocationImplementationinterface usedtime.Time{}as a sentinel value to signal failure fromResyncandInstanceSync, forcing every caller to decode the convention via.IsZero()and discarding error context at the interface boundary.This PR changes both methods signature to return
(time.Time, error), and propagate errors to callers, this avoids the previous situations where in case of sync failure, we'd get one warning log from the sync method with the actual low level error and then a fatal log from the higher level calling code but without the context of the lower error.Now that the error is properly forwarded up the call chain, we get a single log with all the appropriate context.
See what the double logs look like currently without this patch:
