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

Conversation

@igorpeshansky
Copy link
Contributor

@x13n FYI.

std::istringstream in(kube_env);
for (std::string line; std::getline(in, line); ) {
if (line.find("ZONE: ") == 0) {
kubernetes_cluster_location_ = line.substr(line.find(':') + 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's break out of this early when we find a match.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Obsolete. See the new shiny in the next push.


#include <boost/network/protocol/http/client.hpp>
#include <fstream>
#include <sstream>
Copy link
Contributor

Choose a reason for hiding this comment

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

Naive c++ question, where is this actually being used? Is this in the std namespace when you use std::istringstream in(kube_env);?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is the header for std::istringstream.

Copy link
Contributor

@supriyagarg supriyagarg Feb 24, 2018

Choose a reason for hiding this comment

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

remove this import now that std::istringstream is no longer used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Done.

} else {
// Get the kube-env.
const std::string kube_env =
GetMetadataString("instance/attributes/kube-env");
Copy link

Choose a reason for hiding this comment

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

For all clusters with Kubernetes in version 1.10.0 or newer, Metadata Server exports instance attribute "cluster-location". This works also for all GKE clusters created or upgraded after last GKE release (with cl/185806663) included. You shouldn't need to extract this from "kube-env". Do we need to support older clusters?

I think we discussed this earlier in email thread, sorry if I didn't clarify this enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I didn't find the email thread in time. Updated the bug with the info and fixed.

@kawych
Copy link

kawych commented Feb 23, 2018

Please reassign to @x13n if the review is needed within a week, I'm on vacation until March 5.

const std::string kube_env =
GetMetadataString("instance/attributes/kube-env");
// kube-env is a list of NAME: VALUE pairs, one per line.
// The actual location is in the ZONE variable.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this true for regional clusters too? Or is there a new region / location field?

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 was stale anyway. See the new shiny in the next push.

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, all. PTAL.


#include <boost/network/protocol/http/client.hpp>
#include <fstream>
#include <sstream>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is the header for std::istringstream.

} else {
// Get the kube-env.
const std::string kube_env =
GetMetadataString("instance/attributes/kube-env");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I didn't find the email thread in time. Updated the bug with the info and fixed.

const std::string kube_env =
GetMetadataString("instance/attributes/kube-env");
// kube-env is a list of NAME: VALUE pairs, one per line.
// The actual location is in the ZONE variable.
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 was stale anyway. See the new shiny in the next push.

std::istringstream in(kube_env);
for (std::string line; std::getline(in, line); ) {
if (line.find("ZONE: ") == 0) {
kubernetes_cluster_location_ = line.substr(line.find(':') + 2);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Obsolete. See the new shiny in the next push.

@igorpeshansky igorpeshansky changed the title Retrieve cluster location from kube-env, rather than using the instance zone. Retrieve cluster location from metadata attributes, rather than using the instance zone. Feb 24, 2018
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


#include <boost/network/protocol/http/client.hpp>
#include <fstream>
#include <sstream>
Copy link
Contributor

@supriyagarg supriyagarg Feb 24, 2018

Choose a reason for hiding this comment

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

remove this import now that std::istringstream is no longer used.

@igorpeshansky igorpeshansky requested a review from kawych February 24, 2018 18:34
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

@igorpeshansky igorpeshansky force-pushed the igorp-kubernetes-cluster-location branch from 75119f2 to a98bf11 Compare February 25, 2018 05:41
@igorpeshansky igorpeshansky changed the base branch from master to igorp-handle-http-codes February 25, 2018 05:42
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

@igorpeshansky
Copy link
Contributor Author

FYI, I've rebased this off the HTTP status changes, as those are required for correctly detecting that the attribute is absent.

@igorpeshansky igorpeshansky force-pushed the igorp-handle-http-codes branch from 7bc2c05 to 32e3db1 Compare February 26, 2018 02:11
@igorpeshansky igorpeshansky force-pushed the igorp-kubernetes-cluster-location branch from a98bf11 to f30ec5c Compare February 26, 2018 12:20
@igorpeshansky igorpeshansky changed the base branch from igorp-handle-http-codes to master February 26, 2018 12:20
@igorpeshansky
Copy link
Contributor Author

Rebased off master.

@igorpeshansky igorpeshansky requested a review from x13n February 26, 2018 12:47
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

@igorpeshansky igorpeshansky merged commit b6b6142 into master Feb 26, 2018
@igorpeshansky igorpeshansky deleted the igorp-kubernetes-cluster-location branch February 26, 2018 14:35
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.

5 participants