Skip to content

Commit

Permalink
Make all useage of sort deterministic
Browse files Browse the repository at this point in the history
Lots of places used sort (or sort -u) but didn't set LC_ALL=C. This
means it could be slightly different on different people's systems. Make
it deterministic.
  • Loading branch information
eparis committed Oct 20, 2016
1 parent c04aec3 commit 9214f8a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 17 deletions.
8 changes: 4 additions & 4 deletions Makefile.generated_files
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ endif
DEEPCOPY_DIRS := $(shell \
grep --color=never -l '+k8s:deepcopy-gen=' $(ALL_K8S_TAG_FILES) \
| xargs -n1 dirname \
| sort -u \
| LC_ALL=C sort -u \
)
DEEPCOPY_FILES := $(addsuffix /$(DEEPCOPY_FILENAME), $(DEEPCOPY_DIRS))

Expand Down Expand Up @@ -318,7 +318,7 @@ endif
DEFAULTER_DIRS := $(shell \
grep --color=never -l '+k8s:defaulter-gen=' $(ALL_K8S_TAG_FILES) \
| xargs -n1 dirname \
| sort -u \
| LC_ALL=C sort -u \
)

DEFAULTER_FILES := $(addsuffix /$(DEFAULTER_FILENAME), $(DEFAULTER_DIRS))
Expand Down Expand Up @@ -448,7 +448,7 @@ endif
OPENAPI_DIRS := $(shell \
grep --color=never -l '+k8s:openapi-gen=' $(ALL_K8S_TAG_FILES) \
| xargs -n1 dirname \
| sort -u \
| LC_ALL=C sort -u \
)

OPENAPI_OUTFILE := $(OPENAPI_OUTPUT_PKG)/$(OPENAPI_FILENAME)
Expand Down Expand Up @@ -555,7 +555,7 @@ CONVERSION_DIRS := $(shell \
grep --color=never '^// *+k8s:conversion-gen=' $(ALL_K8S_TAG_FILES) \
| cut -f1 -d: \
| xargs -n1 dirname \
| sort -u \
| LC_ALL=C sort -u \
)

CONVERSION_FILES := $(addsuffix /$(CONVERSION_FILENAME), $(CONVERSION_DIRS))
Expand Down
6 changes: 3 additions & 3 deletions hack/grab-profiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ SSH_PID=$(pgrep -f "/usr/bin/ssh.*${tunnel_port}:localhost:8080")
kube::util::trap_add 'kill $SSH_PID' EXIT
kube::util::trap_add 'kill $SSH_PID' SIGTERM

requested_profiles=$(echo ${requested_profiles} | xargs -n1 | sort -u | xargs)
profile_components=$(echo ${profile_components} | xargs -n1 | sort -u | xargs)
kubelet_addreses=$(echo ${kubelet_addreses} | xargs -n1 | sort -u | xargs)
requested_profiles=$(echo ${requested_profiles} | xargs -n1 | LC_ALL=C sort -u | xargs)
profile_components=$(echo ${profile_components} | xargs -n1 | LC_ALL=C sort -u | xargs)
kubelet_addreses=$(echo ${kubelet_addreses} | xargs -n1 | LC_ALL=C sort -u | xargs)
echo "requested profiles: ${requested_profiles}"
echo "flags for heap profile: ${mem_pprof_flags}"

Expand Down
2 changes: 1 addition & 1 deletion hack/list-feature-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ set -o nounset
set -o pipefail

KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
grep "\[Feature:\w+\]" "${KUBE_ROOT}"/test/e2e/*.go -Poh | sort | uniq
grep "\[Feature:\w+\]" "${KUBE_ROOT}"/test/e2e/*.go -Poh | LC_ALL=C sort -u
2 changes: 1 addition & 1 deletion hack/make-rules/helpers/cache_go_dirs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ mkdir -p $(dirname "${CACHE}")
if $("${NEED_FIND}"); then
kfind -type f -name \*.go \
| xargs -n1 dirname \
| sort -u \
| LC_ALL=C sort -u \
| sed 's|^./||' \
> "${CACHE}"
fi
Expand Down
3 changes: 1 addition & 2 deletions hack/make-rules/test-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ kube::test::find_integration_test_dirs() {
cd ${KUBE_ROOT}
find test/integration/${1-} -name '*_test.go' -print0 \
| xargs -0n1 dirname \
| uniq \
| sort -u
| LC_ALL=C sort -u
)
}

Expand Down
4 changes: 2 additions & 2 deletions hack/make-rules/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ kube::test::find_dirs() {
-o -path './staging/*' \
-o -path './vendor/*' \
\) -prune \
\) -name '*_test.go' -print0 | xargs -0n1 dirname | sed 's|^\./||' | sort -u
\) -name '*_test.go' -print0 | xargs -0n1 dirname | sed 's|^\./||' | LC_ALL=C sort -u

find -L . \
-path './_output' -prune \
-o -path './vendor/k8s.io/client-go/*' \
-name '*_test.go' -print0 | xargs -0n1 dirname | sed 's|^\./||' | sort -u
-name '*_test.go' -print0 | xargs -0n1 dirname | sed 's|^\./||' | LC_ALL=C sort -u
)
}

Expand Down
4 changes: 2 additions & 2 deletions hack/update-codecgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ generated_files=($(
-o -wholename '*/vendor/*' \
-o -wholename '*/codecgen-*-1234.generated.go' \
\) -prune \
\) -name '*.generated.go' | sort -r))
\) -name '*.generated.go' | LC_ALL=C sort -r))

# We only work for deps within this prefix.
my_prefix="k8s.io/kubernetes"
Expand Down Expand Up @@ -67,7 +67,7 @@ for (( i=0; i<number; i++ )); do
deps[${i}]=$(go list -f '{{range .Deps}}{{.}}{{"\n"}}{{end}}' ${file} | grep "^${my_prefix}")
done
###echo "DBG: found $number generated files"
###for f in $(echo "${generated_files[@]}" | sort); do
###for f in $(echo "${generated_files[@]}" | LC_ALL=C sort); do
### echo "DBG: $f"
###done

Expand Down
4 changes: 2 additions & 2 deletions hack/verify-test-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ result=0

# Find mentions of untagged gcr.io images in test/e2e/*.go
find_e2e_test_untagged_gcr_images() {
grep -o -E -e 'gcr.io/[-a-z0-9/_:.]+' test/e2e/*.go | grep -v -E "gcr.io/.*:" | cut -d ":" -f 1 | sort | uniq
grep -o -E -e 'gcr.io/[-a-z0-9/_:.]+' test/e2e/*.go | grep -v -E "gcr.io/.*:" | cut -d ":" -f 1 | LC_ALL=C sort -u
}


# Find mentions of latest gcr.io images in test/e2e/*.go
find_e2e_test_latest_gcr_images() {
grep -o -E -e 'gcr.io/.*:latest' test/e2e/*.go | cut -d ":" -f 1 | sort | uniq
grep -o -E -e 'gcr.io/.*:latest' test/e2e/*.go | cut -d ":" -f 1 | LC_ALL=C sort -u
}

if find_e2e_test_latest_gcr_images; then
Expand Down

0 comments on commit 9214f8a

Please sign in to comment.