Skip to content
This repository was archived by the owner on Aug 19, 2019. It is now read-only.

Conversation

@igorpeshansky
Copy link
Contributor

Fixes a segfault in GetOwner.

Copy link
Contributor

@davidbtucker davidbtucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to add a test for this?

@igorpeshansky
Copy link
Contributor Author

Can't add a test, because it requires being able to mock out a permission error from the API. Do we have that functionality already?

@davidbtucker
Copy link
Contributor

I think once my pending PRs are in, we could add a way for the mock k8s master to return a permission error. Feel free to assign an issue to me to do this.

") disappeared");
}
} catch (const QueryException& e) {
owners_.erase(encoded_ref); // Remove the nullptr entry from owners_.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of erasing the reference on an exception, can we just not add it until we get a success?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way it's implemented now, the lookup in line 936 will construct the entry if it's not present. As I understood it, that's the recommended way to do it in C++ 11. Without that approach, there's no clean way to have a single return from the method.
Tried switching to a lookup followed by an emplace, as you suggested. PTAL.

Copy link
Contributor

@davidbtucker davidbtucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@igorpeshansky igorpeshansky changed the title Remove uninitialized (nullptr) entry from the owners cache on exception. Don't update owners cache until the value is available. Jul 17, 2018
json::value& owner = found.first->second;
if (found.second) { // Not found, inserted new.
auto found = owners_.find(encoded_ref);
if (found == owners_.end()) { // Not found, add new.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the owner is found, let's return the owner right away.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tackled this another way by going back to a single return. PTAL.

@igorpeshansky igorpeshansky removed the request for review from rbuskens July 17, 2018 17:02
Copy link
Contributor

@bmoyles0117 bmoyles0117 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@igorpeshansky igorpeshansky merged commit 617b16c into master Jul 17, 2018
@igorpeshansky igorpeshansky deleted the igorp-remove-stale-owners branch July 17, 2018 19:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants