-
Notifications
You must be signed in to change notification settings - Fork 11
Add implicit instance resource mapping. #55
Conversation
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.
Looks reasonable, however, I'm confused by the merging of technical debt fixes with the overall goal of the PR.
src/configuration.cc
Outdated
| 8*1024*1024; | ||
| constexpr const char kMetadataIngestionDefaultRawContentVersion[] = "0.1"; | ||
| constexpr const int kInstanceUpdaterDefaultIntervalSeconds = 60*60; | ||
| constexpr const char kDefaultInstanceResourceType[] = ""; |
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 this be blank?
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.
Blank means "get it from the environment".
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 added a comment to that effect.
| "/resourceMetadata:batchUpdate"; | ||
| constexpr const int kMetadataIngestionDefaultRequestSizeLimitBytes = | ||
| 8*1024*1024; | ||
| constexpr const char kMetadataIngestionDefaultRawContentVersion[] = "0.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.
This was previously only used for Kubernetes, is it reasonable to say that the agent will evolve all resources linearly with a single version? Is it possible for the raw content to change over time at different rates over different resource types? I'm not sure how this contract works with the API.
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, this is the version of the envelope schema for the metadata ingestion API. The next PR will use it for Docker container resources as well.
src/docker.cc
Outdated
| }); | ||
|
|
||
| const json::Object* container_desc = parsed_metadata->As<json::Object>(); | ||
| const json::Object* container_desc = raw_docker->As<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.
I'm not sure why these changes are being bundled in here. This looks like a separate PR.
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, this is basically drive-by cleanup. I'm happy to move these into the next PR that deals specifically with Docker.
Done.
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.
Thanks for the review. PTAL.
src/configuration.cc
Outdated
| 8*1024*1024; | ||
| constexpr const char kMetadataIngestionDefaultRawContentVersion[] = "0.1"; | ||
| constexpr const int kInstanceUpdaterDefaultIntervalSeconds = 60*60; | ||
| constexpr const char kDefaultInstanceResourceType[] = ""; |
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.
Blank means "get it from the environment".
| "/resourceMetadata:batchUpdate"; | ||
| constexpr const int kMetadataIngestionDefaultRequestSizeLimitBytes = | ||
| 8*1024*1024; | ||
| constexpr const char kMetadataIngestionDefaultRawContentVersion[] = "0.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.
Yes, this is the version of the envelope schema for the metadata ingestion API. The next PR will use it for Docker container resources as well.
src/docker.cc
Outdated
| }); | ||
|
|
||
| const json::Object* container_desc = parsed_metadata->As<json::Object>(); | ||
| const json::Object* container_desc = raw_docker->As<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.
Yes, this is basically drive-by cleanup. I'm happy to move these into the next PR that deals specifically with Docker.
Done.
src/instance.cc
Outdated
| @@ -0,0 +1,63 @@ | |||
| /* | |||
| * Copyright 2017 Google Inc. | |||
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.
2018?
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, yes, time flies... 😄 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.
🤣
| constexpr const int kMetadataIngestionDefaultRequestSizeLimitBytes = | ||
| 8*1024*1024; | ||
| constexpr const char kMetadataIngestionDefaultRawContentVersion[] = "0.1"; | ||
| constexpr const int kInstanceUpdaterDefaultIntervalSeconds = 60*60; |
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.
An interval of 1 hour? Because GCE instance don't get updated often?
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.
Correct. Actually, the bits we care about (the resource id) never change. I thought of actually making it 24 hours, or even larger, because we really only need the initial load on startup. Finally settled on 1 hour, for no good reason.
If we choose to actually send mutable instance metadata, including tags, etc, we would poll this more often (e.g., once a minute), just like any other resource.
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.
Makes sense. Thanks for the clarification.
| } else { | ||
| // Default to a GCE instance. | ||
| // TODO: Detect other resources. | ||
| instance_resource_type_ = kGceInstanceResourceType; |
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.
A question not directly related to this PR:
For other resources to be detected, is k8s_node one of them, assuming the metadata agent runs on the same node?
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.
No, this is the underlying instance resource. "Other resources" in this case would be "aws_ec2_instance", for example. Adjusted the comment to make this clearer.
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, right. Thanks for adding the comment!
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.
Thanks, PTAL.
| } else { | ||
| // Default to a GCE instance. | ||
| // TODO: Detect other resources. | ||
| instance_resource_type_ = kGceInstanceResourceType; |
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.
No, this is the underlying instance resource. "Other resources" in this case would be "aws_ec2_instance", for example. Adjusted the comment to make this clearer.
src/instance.cc
Outdated
| @@ -0,0 +1,63 @@ | |||
| /* | |||
| * Copyright 2017 Google Inc. | |||
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, yes, time flies... 😄 Done.
| constexpr const int kMetadataIngestionDefaultRequestSizeLimitBytes = | ||
| 8*1024*1024; | ||
| constexpr const char kMetadataIngestionDefaultRawContentVersion[] = "0.1"; | ||
| constexpr const int kInstanceUpdaterDefaultIntervalSeconds = 60*60; |
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.
Correct. Actually, the bits we care about (the resource id) never change. I thought of actually making it 24 hours, or even larger, because we really only need the initial load on startup. Finally settled on 1 hour, for no good reason.
If we choose to actually send mutable instance metadata, including tags, etc, we would poll this more often (e.g., once a minute), just like any other resource.
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
| #ifndef INSTANCE_H_ | ||
| #define INSTANCE_H_ | ||
|
|
||
| //#include "config.h" |
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: Remove if unnecessary.
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.
This is the pattern in all other files, just to allow using autotools later. I'd like to keep it consistent.
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.
| constexpr const int kMetadataIngestionDefaultRequestSizeLimitBytes = | ||
| 8*1024*1024; | ||
| constexpr const char kMetadataIngestionDefaultRawContentVersion[] = "0.1"; | ||
| constexpr const int kInstanceUpdaterDefaultIntervalSeconds = 60*60; |
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.
Makes sense. Thanks for the clarification.
| } else { | ||
| // Default to a GCE instance. | ||
| // TODO: Detect other resources. | ||
| instance_resource_type_ = kGceInstanceResourceType; |
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, right. Thanks for adding the comment!
src/instance.cc
Outdated
| @@ -0,0 +1,63 @@ | |||
| /* | |||
| * Copyright 2017 Google Inc. | |||
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.
🤣
| #ifndef INSTANCE_H_ | ||
| #define INSTANCE_H_ | ||
|
|
||
| //#include "config.h" |
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
| } else { | ||
| // Default to a GCE instance. | ||
| // TODO: Detect other instance resources. | ||
| instance_resource_type_ = kGceInstanceResourceType; |
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.
Is there a reason that config_.InstanceResourceType cannot default to "gce_instance"?
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 current default (empty value) means "detect via the environment". I've added a comment in configuration.cc to that effect.
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.
Thanks, PTAL.
src/configuration.cc
Outdated
| 8*1024*1024; | ||
| constexpr const char kMetadataIngestionDefaultRawContentVersion[] = "0.1"; | ||
| constexpr const int kInstanceUpdaterDefaultIntervalSeconds = 60*60; | ||
| constexpr const char kDefaultInstanceResourceType[] = ""; |
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 added a comment to that effect.
| } else { | ||
| // Default to a GCE instance. | ||
| // TODO: Detect other instance resources. | ||
| instance_resource_type_ = kGceInstanceResourceType; |
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 current default (empty value) means "detect via the environment". I've added a comment in configuration.cc to that effect.
| #ifndef INSTANCE_H_ | ||
| #define INSTANCE_H_ | ||
|
|
||
| //#include "config.h" |
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 is the pattern in all other files, just to allow using autotools later. I'd like to keep it consistent.
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
…Version into configuration options.
5a9e66c to
c1fa702
Compare
|
Rebased off |
Also factor out an InstanceUpdater that polls the instance resource and add more configuration options.