Merge pull request #11265 from mbforbes/gkeBashlog

Cleanup GKE bash logging
This commit is contained in:
Mike Danese 2015-07-24 18:51:36 -07:00
commit 5bd82ffe6d

View File

@ -29,7 +29,7 @@ source "${KUBE_ROOT}/cluster/gke/${KUBE_CONFIG_FILE:-config-default.sh}"
# Assumed vars: # Assumed vars:
# GCLOUD # GCLOUD
function prepare-e2e() { function prepare-e2e() {
echo "... in prepare-e2e()" >&2 echo "... in gke:prepare-e2e()" >&2
# Ensure GCLOUD is set to some gcloud binary. # Ensure GCLOUD is set to some gcloud binary.
if [[ -z "${GCLOUD:-}" ]]; then if [[ -z "${GCLOUD:-}" ]]; then
@ -48,7 +48,7 @@ function prepare-e2e() {
# Vars set: # Vars set:
# PROJECT # PROJECT
function detect-project() { function detect-project() {
echo "... in detect-project()" >&2 echo "... in gke:detect-project()" >&2
if [[ -z "${PROJECT:-}" ]]; then if [[ -z "${PROJECT:-}" ]]; then
export PROJECT=$("${GCLOUD}" config list project | tail -n 1 | cut -f 3 -d ' ') export PROJECT=$("${GCLOUD}" config list project | tail -n 1 | cut -f 3 -d ' ')
echo "... Using project: ${PROJECT}" >&2 echo "... Using project: ${PROJECT}" >&2
@ -62,13 +62,14 @@ function detect-project() {
# Execute prior to running tests to build a release if required for env. # Execute prior to running tests to build a release if required for env.
function test-build-release() { function test-build-release() {
echo "... in test-build-release()" >&2 echo "... in gke:test-build-release()" >&2
# We currently use the Kubernetes version that GKE supports (not testing # We currently use the Kubernetes version that GKE supports (not testing
# bleeding-edge builds). # bleeding-edge builds).
} }
# Verify needed binaries exist. # Verify needed binaries exist.
function verify-prereqs() { function verify-prereqs() {
echo "... in gke:verify-prereqs()" >&2
if ! which gcloud >/dev/null; then if ! which gcloud >/dev/null; then
local resp local resp
if [[ "${KUBE_PROMPT_FOR_UPDATE}" == "y" ]]; then if [[ "${KUBE_PROMPT_FOR_UPDATE}" == "y" ]]; then
@ -113,7 +114,7 @@ function verify-prereqs() {
# NUM_MINIONS # NUM_MINIONS
# MINION_SCOPES # MINION_SCOPES
function kube-up() { function kube-up() {
echo "... in kube-up()" >&2 echo "... in gke:kube-up()" >&2
detect-project >&2 detect-project >&2
# Make the specified network if we need to. # Make the specified network if we need to.
@ -165,7 +166,7 @@ function kube-up() {
# Vars set: # Vars set:
# MINION_TAG # MINION_TAG
function test-setup() { function test-setup() {
echo "... in test-setup()" >&2 echo "... in gke:test-setup()" >&2
# Detect the project into $PROJECT if it isn't set # Detect the project into $PROJECT if it isn't set
detect-project >&2 detect-project >&2
detect-minions >&2 detect-minions >&2
@ -199,7 +200,7 @@ function test-setup() {
# KUBE_USER # KUBE_USER
# KUBE_PASSWORD # KUBE_PASSWORD
function get-password() { function get-password() {
echo "... in get-password()" >&2 echo "... in gke:get-password()" >&2
detect-project >&2 detect-project >&2
KUBE_USER=$("${GCLOUD}" "${CMD_GROUP}" container clusters describe \ KUBE_USER=$("${GCLOUD}" "${CMD_GROUP}" container clusters describe \
--project="${PROJECT}" --zone="${ZONE}" "${CLUSTER_NAME}" \ --project="${PROJECT}" --zone="${ZONE}" "${CLUSTER_NAME}" \
@ -218,7 +219,7 @@ function get-password() {
# KUBE_MASTER # KUBE_MASTER
# KUBE_MASTER_IP # KUBE_MASTER_IP
function detect-master() { function detect-master() {
echo "... in detect-master()" >&2 echo "... in gke:detect-master()" >&2
detect-project >&2 detect-project >&2
KUBE_MASTER="k8s-${CLUSTER_NAME}-master" KUBE_MASTER="k8s-${CLUSTER_NAME}-master"
KUBE_MASTER_IP=$("${GCLOUD}" "${CMD_GROUP}" container clusters describe \ KUBE_MASTER_IP=$("${GCLOUD}" "${CMD_GROUP}" container clusters describe \
@ -231,7 +232,7 @@ function detect-master() {
# Vars set: # Vars set:
# MINION_NAMES # MINION_NAMES
function detect-minions() { function detect-minions() {
echo "... in detect-minions()" >&2 echo "... in gke:detect-minions()" >&2
detect-minion-names detect-minion-names
} }
@ -242,6 +243,7 @@ function detect-minions() {
# Vars set: # Vars set:
# MINION_NAMES # MINION_NAMES
function detect-minion-names { function detect-minion-names {
echo "... in gke:detect-minion-names()" >&2
detect-project detect-project
detect-node-instance-group detect-node-instance-group
MINION_NAMES=($(gcloud preview --project "${PROJECT}" instance-groups \ MINION_NAMES=($(gcloud preview --project "${PROJECT}" instance-groups \
@ -260,6 +262,7 @@ function detect-minion-names {
# Vars set: # Vars set:
# NODE_INSTANCE_GROUP # NODE_INSTANCE_GROUP
function detect-node-instance-group { function detect-node-instance-group {
echo "... in gke:detect-node-instance-group()" >&2
NODE_INSTANCE_GROUP=$("${GCLOUD}" "${CMD_GROUP}" container clusters describe \ NODE_INSTANCE_GROUP=$("${GCLOUD}" "${CMD_GROUP}" container clusters describe \
--project="${PROJECT}" --zone="${ZONE}" "${CLUSTER_NAME}" \ --project="${PROJECT}" --zone="${ZONE}" "${CLUSTER_NAME}" \
| grep instanceGroupManagers | cut -d '/' -f 11) | grep instanceGroupManagers | cut -d '/' -f 11)
@ -271,7 +274,7 @@ function detect-node-instance-group {
# GCLOUD # GCLOUD
# ZONE # ZONE
function ssh-to-node() { function ssh-to-node() {
echo "... in ssh-to-node()" >&2 echo "... in gke:ssh-to-node()" >&2
detect-project >&2 detect-project >&2
local node="$1" local node="$1"
@ -289,13 +292,13 @@ function ssh-to-node() {
# Restart the kube-proxy on a node ($1) # Restart the kube-proxy on a node ($1)
function restart-kube-proxy() { function restart-kube-proxy() {
echo "... in restart-kube-proxy()" >&2 echo "... in gke:restart-kube-proxy()" >&2
ssh-to-node "$1" "sudo /etc/init.d/kube-proxy restart" ssh-to-node "$1" "sudo /etc/init.d/kube-proxy restart"
} }
# Restart the kube-proxy on master ($1) # Restart the kube-proxy on master ($1)
function restart-apiserver() { function restart-apiserver() {
echo "... in restart-kube-apiserver()" >&2 echo "... in gke:restart-apiserver()" >&2
ssh-to-node "$1" "sudo docker ps | grep /kube-apiserver | cut -d ' ' -f 1 | xargs sudo docker kill" ssh-to-node "$1" "sudo docker ps | grep /kube-apiserver | cut -d ' ' -f 1 | xargs sudo docker kill"
} }
@ -309,7 +312,7 @@ function restart-apiserver() {
# KUBE_ROOT # KUBE_ROOT
# ZONE # ZONE
function test-teardown() { function test-teardown() {
echo "... in test-teardown()" >&2 echo "... in gke:test-teardown()" >&2
detect-project >&2 detect-project >&2
detect-minions >&2 detect-minions >&2
@ -334,7 +337,7 @@ function test-teardown() {
# ZONE # ZONE
# CLUSTER_NAME # CLUSTER_NAME
function kube-down() { function kube-down() {
echo "... in kube-down()" >&2 echo "... in gke:kube-down()" >&2
detect-project >&2 detect-project >&2
"${GCLOUD}" "${CMD_GROUP}" container clusters delete --project="${PROJECT}" \ "${GCLOUD}" "${CMD_GROUP}" container clusters delete --project="${PROJECT}" \
--zone="${ZONE}" "${CLUSTER_NAME}" --quiet --zone="${ZONE}" "${CLUSTER_NAME}" --quiet