This repository was archived by the owner on Aug 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
A set of refactorings to enable Kubernetes watch. #44
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4bec5c7
New DockerUpdater and KubernetesUpdater classes. Swap order of Pollin…
igorpeshansky 157d9f4
Factor out the MetadataUpdater abstract class.
igorpeshansky 00a9141
Split MetadataAgent::UpdateResource into UpdateResource and UpdateMet…
igorpeshansky 6118758
Factor out metadata creation.
igorpeshansky 6e91a2d
Factor out GetPodAndContainerMetadata; add a move constructor to Reso…
igorpeshansky a3258f5
Rename local variable.
igorpeshansky 38d3db0
Address feedback.
igorpeshansky d623dcb
Rename variable.
igorpeshansky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,12 +81,15 @@ class MetadataAgent { | |
| MetadataAgent(const MetadataAgentConfiguration& config); | ||
| ~MetadataAgent(); | ||
|
|
||
| // Updates metadata for a given resource. | ||
| // Updates the local resource map entry for a given resource. | ||
| // Each local id in `resource_ids` is effectively an alias for `resource`. | ||
| // Adds a resource mapping from each of the `resource_ids` to the `resource` | ||
| // and a metadata mapping from the `resource` to the metadata `entry`. | ||
| // Adds a resource mapping from each of the `resource_ids` to the `resource`. | ||
| void UpdateResource(const std::vector<std::string>& resource_ids, | ||
| const MonitoredResource& resource, | ||
| const MonitoredResource& resource); | ||
|
|
||
| // Updates metadata for a given resource. | ||
| // Adds a metadata mapping from the `resource` to the metadata `entry`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does "metadata mapping" mean. Is just "mapping" sufficient?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The metadata agent maintains two mappings:
|
||
| void UpdateMetadata(const MonitoredResource& resource, | ||
| Metadata&& entry); | ||
|
|
||
| // Starts serving. | ||
|
|
@@ -104,10 +107,12 @@ class MetadataAgent { | |
|
|
||
| const MetadataAgentConfiguration& config_; | ||
|
|
||
| // A lock that guards access to the maps. | ||
| mutable std::mutex mu_; | ||
| // A lock that guards access to the local resource map. | ||
| mutable std::mutex resource_mu_; | ||
| // A map from a locally unique id to MonitoredResource. | ||
| std::map<std::string, MonitoredResource> resource_map_; | ||
| // A lock that guards access to the metadata map. | ||
| mutable std::mutex metadata_mu_; | ||
| // A map from MonitoredResource to (JSON) resource metadata. | ||
| std::map<MonitoredResource, Metadata> metadata_map_; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just curious, why is this second map not keyed by
resource_idas 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.
Because that map is sent to to the Resource Metadata API, which neither knows nor cares about the local resource ids.
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, got it. Makes sense.
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.
Curious - how is the local resource_id different from the monitored resource ID?
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 local resource_id is an easily discoverable identifier for the resource that is unique within the current context (e.g., a Kubernetes node), but may not be globally unique, whereas the monitored resource (which actually is an id, so "monitored resource id" is redundant) is globally unique.