-
Notifications
You must be signed in to change notification settings - Fork 11
Retrieve cluster location from metadata attributes, rather than using the instance zone. #57
Conversation
src/environment.cc
Outdated
| 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); |
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.
Let's break out of this early when we find a match.
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.
Obsolete. See the new shiny in the next push.
|
|
||
| #include <boost/network/protocol/http/client.hpp> | ||
| #include <fstream> | ||
| #include <sstream> |
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.
Naive c++ question, where is this actually being used? Is this in the std namespace when you use std::istringstream in(kube_env);?
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.
Yeah, this is the header for std::istringstream.
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.
remove this import now that std::istringstream is no longer used.
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.
Good catch. Done.
src/environment.cc
Outdated
| } else { | ||
| // Get the kube-env. | ||
| const std::string kube_env = | ||
| GetMetadataString("instance/attributes/kube-env"); |
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.
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.
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.
Sorry, I didn't find the email thread in time. Updated the bug with the info and fixed.
|
Please reassign to @x13n if the review is needed within a week, I'm on vacation until March 5. |
src/environment.cc
Outdated
| 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. |
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 this true for regional clusters too? Or is there a new region / location field?
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 stale anyway. See the new shiny in the next push.
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, all. PTAL.
|
|
||
| #include <boost/network/protocol/http/client.hpp> | ||
| #include <fstream> | ||
| #include <sstream> |
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.
Yeah, this is the header for std::istringstream.
src/environment.cc
Outdated
| } else { | ||
| // Get the kube-env. | ||
| const std::string kube_env = | ||
| GetMetadataString("instance/attributes/kube-env"); |
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.
Sorry, I didn't find the email thread in time. Updated the bug with the info and fixed.
src/environment.cc
Outdated
| 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. |
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 stale anyway. See the new shiny in the next push.
src/environment.cc
Outdated
| 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); |
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.
Obsolete. See the new shiny in the next push.
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
|
|
||
| #include <boost/network/protocol/http/client.hpp> | ||
| #include <fstream> | ||
| #include <sstream> |
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.
remove this import now that std::istringstream is no longer used.
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
75119f2 to
a98bf11
Compare
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
|
FYI, I've rebased this off the HTTP status changes, as those are required for correctly detecting that the attribute is absent. |
7bc2c05 to
32e3db1
Compare
a98bf11 to
f30ec5c
Compare
|
Rebased off |
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
@x13n FYI.