Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix list-resources.sh to work with the GKE provider #20143

Merged
merged 1 commit into from
Jan 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions cluster/gce/list-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ REGION=${ZONE%-*}
INSTANCE_PREFIX=${KUBE_GCE_INSTANCE_PREFIX:-${CLUSTER_NAME:-}}
NETWORK=${KUBE_GCE_NETWORK:-${KUBE_GKE_NETWORK:-}}

# In GKE the instance prefix starts with "gke-".
if [[ "${KUBERNETES_PROVIDER:-}" == "gke" ]]; then
INSTANCE_PREFIX="gke-${CLUSTER_NAME}"
# Truncate to 26 characters for route prefix matching.
INSTANCE_PREFIX="${INSTANCE_PREFIX:0:26}"
fi

# Usage: gcloud-compute-list <resource> <additional parameters to gcloud...>
# GREP_REGEX is applied to the output of gcloud if set
GREP_REGEX=""
Expand All @@ -40,7 +47,6 @@ function gcloud-compute-list() {
local attempt=1
local result=""
while true; do
echo "Attempt ${attempt} to list ${resource} in GCE"
if result=$(gcloud compute ${resource} list --project=${PROJECT} ${@:2} | grep "${GREP_REGEX}"); then
echo "${result}"
return
Expand All @@ -59,7 +65,8 @@ echo "Project: ${PROJECT}"
echo "Region: ${REGION}"
echo "Zone: ${ZONE}"
echo "Instance prefix: ${INSTANCE_PREFIX:-}"
echo "Network: ${NETWORK:-}"
echo "Network: ${NETWORK}"
Copy link
Member

Choose a reason for hiding this comment

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

one more small suggestion: also print out Provider: ${KUBERNETES_PROVIDER}?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

echo "Provider: ${KUBERNETES_PROVIDER:-}"

# List resources related to instances, filtering by the instance prefix if
# provided.
Expand All @@ -75,7 +82,7 @@ gcloud-compute-list disks ${ZONE:+"--zone=${ZONE}"} --regexp="${INSTANCE_PREFIX}
gcloud-compute-list addresses ${REGION:+"--region=${REGION}"} --regexp="a.*|${INSTANCE_PREFIX}.*"
# Match either the header or a line with the specified e2e network.
# This assumes that the network name is the second field in the output.
GREP_REGEX="^NAME\|^[^\s]\+\s\+\(default\|${NETWORK}\)\s"
GREP_REGEX="^NAME\|^[^ ]\+[ ]\+\(default\|${NETWORK}\) "
gcloud-compute-list routes --regexp="default.*|${INSTANCE_PREFIX}.*"
gcloud-compute-list firewall-rules --regexp="default.*|k8s-fw.*|${INSTANCE_PREFIX}.*"
GREP_REGEX=""
Expand Down