-
Notifications
You must be signed in to change notification settings - Fork 11
Handle pod metadata with missing containerStatuses. #49
Conversation
dhrupadb
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 👌
| for (const json::value& c_spec : *container_specs) { | ||
| if (config_.VerboseLogging()) { | ||
| LOG(INFO) << "Container: " << *c_status; | ||
| LOG(INFO) << "Container: " << *c_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.
Assuming the spec has a lot more in it than just the status -- might this make it too chatty?
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 agree with the comment, however, this is only being displayed if verbose logging is enabled, so I'm ok with keeping it.
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.
Heh, the status object isn't that small either. At some point the code logged both, so I figured I was just changing the order, but I guess the logging of the spec got lost.
Just pushed a commit that also logs the status. The config option says "verbose logging", so some chattiness should be expected, and it's helpful in debugging the processing of the incoming JSON.
| result.emplace_back(GetLegacyResource(pod, name)); | ||
| result.emplace_back( | ||
| GetContainerMetadata(pod, container_status, container_spec, | ||
| GetContainerMetadata(pod, container_spec, container_status, |
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.
Nit: generally not sure why you reversed the args here, but whatever the order ends up being, it'd be nice if it lined up with the definitions above. That way the code reads consistently throughout. Either reverse the order of the params, or the order of the definitions.
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 does, though -- container_spec is now declared in the loop header, and container_status is retrieved by name later. What am I missing?
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 didn't zoom out and realize this is being invoked inside of the loop. This looks good now that I better understand.
| continue; | ||
| const json::Object* container_spec = c_spec->As<json::Object>(); | ||
| const std::string name = container_spec->Get<json::String>("name"); | ||
| auto status_it = container_status_by_name.find(name); |
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.
What does "_it" mean here? "is there"?
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.
Short for "iterator". Fairly standard C++ convention.
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.
SG
| for (const json::value& c_spec : *container_specs) { | ||
| if (config_.VerboseLogging()) { | ||
| LOG(INFO) << "Container: " << *c_status; | ||
| LOG(INFO) << "Container: " << *c_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.
I agree with the comment, however, this is only being displayed if verbose logging is enabled, so I'm ok with keeping it.
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.
Forgot to request changes.
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.
PTAL.
| continue; | ||
| const json::Object* container_spec = c_spec->As<json::Object>(); | ||
| const std::string name = container_spec->Get<json::String>("name"); | ||
| auto status_it = container_status_by_name.find(name); |
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.
Short for "iterator". Fairly standard C++ convention.
| result.emplace_back(GetLegacyResource(pod, name)); | ||
| result.emplace_back( | ||
| GetContainerMetadata(pod, container_status, container_spec, | ||
| GetContainerMetadata(pod, container_spec, container_status, |
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 does, though -- container_spec is now declared in the loop header, and container_status is retrieved by name later. What am I missing?
supriyagarg
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
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
| continue; | ||
| const json::Object* container_spec = c_spec->As<json::Object>(); | ||
| const std::string name = container_spec->Get<json::String>("name"); | ||
| auto status_it = container_status_by_name.find(name); |
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.
SG
| result.emplace_back(GetLegacyResource(pod, name)); | ||
| result.emplace_back( | ||
| GetContainerMetadata(pod, container_status, container_spec, | ||
| GetContainerMetadata(pod, container_spec, container_status, |
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 didn't zoom out and realize this is being invoked inside of the loop. This looks good now that I better understand.
Also remove the unused container_id.