Skip to content

Commit

Permalink
Merge pull request #49968 from mikedanese/automated-cherry-pick-of-#4…
Browse files Browse the repository at this point in the history
…9897-#49898-release-1.7

Automatic merge from submit-queue

Automated cherry pick of #49897 #49898 release 1.7

Cherrypick of  #49897 #49898
Part of #49895
```release-note
In GCE, add measures to prevent corruption of known_tokens.csv
```
  • Loading branch information
Kubernetes Submit Queue authored Aug 2, 2017
2 parents ae8e383 + c5a3343 commit 07834b8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cluster/gce/gci/configure-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,13 @@ function append_or_replace_prefixed_line {
local -r file="${1:-}"
local -r prefix="${2:-}"
local -r suffix="${3:-}"
local -r dirname="$(dirname ${file})"
local -r tmpfile="$(mktemp -t filtered.XXXX --tmpdir=${dirname})"

touch "${file}"
awk "substr(\$0,0,length(\"${prefix}\")) != \"${prefix}\" { print }" "${file}" > "${file}.filtered" && mv "${file}.filtered" "${file}"
echo "${prefix}${suffix}" >> "${file}"
awk "substr(\$0,0,length(\"${prefix}\")) != \"${prefix}\" { print }" "${file}" > "${tmpfile}"
echo "${prefix}${suffix}" >> "${tmpfile}"
mv "${tmpfile}" "${file}"
}

function create-node-pki {
Expand Down Expand Up @@ -356,7 +359,11 @@ function create-master-auth {
fi
append_or_replace_prefixed_line "${basic_auth_csv}" "${KUBE_PASSWORD},${KUBE_USER}," "admin,system:masters"
fi

local -r known_tokens_csv="${auth_dir}/known_tokens.csv"
if [[ -e "${known_tokens_csv}" && "${METADATA_CLOBBERS_CONFIG:-false}" == "true" ]]; then
rm "${known_tokens_csv}"
fi
if [[ -n "${KUBE_BEARER_TOKEN:-}" ]]; then
append_or_replace_prefixed_line "${known_tokens_csv}" "${KUBE_BEARER_TOKEN}," "admin,admin,system:masters"
fi
Expand Down

0 comments on commit 07834b8

Please sign in to comment.