Skip to content

Commit 8a4b4e8

Browse files
authored
Fix CI issue by pulling download-istio.sh (knative#3182)
1 parent 0f71541 commit 8a4b4e8

File tree

8 files changed

+106
-49
lines changed

8 files changed

+106
-49
lines changed

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ require (
1717
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
1818
gopkg.in/go-playground/webhooks.v3 v3.13.0
1919
gopkg.in/yaml.v2 v2.3.0
20-
knative.dev/hack v0.0.0-20210114150620-4422dcadb3c8
21-
knative.dev/net-istio v0.20.1-0.20210114170820-b4b1c95dc264
20+
knative.dev/hack v0.0.0-20210120165453-8d623a0af457
21+
knative.dev/net-istio v0.20.1-0.20210121182253-79a9f7f6a067
2222
)
2323

2424
replace go.opencensus.io => go.opencensus.io v0.20.2

go.sum

+7-7
Original file line numberDiff line numberDiff line change
@@ -1070,15 +1070,15 @@ k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6/go.mod h1:GRQhZsXIAJ1xR0C
10701070
k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29/go.mod h1:F+5wygcW0wmRTnM3cOgIqGivxkwSWIWT5YdsDbeAOaU=
10711071
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
10721072
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
1073-
knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24 h1:kIztWfvnIFV8Lhlea02K3YO2mIzcDyQNzrBLn0Oq9sA=
1074-
knative.dev/hack v0.0.0-20201214230143-4ed1ecb8db24/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
1075-
knative.dev/hack v0.0.0-20210112093330-d946d2557383/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
10761073
knative.dev/hack v0.0.0-20210114150620-4422dcadb3c8 h1:N/Kt6C5zZzTtFcTntRThB+vEJ7WcLKaZ5Q2Jm7b23vw=
10771074
knative.dev/hack v0.0.0-20210114150620-4422dcadb3c8/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
1078-
knative.dev/net-istio v0.20.1-0.20210114170820-b4b1c95dc264 h1:mcYdahUgJLQ8ThJL5TVEoh77uMvQ1I00LN3TMzof0rU=
1079-
knative.dev/net-istio v0.20.1-0.20210114170820-b4b1c95dc264/go.mod h1:Lum3PhFU7JweJQ1+sGka04/vphohTDhYRYqa3CfrYLU=
1080-
knative.dev/networking v0.0.0-20210113172032-07a8160d1971/go.mod h1:lAll0+JcN2iKex0P9hOXZ4siOdryW+HIuK4KBRM+ca4=
1081-
knative.dev/pkg v0.0.0-20210112143930-acbf2af596cf/go.mod h1:hckgW978SdzPA2H5EDvRPY8xsnPuDZLJLbPf8Jte7Q0=
1075+
knative.dev/hack v0.0.0-20210120165453-8d623a0af457 h1:jEBITgx/lQydGncM0uetpv/ZqawRzb2aSfEaYoMeDjM=
1076+
knative.dev/hack v0.0.0-20210120165453-8d623a0af457/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
1077+
knative.dev/net-istio v0.20.1-0.20210121182253-79a9f7f6a067 h1:y59Amw1hClEJOjnYVHtMx3iITHJxxu9VlPq+PTG1Y7U=
1078+
knative.dev/net-istio v0.20.1-0.20210121182253-79a9f7f6a067/go.mod h1:SnnQ05PEPAVUcgleQp9WfA/dtdEt/6er/JUHo1oEskw=
1079+
knative.dev/networking v0.0.0-20210121025453-4db00b8ae77a/go.mod h1:hVzeezXBzGbhKxNpG66/wNjDRiLwlWrVilunogWaKlo=
1080+
knative.dev/pkg v0.0.0-20210120200253-8cd47b5af35d/go.mod h1:cZdMjcJE6JGSNaEypgbUigX1TjteMIwQsW2woNBPVCA=
1081+
knative.dev/pkg v0.0.0-20210121025054-992644aa1905/go.mod h1:cZdMjcJE6JGSNaEypgbUigX1TjteMIwQsW2woNBPVCA=
10821082
pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
10831083
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
10841084
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=

hack/tools.go

+1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ import (
2222
_ "knative.dev/hack"
2323

2424
// For istio installation
25+
_ "knative.dev/net-istio/third_party"
2526
_ "knative.dev/net-istio/third_party/istio-stable"
2627
)

vendor/knative.dev/hack/library.sh

+25-4
Original file line numberDiff line numberDiff line change
@@ -794,11 +794,32 @@ function shellcheck_new_files() {
794794
}
795795

796796
function latest_version() {
797-
local semver=$(git describe --match "v[0-9]*" --abbrev=0)
798-
local major_minor=$(echo "$semver" | cut -d. -f1-2)
797+
# This function works "best effort" and works on Prow but not necessarily locally.
798+
# The problem is finding the latest release. If a release occurs on the same commit which
799+
# was branched from master, then the tag will be an ancestor to any commit derived from master.
800+
# That was the original logic. Additionally in a release branch, the tag is always an ancestor.
801+
# However, if the release commit ends up not the first commit from master, then the tag is not
802+
# an ancestor of master, so we can't use `git describe` to find the most recent versioned tag. So
803+
# we just sort all the tags and find the newest versioned one.
804+
# But when running locally, we cannot(?) know if the current branch is a fork of master or a fork
805+
# of a release branch. That's where this function will malfunction when the last release did not
806+
# occur on the first commit -- it will try to run the upgrade tests from an older version instead
807+
# of the most recent release.
808+
# Workarounds include:
809+
# Tag the first commit of the release branch. Say release-0.75 released v0.75.0 from the second commit
810+
# Then tag the first commit in common between master and release-0.75 with `v0.75`.
811+
# Always name your local fork master or main.
812+
if [ $(current_branch) = "master" ] || [ $(current_branch) = "main" ]; then
813+
# For main branch, simply use git tag without major version, this will work even
814+
# if the release tag is not in the main
815+
git tag -l "v[0-9]*" | sort -r --version-sort | head -n1
816+
else
817+
local semver=$(git describe --match "v[0-9]*" --abbrev=0)
818+
local major_minor=$(echo "$semver" | cut -d. -f1-2)
799819

800-
# Get the latest patch release for the major minor
801-
git tag -l "${major_minor}*" | sort -r --version-sort | head -n1
820+
# Get the latest patch release for the major minor
821+
git tag -l "${major_minor}*" | sort -r --version-sort | head -n1
822+
fi
802823
}
803824

804825
# Initializations that depend on previous functions.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2021 The Knative Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
function download_istio() {
18+
# Find the right arch so we can download the correct istioctl version
19+
case "${OSTYPE}" in
20+
darwin*) ARCH=osx ;;
21+
linux*) ARCH=linux-amd64 ;;
22+
msys*) ARCH=win ;;
23+
*) echo "** unknown OS '${OSTYPE}'" ; exit 1 ;;
24+
esac
25+
26+
# Download and unpack Istio
27+
ISTIO_VERSION=$1
28+
ISTIO_TARBALL=istio-${ISTIO_VERSION}-${ARCH}.tar.gz
29+
DOWNLOAD_URL=https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/${ISTIO_TARBALL}
30+
SYSTEM_NAMESPACE="${SYSTEM_NAMESPACE:-"knative-serving"}"
31+
32+
ISTIO_TMP=$(mktemp -d)
33+
pushd $ISTIO_TMP
34+
wget --no-check-certificate $DOWNLOAD_URL
35+
if [ $? != 0 ]; then
36+
echo "Failed to download Istio release: $DOWNLOAD_URL"
37+
exit 1
38+
fi
39+
tar xzf ${ISTIO_TARBALL}
40+
ISTIO_DIR="${ISTIO_TMP}/istio-${ISTIO_VERSION}"
41+
echo "Istio was downloaded to ${ISTIO_TMP}"
42+
popd
43+
}
44+
45+
function cleanup_istio() {
46+
echo "Deleting $ISTIO_TMP"
47+
rm -rf $ISTIO_TMP
48+
}

vendor/knative.dev/net-istio/third_party/istio-stable/install-istio.sh

+5-34
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,16 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# Find the right arch so we can download the correct istioctl version
18-
case "${OSTYPE}" in
19-
darwin*) ARCH=osx ;;
20-
linux*) ARCH=linux-amd64 ;;
21-
msys*) ARCH=win ;;
22-
*) echo "** unknown OS '${OSTYPE}'" ; exit 1 ;;
23-
esac
17+
source $(dirname $0)/../download-istio.sh
2418

25-
# Download and unpack Istio
26-
ISTIO_VERSION=1.7.6
27-
ISTIO_TARBALL=istio-${ISTIO_VERSION}-${ARCH}.tar.gz
28-
DOWNLOAD_URL=https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/${ISTIO_TARBALL}
29-
SYSTEM_NAMESPACE="${SYSTEM_NAMESPACE:-"knative-serving"}"
30-
31-
wget --no-check-certificate $DOWNLOAD_URL
32-
if [ $? != 0 ]; then
33-
echo "Failed to download Istio package"
34-
exit 1
35-
fi
36-
tar xzf ${ISTIO_TARBALL}
19+
# Download Istio
20+
download_istio 1.7.6
21+
trap cleanup_istio EXIT
3722

3823
# Install Istio
39-
./istio-${ISTIO_VERSION}/bin/istioctl install -f "$(dirname $0)/$1"
24+
${ISTIO_DIR}/bin/istioctl install -f "$(dirname $0)/$1"
4025

4126
# Enable mTLS STRICT in mesh mode
4227
if [[ $MESH -eq 1 ]]; then
4328
kubectl apply -f "$(dirname $0)/extra/global-mtls.yaml"
4429
fi
45-
46-
# Clean up
47-
rm -rf istio-${ISTIO_VERSION}
48-
rm ${ISTIO_TARBALL}
49-
50-
## Add in the `istio-system` namespace to reduce number of commands.
51-
#patch istio-crds.yaml namespace.yaml.patch
52-
#patch istio-ci-mesh.yaml namespace.yaml.patch
53-
#patch istio-ci-no-mesh.yaml namespace.yaml.patch
54-
#patch istio-minimal.yaml namespace.yaml.patch
55-
#
56-
## Increase termination drain duration seconds.
57-
#patch -l istio-ci-mesh.yaml drain-seconds.yaml.patch
58-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
Copyright 2020 The Knative Authors
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
https://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
// Package config exists to make the config directory importable.
15+
package config

vendor/modules.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,11 @@ gopkg.in/go-playground/webhooks.v3/github
268268
# gopkg.in/yaml.v2 v2.3.0
269269
## explicit
270270
gopkg.in/yaml.v2
271-
# knative.dev/hack v0.0.0-20210114150620-4422dcadb3c8
271+
# knative.dev/hack v0.0.0-20210120165453-8d623a0af457
272272
## explicit
273273
knative.dev/hack
274-
# knative.dev/net-istio v0.20.1-0.20210114170820-b4b1c95dc264
274+
# knative.dev/net-istio v0.20.1-0.20210121182253-79a9f7f6a067
275275
## explicit
276+
knative.dev/net-istio/third_party
276277
knative.dev/net-istio/third_party/istio-stable
277278
# go.opencensus.io => go.opencensus.io v0.20.2

0 commit comments

Comments
 (0)