Add implicit instance resource mapping.#55
Conversation
bmoyles0117
left a comment
There was a problem hiding this comment.
Looks reasonable, however, I'm confused by the merging of technical debt fixes with the overall goal of the PR.
| 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.
Blank means "get it from the environment".
There was a problem hiding this comment.
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.
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.
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.
| }); | ||
|
|
||
| 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.
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.
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.
Thanks for the review. PTAL.
| 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.
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.
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.
| }); | ||
|
|
||
| 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.
Yes, this is basically drive-by cleanup. I'm happy to move these into the next PR that deals specifically with Docker.
Done.
| @@ -0,0 +1,63 @@ | |||
| /* | |||
| * Copyright 2017 Google Inc. | |||
There was a problem hiding this comment.
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.
An interval of 1 hour? Because GCE instance don't get updated often?
There was a problem hiding this comment.
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.
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.
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.
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.
Ah, right. Thanks for adding the comment!
igorpeshansky
left a comment
There was a problem hiding this comment.
Thanks, PTAL.
| } else { | ||
| // Default to a GCE instance. | ||
| // TODO: Detect other resources. | ||
| instance_resource_type_ = kGceInstanceResourceType; |
There was a problem hiding this comment.
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.
| @@ -0,0 +1,63 @@ | |||
| /* | |||
| * Copyright 2017 Google Inc. | |||
There was a problem hiding this comment.
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.
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.
| #ifndef INSTANCE_H_ | ||
| #define INSTANCE_H_ | ||
|
|
||
| //#include "config.h" |
There was a problem hiding this comment.
Nit: Remove if unnecessary.
There was a problem hiding this comment.
This is the pattern in all other files, just to allow using autotools later. I'd like to keep it consistent.
| 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.
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.
Ah, right. Thanks for adding the comment!
| @@ -0,0 +1,63 @@ | |||
| /* | |||
| * Copyright 2017 Google Inc. | |||
| #ifndef INSTANCE_H_ | ||
| #define INSTANCE_H_ | ||
|
|
||
| //#include "config.h" |
| } else { | ||
| // Default to a GCE instance. | ||
| // TODO: Detect other instance resources. | ||
| instance_resource_type_ = kGceInstanceResourceType; |
There was a problem hiding this comment.
Is there a reason that config_.InstanceResourceType cannot default to "gce_instance"?
There was a problem hiding this comment.
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.
Thanks, PTAL.
| 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.
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.
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.
This is the pattern in all other files, just to allow using autotools later. I'd like to keep it consistent.
…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.