Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic controller Observe function doesn't distinguish between non-existing topics and errors from the client in retrieving the topic #46

Open
adarmiento opened this issue Nov 3, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@adarmiento
Copy link
Contributor

adarmiento commented Nov 3, 2022

From controller/topic/topic.go Observe() function:

	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

@adarmiento adarmiento added the bug Something isn't working label Nov 3, 2022
@adarmiento 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant