You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tpc, err := topic.Get(ctx, c.kafkaClient, meta.GetExternalName(cr))
if tpc == nil {
return managed.ExternalObservation{ResourceExists: false}, nil
}
if err != nil {
return managed.ExternalObservation{}, errors.Wrapf(err, "cannot get topic spec from topic client")
}
topic.Get either returns a topic or an error. In case of errors, the topic will always be nil and the function will return on the first error check. If the topic is not nil err will always be nil, therefore the code in that if block is unreachable.
This code was probably developed because topic.Get() returns an error in both cases when a topic does not exist of when something went wrong, and it is not possible with just the error itself to discern which of the two happened.
As a result, errors from the client performing a Get are interpreted as "Topic does not exist" issuing a topic creation when not necessary
The text was updated successfully, but these errors were encountered:
adarmiento
changed the title
Topic controller Observe function contains unteachable error checks
Topic controller Observe function doesn't distinguish between non-existing topics and errors from the client in retrieving the topic
Nov 3, 2022
From
controller/topic/topic.go
Observe()
function:topic.Get
either returns a topic or an error. In case of errors, the topic will always be nil and the function will return on the first error check. If the topic is not nil err will always be nil, therefore the code in that if block is unreachable.This code was probably developed because
topic.Get()
returns an error in both cases when a topic does not exist of when something went wrong, and it is not possible with just the error itself to discern which of the two happened.As a result, errors from the client performing a Get are interpreted as "Topic does not exist" issuing a topic creation when not necessary
The text was updated successfully, but these errors were encountered: