-
Notifications
You must be signed in to change notification settings - Fork 11
Handle deletion events from watch and purge deleted entries. #62
Conversation
@@ -33,6 +33,7 @@ constexpr const int kMetadataApiDefaultNumThreads = 3; | |||
constexpr const int kMetadataApiDefaultPort = 8000; | |||
constexpr const char kMetadataApiDefaultResourceTypeSeparator[] = "."; | |||
constexpr const int kMetadataReporterDefaultIntervalSeconds = 60; | |||
constexpr const int kMetadataReporterDefaultPurgeDeleted = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be defaulting to true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather put this through a few more tests. It can be overridden in the config map if necessary.
@@ -322,7 +316,7 @@ MetadataUpdater::ResourceMetadata KubernetesReader::GetContainerMetadata( | |||
k8s_container_name, | |||
}; | |||
|
|||
if (container_status) { | |||
if (container_status && container_status->Has("containerID")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this added? Do we directly depend on this property anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, right below. The deletion events apparently had a status without a container id.
@@ -737,8 +754,8 @@ void KubernetesReader::WatchMaster( | |||
// A notification for watch completion. | |||
std::mutex completion_mutex; | |||
std::unique_lock<std::mutex> watch_completion(completion_mutex); | |||
Watcher watcher(callback, std::move(watch_completion), | |||
config_.VerboseLogging()); | |||
Watcher watcher(std::bind(&EventCallback, callback, std::placeholders::_1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::placeholders::_N
leaves me a bit puzzled. Is there a way of doing these methods without using unbound arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They confuse me too. Unfortunately, there is no better way.
If it helps, think about std::bind
as: you have to list all of the arguments to the bound function, but some of those can represent the arguments to the function being called -- that's what placeholders are (std::placeholders::_1
is the first argument to the resulting function).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. PTAL.
@@ -33,6 +33,7 @@ constexpr const int kMetadataApiDefaultNumThreads = 3; | |||
constexpr const int kMetadataApiDefaultPort = 8000; | |||
constexpr const char kMetadataApiDefaultResourceTypeSeparator[] = "."; | |||
constexpr const int kMetadataReporterDefaultIntervalSeconds = 60; | |||
constexpr const int kMetadataReporterDefaultPurgeDeleted = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather put this through a few more tests. It can be overridden in the config map if necessary.
@@ -322,7 +316,7 @@ MetadataUpdater::ResourceMetadata KubernetesReader::GetContainerMetadata( | |||
k8s_container_name, | |||
}; | |||
|
|||
if (container_status) { | |||
if (container_status && container_status->Has("containerID")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, right below. The deletion events apparently had a status without a container id.
@@ -737,8 +754,8 @@ void KubernetesReader::WatchMaster( | |||
// A notification for watch completion. | |||
std::mutex completion_mutex; | |||
std::unique_lock<std::mutex> watch_completion(completion_mutex); | |||
Watcher watcher(callback, std::move(watch_completion), | |||
config_.VerboseLogging()); | |||
Watcher watcher(std::bind(&EventCallback, callback, std::placeholders::_1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They confuse me too. Unfortunately, there is no better way.
If it helps, think about std::bind
as: you have to list all of the arguments to the bound function, but some of those can represent the arguments to the function being called -- that's what placeholders are (std::placeholders::_1
is the first argument to the resulting function).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
4d3eadd
to
9c46711
Compare
Rebased off |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Also a minor refactoring of the watch code.