Skip to content

Commit 4961065

Browse files
committed
cluster: remove unused functions
1 parent 4709140 commit 4961065

File tree

3 files changed

+11
-99
lines changed

3 files changed

+11
-99
lines changed

Diff for: cluster/common.sh

-44
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,6 @@ function clear-kubeconfig() {
159159
echo "Cleared config for ${CONTEXT} from ${KUBECONFIG}"
160160
}
161161

162-
function tear_down_alive_resources() {
163-
local kubectl="${KUBE_ROOT}/cluster/kubectl.sh"
164-
"${kubectl}" delete deployments --all || true
165-
"${kubectl}" delete rc --all || true
166-
"${kubectl}" delete pods --all || true
167-
"${kubectl}" delete svc --all || true
168-
"${kubectl}" delete pvc --all || true
169-
}
170-
171162
# Gets username, password for the current-context in kubeconfig, if they exist.
172163
# Assumed vars:
173164
# KUBECONFIG # if unset, defaults to global
@@ -253,17 +244,6 @@ function gen-kube-bearertoken() {
253244
KUBE_BEARER_TOKEN=$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64 | tr -d "=+/" | dd bs=32 count=1 2>/dev/null)
254245
}
255246

256-
# Generate uid
257-
# This function only works on systems with python. It generates a time based
258-
# UID instead of a UUID because GCE has a name length limit.
259-
#
260-
# Vars set:
261-
# KUBE_UID
262-
function gen-uid {
263-
KUBE_UID=$(python -c 'import uuid; print(uuid.uuid1().fields[0])')
264-
}
265-
266-
267247
function load-or-gen-kube-basicauth() {
268248
if [[ ! -z "${KUBE_CONTEXT:-}" ]]; then
269249
get-kubeconfig-basicauth
@@ -293,28 +273,6 @@ function load-or-gen-kube-bearertoken() {
293273
fi
294274
}
295275

296-
# Get the master IP for the current-context in kubeconfig if one exists.
297-
#
298-
# Assumed vars:
299-
# KUBECONFIG # if unset, defaults to global
300-
# KUBE_CONTEXT # if unset, defaults to current-context
301-
#
302-
# Vars set:
303-
# KUBE_MASTER_URL
304-
#
305-
# KUBE_MASTER_URL will be empty if no current-context is set, or the
306-
# current-context user does not exist or contain a server entry.
307-
function detect-master-from-kubeconfig() {
308-
export KUBECONFIG=${KUBECONFIG:-$DEFAULT_KUBECONFIG}
309-
310-
local cc=$("${KUBE_ROOT}/cluster/kubectl.sh" config view -o jsonpath="{.current-context}")
311-
if [[ ! -z "${KUBE_CONTEXT:-}" ]]; then
312-
cc="${KUBE_CONTEXT}"
313-
fi
314-
local cluster=$("${KUBE_ROOT}/cluster/kubectl.sh" config view -o jsonpath="{.contexts[?(@.name == \"${cc}\")].context.cluster}")
315-
KUBE_MASTER_URL=$("${KUBE_ROOT}/cluster/kubectl.sh" config view -o jsonpath="{.clusters[?(@.name == \"${cluster}\")].cluster.server}")
316-
}
317-
318276
# Sets KUBE_VERSION variable to the proper version number (e.g. "v1.0.6",
319277
# "v1.2.0-alpha.1.881+376438b69c7612") or a version' publication of the form
320278
# <path>/<version> (e.g. "release/stable",' "ci/latest-1").
@@ -569,7 +527,6 @@ function build-kube-env {
569527
fi
570528

571529
build-runtime-config
572-
gen-uid
573530

574531
rm -f ${file}
575532
cat >$file <<EOF
@@ -633,7 +590,6 @@ KUBE_DOCKER_REGISTRY: $(yaml-quote ${KUBE_DOCKER_REGISTRY:-})
633590
KUBE_ADDON_REGISTRY: $(yaml-quote ${KUBE_ADDON_REGISTRY:-})
634591
MULTIZONE: $(yaml-quote ${MULTIZONE:-})
635592
NON_MASQUERADE_CIDR: $(yaml-quote ${NON_MASQUERADE_CIDR:-})
636-
KUBE_UID: $(yaml-quote ${KUBE_UID:-})
637593
ENABLE_DEFAULT_STORAGE_CLASS: $(yaml-quote ${ENABLE_DEFAULT_STORAGE_CLASS:-})
638594
ENABLE_APISERVER_BASIC_AUDIT: $(yaml-quote ${ENABLE_APISERVER_BASIC_AUDIT:-})
639595
ENABLE_APISERVER_ADVANCED_AUDIT: $(yaml-quote ${ENABLE_APISERVER_ADVANCED_AUDIT:-})

Diff for: cluster/gce/util.sh

-55
Original file line numberDiff line numberDiff line change
@@ -677,61 +677,6 @@ function create-node-template() {
677677
done
678678
}
679679

680-
# Robustly try to add metadata on an instance.
681-
# $1: The name of the instance.
682-
# $2...$n: The metadata key=value pairs to add.
683-
function add-instance-metadata() {
684-
local -r instance=$1
685-
shift 1
686-
local -r kvs=( "$@" )
687-
detect-project
688-
local attempt=0
689-
while true; do
690-
if ! gcloud compute instances add-metadata "${instance}" \
691-
--project "${PROJECT}" \
692-
--zone "${ZONE}" \
693-
--metadata "${kvs[@]}"; then
694-
if (( attempt > 5 )); then
695-
echo -e "${color_red}Failed to add instance metadata in ${instance} ${color_norm}" >&2
696-
exit 2
697-
fi
698-
echo -e "${color_yellow}Attempt $(($attempt+1)) failed to add metadata in ${instance}. Retrying.${color_norm}" >&2
699-
attempt=$(($attempt+1))
700-
sleep $((5 * $attempt))
701-
else
702-
break
703-
fi
704-
done
705-
}
706-
707-
# Robustly try to add metadata on an instance, from a file.
708-
# $1: The name of the instance.
709-
# $2...$n: The metadata key=file pairs to add.
710-
function add-instance-metadata-from-file() {
711-
local -r instance=$1
712-
shift 1
713-
local -r kvs=( "$@" )
714-
detect-project
715-
local attempt=0
716-
while true; do
717-
echo "${kvs[@]}"
718-
if ! gcloud compute instances add-metadata "${instance}" \
719-
--project "${PROJECT}" \
720-
--zone "${ZONE}" \
721-
--metadata-from-file "$(join_csv ${kvs[@]})"; then
722-
if (( attempt > 5 )); then
723-
echo -e "${color_red}Failed to add instance metadata in ${instance} ${color_norm}" >&2
724-
exit 2
725-
fi
726-
echo -e "${color_yellow}Attempt $(($attempt+1)) failed to add metadata in ${instance}. Retrying.${color_norm}" >&2
727-
attempt=$(($attempt+1))
728-
sleep $(($attempt * 5))
729-
else
730-
break
731-
fi
732-
done
733-
}
734-
735680
# Instantiate a kubernetes cluster
736681
#
737682
# Assumed vars

Diff for: hack/ginkgo-e2e.sh

+11
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ export KUBECTL KUBE_CONFIG_FILE
4545

4646
source "${KUBE_ROOT}/cluster/kube-util.sh"
4747

48+
function detect-master-from-kubeconfig() {
49+
export KUBECONFIG=${KUBECONFIG:-$DEFAULT_KUBECONFIG}
50+
51+
local cc=$("${KUBE_ROOT}/cluster/kubectl.sh" config view -o jsonpath="{.current-context}")
52+
if [[ ! -z "${KUBE_CONTEXT:-}" ]]; then
53+
cc="${KUBE_CONTEXT}"
54+
fi
55+
local cluster=$("${KUBE_ROOT}/cluster/kubectl.sh" config view -o jsonpath="{.contexts[?(@.name == \"${cc}\")].context.cluster}")
56+
KUBE_MASTER_URL=$("${KUBE_ROOT}/cluster/kubectl.sh" config view -o jsonpath="{.clusters[?(@.name == \"${cluster}\")].cluster.server}")
57+
}
58+
4859
# ---- Do cloud-provider-specific setup
4960
if [[ -n "${KUBERNETES_CONFORMANCE_TEST:-}" ]]; then
5061
echo "Conformance test: not doing test setup."

0 commit comments

Comments
 (0)