-
Notifications
You must be signed in to change notification settings - Fork 11
Don't add labels to container metadata if the pod has no labels. #48
Conversation
src/kubernetes.cc
Outdated
try { | ||
labels = metadata->Get<json::Object>("labels"); | ||
} catch (const json::Exception& e) { | ||
labels = new json::Object({}); |
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.
This will leak. Let's instead handle it by not sending the "labels" component at all...
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.
Done.
@@ -263,7 +263,12 @@ MetadataUpdater::ResourceMetadata KubernetesReader::GetContainerMetadata( | |||
const std::string created_str = | |||
metadata->Get<json::String>("creationTimestamp"); | |||
Timestamp created_at = rfc3339::FromString(created_str); | |||
const json::Object* labels = metadata->Get<json::Object>("labels"); |
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.
Might as well also delete this from line 199...
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.
Done.
…as labels. Use a Has test instead of catching the exception.
Your changes 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.
Feels weird approving my own changes, but you've already LGTM'd them.
@@ -263,7 +263,12 @@ MetadataUpdater::ResourceMetadata KubernetesReader::GetContainerMetadata( | |||
const std::string created_str = | |||
metadata->Get<json::String>("creationTimestamp"); | |||
Timestamp created_at = rfc3339::FromString(created_str); | |||
const json::Object* labels = metadata->Get<json::Object>("labels"); |
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.
Done.
src/kubernetes.cc
Outdated
try { | ||
labels = metadata->Get<json::Object>("labels"); | ||
} catch (const json::Exception& e) { | ||
labels = new json::Object({}); |
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.
Done.
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!
No description provided.