-
Notifications
You must be signed in to change notification settings - Fork 11
Fix container spec/status order mismatch. #47
Conversation
…er, look up containers by name, rather than by index.
bmoyles0117
left a comment
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 🦑 Only one minor comment.
src/kubernetes.cc
Outdated
| result.emplace_back(GetLegacyResource(pod, name)); | ||
| result.emplace_back( | ||
| GetContainerMetadata(pod, i, associations->Clone(), collected_at)); | ||
| GetContainerMetadata(pod, container, container_spec, |
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.
Can we use container_status instead of container?
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.
+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.
Done.
qingling128
left a comment
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.
src/kubernetes.cc
Outdated
| result.emplace_back(GetLegacyResource(pod, name)); | ||
| result.emplace_back( | ||
| GetContainerMetadata(pod, i, associations->Clone(), collected_at)); | ||
| GetContainerMetadata(pod, container, container_spec, |
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.
+1
src/kubernetes.h
Outdated
| @@ -89,12 +89,13 @@ class KubernetesReader { | |||
| const throw(json::Exception); | |||
| // Given a pod object and container index, return the container metadata. | |||
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.
Please update the comment here. There is no more container index being passed in.
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.
Good catch. Done.
| const json::Object* container_spec, json::value associations, | ||
| Timestamp collected_at) const throw(json::Exception); | ||
| // Given a pod object and container index, return the legacy resource. | ||
| // The returned "metadata" field will be Metadata::IGNORED. |
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.
ditto
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.
| const std::string container_id = | ||
| container->Get<json::String>("containerID").substr( | ||
| docker_prefix_end); | ||
| const std::string container_id = docker_id.substr(docker_prefix_end); |
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.
the container ID is not used 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.
It's used in line 318 (hidden by the diff).
| {"status", json::object({ | ||
| {"version", json::string(kKubernetesApiVersion)}, | ||
| {"raw", container->Clone()}, | ||
| {"raw", container_status->Clone()}, |
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 not add the spec to the "raw" metadata as well?
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.
It is, the lines are right above hidden in the diff.
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.
ah, thanks Brian.
- Rename variable. - Update method comments.
igorpeshansky
left a comment
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.
Addressed feedback. PTAL.
| const std::string container_id = | ||
| container->Get<json::String>("containerID").substr( | ||
| docker_prefix_end); | ||
| const std::string container_id = docker_id.substr(docker_prefix_end); |
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.
It's used in line 318 (hidden by the diff).
src/kubernetes.cc
Outdated
| result.emplace_back(GetLegacyResource(pod, name)); | ||
| result.emplace_back( | ||
| GetContainerMetadata(pod, i, associations->Clone(), collected_at)); | ||
| GetContainerMetadata(pod, container, container_spec, |
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.h
Outdated
| @@ -89,12 +89,13 @@ class KubernetesReader { | |||
| const throw(json::Exception); | |||
| // Given a pod object and container index, return the container metadata. | |||
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.
Good catch. Done.
| const json::Object* container_spec, json::value associations, | ||
| Timestamp collected_at) const throw(json::Exception); | ||
| // Given a pod object and container index, return the legacy resource. | ||
| // The returned "metadata" field will be Metadata::IGNORED. |
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.
No description provided.