Skip to content
This repository was archived by the owner on Aug 19, 2019. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/kubernetes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1049,9 +1049,13 @@ void KubernetesReader::PodCallback(
MetadataUpdater::UpdateCallback callback,
const json::Object* pod, Timestamp collected_at, bool is_deleted) const
throw(json::Exception) {
Copy link
Contributor

@supriyagarg supriyagarg Mar 13, 2018

Choose a reason for hiding this comment

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

update the method signature - since the exception is being caught and logged, the throw(..) can be dropped.

std::vector<MetadataUpdater::ResourceMetadata> result_vector =
GetPodAndContainerMetadata(pod, collected_at, is_deleted);
callback(std::move(result_vector));
try {
std::vector<MetadataUpdater::ResourceMetadata> result_vector =
GetPodAndContainerMetadata(pod, collected_at, is_deleted);
callback(std::move(result_vector));
} catch (const json::Exception& e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is the right fix for the situation -- this will simply ignore a JSON error. The assumption here is that if we got an invalid hunk of JSON, the rest of the hunks will also be garbage, so we shouldn't bother with the current connection -- it's better to re-establish the watch.

LOG(ERROR) << e.what();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

A couple of questions:

  1. Why is the error not being caught + logged by the try-catch block around the Watchmaster (L1077)?
  2. For parity, please add a try-catch block in the NodeCallback too

Copy link
Contributor

Choose a reason for hiding this comment

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

+1. This should have been logged in WatchMaster. I think the issue here is that the thread dies, but the right fix is to restart the watch, not to swallow the error.

}

void KubernetesReader::WatchPods(MetadataUpdater::UpdateCallback callback)
Expand Down