Skip to content
This repository was archived by the owner on Aug 19, 2019. It is now read-only.

Conversation

@igorpeshansky
Copy link
Contributor

Also factor out an InstanceUpdater that polls the instance resource and add more configuration options.

Copy link
Contributor

@bmoyles0117 bmoyles0117 left a 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.

8*1024*1024;
constexpr const char kMetadataIngestionDefaultRawContentVersion[] = "0.1";
constexpr const int kInstanceUpdaterDefaultIntervalSeconds = 60*60;
constexpr const char kDefaultInstanceResourceType[] = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be blank?

Copy link
Contributor Author

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".

Copy link
Contributor Author

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";
Copy link
Contributor

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.

Copy link
Contributor Author

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>();
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

@igorpeshansky igorpeshansky left a 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.

8*1024*1024;
constexpr const char kMetadataIngestionDefaultRawContentVersion[] = "0.1";
constexpr const int kInstanceUpdaterDefaultIntervalSeconds = 60*60;
constexpr const char kDefaultInstanceResourceType[] = "";
Copy link
Contributor Author

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";
Copy link
Contributor Author

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>();
Copy link
Contributor Author

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2018?

Copy link
Contributor Author

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.

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;

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?

Copy link
Contributor Author

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.

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;

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?

Copy link
Contributor Author

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.

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!

Copy link
Contributor Author

@igorpeshansky igorpeshansky left a 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;
Copy link
Contributor Author

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.
Copy link
Contributor Author

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;
Copy link
Contributor Author

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.

Copy link
Contributor

@bmoyles0117 bmoyles0117 left a 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Remove if unnecessary.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

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.

Copy link

@qingling128 qingling128 left a 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;

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;

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.

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"

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;
Copy link
Contributor

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"?

Copy link
Contributor Author

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.

Copy link
Contributor Author

@igorpeshansky igorpeshansky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, PTAL.

8*1024*1024;
constexpr const char kMetadataIngestionDefaultRawContentVersion[] = "0.1";
constexpr const int kInstanceUpdaterDefaultIntervalSeconds = 60*60;
constexpr const char kDefaultInstanceResourceType[] = "";
Copy link
Contributor Author

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;
Copy link
Contributor Author

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"
Copy link
Contributor Author

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.

Copy link
Contributor

@supriyagarg supriyagarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@igorpeshansky igorpeshansky force-pushed the igorp-instance-resource branch from 5a9e66c to c1fa702 Compare February 23, 2018 20:57
@igorpeshansky
Copy link
Contributor Author

Rebased off master.

@igorpeshansky igorpeshansky merged commit 419d9ca into master Feb 23, 2018
@igorpeshansky igorpeshansky deleted the igorp-instance-resource branch February 23, 2018 21:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants