Skip to content

Commit 943f726

Browse files
Merge pull request #18765 from hakman/hakman-nodeup-xz-migration
nodeup: make nodeup.xz the canonical release artifact
2 parents 9964dea + d052ee4 commit 943f726

643 files changed

Lines changed: 4168 additions & 5076 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,7 @@ version-dist-nodeup: version-dist-nodeup-amd64 version-dist-nodeup-arm64
613613

614614
version-dist-nodeup-amd64 version-dist-nodeup-arm64: version-dist-nodeup-%: nodeup-%
615615
mkdir -p ${UPLOAD}/kops/${VERSION}/linux/$*/
616-
cp -fp ${DIST}/linux/$*/nodeup ${UPLOAD}/kops/${VERSION}/linux/$*/nodeup
617-
tools/sha256 ${UPLOAD}/kops/${VERSION}/linux/$*/nodeup ${UPLOAD}/kops/${VERSION}/linux/$*/nodeup.sha256
616+
rm -f ${UPLOAD}/kops/${VERSION}/linux/$*/nodeup ${UPLOAD}/kops/${VERSION}/linux/$*/nodeup.sha256
618617
tools/xz.sh ${DIST}/linux/$*/nodeup ${UPLOAD}/kops/${VERSION}/linux/$*/nodeup.xz
619618
tools/sha256 ${UPLOAD}/kops/${VERSION}/linux/$*/nodeup.xz ${UPLOAD}/kops/${VERSION}/linux/$*/nodeup.xz.sha256
620619

cmd/kops/integration_test.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@ import (
4545
"k8s.io/kops/upup/pkg/fi/cloudup"
4646
)
4747

48-
// updateClusterTestBase is added automatically to the srcDir on all
49-
// tests using runTest, including runTestTerraformAWS, runTestTerraformGCE
50-
const updateClusterTestBase = "../../tests/integration/update_cluster/"
48+
const (
49+
// updateClusterTestBase is added automatically to the srcDir on all
50+
// tests using runTest, including runTestTerraformAWS, runTestTerraformGCE.
51+
updateClusterTestBase = "../../tests/integration/update_cluster/"
52+
53+
// integrationTestKopsVersion must remain pinned to a published release whose nodeup artifacts
54+
// are permanently available. Every integration runner that renders release assets must use it.
55+
integrationTestKopsVersion = "1.37.0-beta.1"
56+
)
5157

5258
type integrationTest struct {
5359
clusterName string
@@ -923,7 +929,7 @@ func (i *integrationTest) runTestTerraformAWS(t *testing.T) {
923929
h := testutils.NewIntegrationTestHarness(t)
924930
defer h.Close()
925931

926-
h.MockKopsVersion("1.34.0-beta.1")
932+
h.MockKopsVersion(integrationTestKopsVersion)
927933
h.SetupMockAWS()
928934

929935
i.runTest(t, ctx, h, "", "", nil)
@@ -936,7 +942,7 @@ func (i *integrationTest) runTestPhase(t *testing.T, phase cloudup.Phase) {
936942
h := testutils.NewIntegrationTestHarness(t)
937943
defer h.Close()
938944

939-
h.MockKopsVersion("1.34.0-beta.1")
945+
h.MockKopsVersion(integrationTestKopsVersion)
940946
h.SetupMockAWS()
941947
phaseName := string(phase)
942948
if phaseName == "" {
@@ -954,7 +960,7 @@ func (i *integrationTest) runTestTerraformGCE(t *testing.T) {
954960
h := testutils.NewIntegrationTestHarness(t)
955961
defer h.Close()
956962

957-
h.MockKopsVersion("1.34.0-beta.1")
963+
h.MockKopsVersion(integrationTestKopsVersion)
958964
h.SetupMockGCE()
959965

960966
i.runTest(t, ctx, h, "", "", nil)
@@ -970,7 +976,7 @@ func (i *integrationTest) runTestTerraformAzure(t *testing.T) {
970976
h := testutils.NewIntegrationTestHarness(t)
971977
defer h.Close()
972978

973-
h.MockKopsVersion("1.34.0-beta.1")
979+
h.MockKopsVersion(integrationTestKopsVersion)
974980
h.SetupMockAzure(i.clusterName)
975981

976982
var stdout bytes.Buffer
@@ -1047,7 +1053,7 @@ func (i *integrationTest) runTestTerraformHetzner(t *testing.T) {
10471053
h := testutils.NewIntegrationTestHarness(t)
10481054
defer h.Close()
10491055

1050-
h.MockKopsVersion("1.34.0-beta.1")
1056+
h.MockKopsVersion(integrationTestKopsVersion)
10511057

10521058
i.runTest(t, ctx, h, "", "", nil)
10531059
}
@@ -1065,7 +1071,7 @@ func (i *integrationTest) runTestTerraformScaleway(t *testing.T) {
10651071
h := testutils.NewIntegrationTestHarness(t)
10661072
defer h.Close()
10671073

1068-
h.MockKopsVersion("1.34.0-beta.1")
1074+
h.MockKopsVersion(integrationTestKopsVersion)
10691075

10701076
i.runTest(t, ctx, h, "", "", nil)
10711077
}

cmd/kops/lifecycle_integration_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ func runLifecycleTestAWS(o *LifecycleTestOptions) {
376376
h := testutils.NewIntegrationTestHarness(o.t)
377377
defer h.Close()
378378

379-
h.MockKopsVersion("1.34.0-beta.1")
379+
h.MockKopsVersion(integrationTestKopsVersion)
380380
cloud := h.SetupMockAWS()
381381

382382
var beforeIds []string
@@ -408,7 +408,7 @@ func runLifecycleTestOpenstack(o *LifecycleTestOptions) {
408408
h := testutils.NewIntegrationTestHarness(o.t)
409409
defer h.Close()
410410

411-
h.MockKopsVersion("1.34.0-beta.1")
411+
h.MockKopsVersion(integrationTestKopsVersion)
412412
cloud := testutils.SetupMockOpenstack()
413413

414414
var beforeIds []string
@@ -461,7 +461,7 @@ func runLifecycleTestGCE(o *LifecycleTestOptions) {
461461
h := testutils.NewIntegrationTestHarness(o.t)
462462
defer h.Close()
463463

464-
h.MockKopsVersion("1.34.0-beta.1")
464+
h.MockKopsVersion(integrationTestKopsVersion)
465465

466466
cloud := h.SetupMockGCE()
467467

hack/dev-build.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ KOPS_VERSION=$(kops version --short)
104104
KOPS_BASE_URL="http://${NODEUP_BUCKET}.s3.amazonaws.com/kops/${KOPS_VERSION}/"
105105

106106
echo "KOPS_BASE_URL=${KOPS_BASE_URL}"
107-
echo "NODEUP_URL=${KOPS_BASE_URL}linux/amd64/nodeup"
108107

109108
echo ==========
110109
echo "Deleting cluster ${CLUSTER_NAME}. Elle est finie."
@@ -118,7 +117,7 @@ kops delete cluster \
118117
echo ==========
119118
echo "Creating cluster ${CLUSTER_NAME}"
120119

121-
kops_command="NODEUP_URL=${KOPS_BASE_URL}linux/amd64/nodeup KOPS_BASE_URL=${KOPS_BASE_URL} kops create cluster --name $CLUSTER_NAME --state $KOPS_STATE_STORE --node-count $NODE_COUNT --zones $NODE_ZONES --master-zones $MASTER_ZONES --node-size $NODE_SIZE --master-size $MASTER_SIZE -v $VERBOSITY --image $IMAGE --channel alpha --topology $TOPOLOGY --networking $NETWORKING"
120+
kops_command="KOPS_BASE_URL=${KOPS_BASE_URL} kops create cluster --name $CLUSTER_NAME --state $KOPS_STATE_STORE --node-count $NODE_COUNT --zones $NODE_ZONES --master-zones $MASTER_ZONES --node-size $NODE_SIZE --master-size $MASTER_SIZE -v $VERBOSITY --image $IMAGE --channel alpha --topology $TOPOLOGY --networking $NETWORKING"
122121

123122
if [[ $TOPOLOGY == "private" ]]; then
124123
kops_command+=" --bastion='true'"

hack/release-assets.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@ declare -A BINARIES=(
3030
["linux/amd64/kops"]="kops-linux-amd64"
3131
["linux/arm64/kops"]="kops-linux-arm64"
3232
["windows/amd64/kops.exe"]="kops-windows-amd64"
33-
["linux/amd64/nodeup"]="nodeup-linux-amd64"
34-
["linux/arm64/nodeup"]="nodeup-linux-arm64"
3533
)
3634

3735
# Binaries that only some kOps releases ship: source-path -> github-name.
38-
# channels was dropped from releases in kOps 1.36 and protokube in kOps 1.37,
39-
# while nodeup.xz was added in kOps 1.37. The scripts still promote and validate older versions.
36+
# channels was dropped from releases in kOps 1.36, protokube in kOps 1.37, and
37+
# uncompressed nodeup after kOps 1.37.0-beta.1. nodeup.xz was added in that release.
4038
declare -A OPTIONAL_BINARIES=(
4139
["linux/amd64/channels"]="channels-linux-amd64"
4240
["linux/arm64/channels"]="channels-linux-arm64"
4341
["linux/amd64/protokube"]="protokube-linux-amd64"
4442
["linux/arm64/protokube"]="protokube-linux-arm64"
43+
["linux/amd64/nodeup"]="nodeup-linux-amd64"
44+
["linux/arm64/nodeup"]="nodeup-linux-arm64"
4545
["linux/amd64/nodeup.xz"]="nodeup-linux-amd64.xz"
4646
["linux/arm64/nodeup.xz"]="nodeup-linux-arm64.xz"
4747
)
4848

4949
# add_optional_binaries <version>: append the optional binaries that exist upstream for
50-
# the given version to BINARIES, so releases that ship them keep full coverage.
50+
# the given version to BINARIES, so releases keep full coverage without version-specific logic.
5151
# Only a confirmed 404 counts as absent; any other probe outcome fails the script,
5252
# so a transient error cannot silently drop an artifact from promotion or validation.
5353
add_optional_binaries() {

hack/set-version

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,20 @@ KOPS_CI_VERSION=`grep 'KOPS_CI_VERSION\s*=' kops-version.go | awk '{print $3}'
5656
echo "KOPS_RELEASE_VERSION ${KOPS_RELEASE_VERSION} -> ${NEW_RELEASE_VERSION}"
5757
echo "KOPS_CI_VERSION ${KOPS_CI_VERSION} -> ${NEW_CI_VERSION}"
5858

59-
sed -i.bak -e "s@${KOPS_RELEASE_VERSION}@${NEW_RELEASE_VERSION}@g" pkg/nodemodel/wellknownassets/kopsassets_test.go
60-
61-
git grep -l registry.k8s.io/kops/dns-controller | xargs -I {} sed -i.bak -e "s@dns-controller:${KOPS_RELEASE_VERSION}@dns-controller:${NEW_RELEASE_VERSION}@g" {}
59+
# Only rewrite goldens that intentionally track the current release. Integration fixtures pin
60+
# published kOps versions so their external assets remain available and reproducible.
61+
RELEASE_GOLDEN_PATHS=(
62+
pkg/model/components
63+
upup/pkg/fi/cloudup/tests/bootstrapchannelbuilder
64+
)
65+
66+
git grep -l "registry.k8s.io/kops/dns-controller:${KOPS_RELEASE_VERSION}" -- "${RELEASE_GOLDEN_PATHS[@]}" | xargs -I {} sed -i.bak -e "s@dns-controller:${KOPS_RELEASE_VERSION}@dns-controller:${NEW_RELEASE_VERSION}@g" {}
6267
git grep -l "version..v${KOPS_RELEASE_VERSION}" upup/models/cloudup/resources/addons/dns-controller.addons.k8s.io/ | xargs -I {} sed -i.bak -e "s@version: v${KOPS_RELEASE_VERSION}@version: v${NEW_RELEASE_VERSION}@g" {}
6368

64-
git grep -l registry.k8s.io/kops/kops-controller | xargs -I {} sed -i.bak -e "s@kops-controller:${KOPS_RELEASE_VERSION}@kops-controller:${NEW_RELEASE_VERSION}@g" {}
69+
git grep -l "registry.k8s.io/kops/kops-controller:${KOPS_RELEASE_VERSION}" -- "${RELEASE_GOLDEN_PATHS[@]}" | xargs -I {} sed -i.bak -e "s@kops-controller:${KOPS_RELEASE_VERSION}@kops-controller:${NEW_RELEASE_VERSION}@g" {}
6570
git grep -l "version..v${KOPS_RELEASE_VERSION}" upup/models/cloudup/resources/addons/kops-controller.addons.k8s.io/ | xargs -I {} sed -i.bak -e "s@version: v${KOPS_RELEASE_VERSION}@version: v${NEW_RELEASE_VERSION}@g" {}
6671

67-
git grep -l registry.k8s.io/kops/kube-apiserver-healthcheck | xargs -I {} sed -i.bak -e "s@kube-apiserver-healthcheck:${KOPS_RELEASE_VERSION}@kube-apiserver-healthcheck:${NEW_RELEASE_VERSION}@g" {}
72+
git grep -l "registry.k8s.io/kops/kube-apiserver-healthcheck:${KOPS_RELEASE_VERSION}" -- "${RELEASE_GOLDEN_PATHS[@]}" | xargs -I {} sed -i.bak -e "s@kube-apiserver-healthcheck:${KOPS_RELEASE_VERSION}@kube-apiserver-healthcheck:${NEW_RELEASE_VERSION}@g" {}
6873

6974
git grep -l "version..${KOPS_RELEASE_VERSION}" upup/pkg/fi/cloudup/tests/bootstrapchannelbuilder/ | xargs -I {} sed -i.bak -e "s@version: ${KOPS_RELEASE_VERSION}@version: ${NEW_RELEASE_VERSION}@g" {}
7075

pkg/assets/builder.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,6 @@ func (a *AssetBuilder) RemapImage(image string) string {
313313
return image + "@" + digest
314314
}
315315

316-
// HasFileRepository reports whether a file repository is configured for asset mirroring.
317-
func (a *AssetBuilder) HasFileRepository() bool {
318-
return a.assetsLocation != nil && a.assetsLocation.FileRepository != nil
319-
}
320-
321316
// RemapFile returns a remapped URL for the file, if AssetsLocation is defined.
322317
// It is returns in a FileAsset, alongside the SHA hash of the file.
323318
// The SHA hash is is knownHash is provided, and otherwise will be found first by

pkg/model/bootstrapscript_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ func TestBootstrapUserData(t *testing.T) {
181181
NodeUpConfigBuilder: &nodeupConfigBuilder{cluster: cluster},
182182
NodeUpAssets: map[architectures.Architecture]*assets.MirroredAsset{
183183
architectures.ArchitectureAmd64: {
184-
Locations: []string{"nodeup-amd64-1", "nodeup-amd64-2"},
184+
Locations: []string{"nodeup-amd64-1.xz", "nodeup-amd64-2.xz"},
185185
Hash: hashing.MustFromString("833723369ad345a88dd85d61b1e77336d56e61b864557ded71b92b6e34158e6a"),
186186
},
187187
architectures.ArchitectureArm64: {
188-
Locations: []string{"nodeup-arm64-1", "nodeup-arm64-2"},
188+
Locations: []string{"nodeup-arm64-1.xz", "nodeup-arm64-2.xz"},
189189
Hash: hashing.MustFromString("e525c28a65ff0ce4f95f9e730195b4e67fdcb15ceb1f36b5ad6921a8a4490c71"),
190190
},
191191
},

pkg/model/openstackmodel/servergroup_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,11 +1577,11 @@ func RunGoldenTest(t *testing.T, basedir string, testCase serverGroupModelBuilde
15771577
NodeUpConfigBuilder: &nodeupConfigBuilder{},
15781578
NodeUpAssets: map[architectures.Architecture]*assets.MirroredAsset{
15791579
architectures.ArchitectureAmd64: {
1580-
Locations: []string{"nodeup-amd64-1", "nodeup-amd64-2"},
1580+
Locations: []string{"nodeup-amd64-1.xz", "nodeup-amd64-2.xz"},
15811581
Hash: hashing.MustFromString("833723369ad345a88dd85d61b1e77336d56e61b864557ded71b92b6e34158e6a"),
15821582
},
15831583
architectures.ArchitectureArm64: {
1584-
Locations: []string{"nodeup-arm64-1", "nodeup-arm64-2"},
1584+
Locations: []string{"nodeup-arm64-1.xz", "nodeup-arm64-2.xz"},
15851585
Hash: hashing.MustFromString("e525c28a65ff0ce4f95f9e730195b4e67fdcb15ceb1f36b5ad6921a8a4490c71"),
15861586
},
15871587
},

pkg/model/resources/nodeup.go

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,18 @@ json-field() {
9191
}
9292
{{- end }}
9393
94-
# Retry a download until we get it. sha covers the uncompressed binary. args: name, sha, urls
94+
# Retry until a compressed archive is downloaded, validated, and decompressed. args: name, sha, urls
9595
download-or-bust() {
9696
echo "== Downloading $1 with hash $2 from $3 =="
9797
local -r file="$1"
9898
local -r hash="$2"
9999
local -a urls
100100
IFS=, read -r -a urls <<< "$3"
101101
102-
if [[ -f "${file}" ]]; then
103-
if ! validate-hash "${file}" "${hash}"; then
104-
rm -f "${file}"
105-
else
106-
return 0
107-
fi
108-
fi
109-
110102
while true; do
111103
for url in "${urls[@]}"; do
112-
echo "== Downloading ${url}.xz =="
104+
echo "== Downloading ${url} =="
105+
rm -f "${file}.xz"
113106
{{- if UseGCSDownload }}
114107
local response token
115108
# Use the IP of the metadata server, to not depend on DNS this early in boot
@@ -118,8 +111,8 @@ download-or-bust() {
118111
elif ! token=$(json-field "${response}" access_token); then
119112
echo "== Failed to parse the service account token =="
120113
# Pass the token through stdin so it does not appear in files, logs, or process arguments.
121-
elif ! echo "Authorization: Bearer ${token}" | curl -f -Lo "${file}.xz" --connect-timeout 20 --retry 6 --retry-delay 10 -H @- "https://storage.googleapis.com/${url#gs://}.xz"; then
122-
echo "== Failed to download ${url}.xz =="
114+
elif ! echo "Authorization: Bearer ${token}" | curl -f -Lo "${file}.xz" --connect-timeout 20 --retry 6 --retry-delay 10 -H @- "https://storage.googleapis.com/${url#gs://}"; then
115+
echo "== Failed to download ${url} =="
123116
rm -f "${file}.xz"
124117
{{- else if UseBlobDownload }}
125118
local rest account response token
@@ -135,8 +128,8 @@ download-or-bust() {
135128
# Pass the token through stdin so it does not appear in files, logs, or process arguments.
136129
elif ! printf 'Authorization: Bearer %s\nx-ms-version: 2017-11-09\n' "${token}" |
137130
curl -f -Lo "${file}.xz" --connect-timeout 20 --retry 6 --retry-delay 10 -H @- \
138-
"https://${account}.blob.core.windows.net/${rest}.xz"; then
139-
echo "== Failed to download ${url}.xz =="
131+
"https://${account}.blob.core.windows.net/${rest}"; then
132+
echo "== Failed to download ${url} =="
140133
rm -f "${file}.xz"
141134
{{- else if UseS3Download }}
142135
local imds_token profile creds access_key secret_key session_token
@@ -153,22 +146,25 @@ download-or-bust() {
153146
elif ! printf 'user "%s:%s"\nheader "x-amz-security-token: %s"\n' "${access_key}" "${secret_key}" "${session_token}" |
154147
curl -f -Lo "${file}.xz" --connect-timeout 20 --retry 6 --retry-delay 10 \
155148
--config - --aws-sigv4 "aws:amz:{{ S3Region }}:s3" \
156-
"https://s3.{{ S3Region }}.amazonaws.com/${url#s3://}.xz"; then
157-
echo "== Failed to download ${url}.xz =="
149+
"https://s3.{{ S3Region }}.amazonaws.com/${url#s3://}"; then
150+
echo "== Failed to download ${url} =="
158151
rm -f "${file}.xz"
159152
{{- else }}
160-
if ! curl -f -Lo "${file}.xz" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}.xz"; then
161-
echo "== Failed to download ${url}.xz =="
153+
if ! curl -f -Lo "${file}.xz" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then
154+
echo "== Failed to download ${url} =="
162155
rm -f "${file}.xz"
163156
{{- end }}
164-
elif ! xz -d "${file}.xz"; then
165-
echo "== Failed to decompress ${url}.xz =="
157+
elif ! validate-hash "${file}.xz" "${hash}"; then
158+
echo "== Failed to validate compressed hash for ${url} =="
159+
rm -f "${file}.xz"
160+
elif ! xz -df "${file}.xz"; then
161+
echo "== Failed to decompress ${url} =="
166162
rm -f "${file}" "${file}.xz"
167-
elif ! validate-hash "${file}" "${hash}"; then
168-
echo "== Failed to validate decompressed hash for ${url}.xz =="
163+
elif ! chmod +x "${file}"; then
164+
echo "== Failed to make ${file} executable =="
169165
rm -f "${file}"
170166
else
171-
echo "== Downloaded ${url}.xz and validated decompressed hash ${hash} =="
167+
echo "== Downloaded ${url}, validated hash ${hash} and decompressed =="
172168
return 0
173169
fi
174170
done
@@ -209,8 +205,6 @@ function download-release() {
209205
cd ${INSTALL_DIR}/bin
210206
download-or-bust nodeup "${NODEUP_HASH}" "${NODEUP_URL}"
211207
212-
chmod +x nodeup
213-
214208
echo "== Running nodeup =="
215209
# We can't run in the foreground because of https://github.com/docker/docker/issues/23793
216210
( cd ${INSTALL_DIR}/bin; ./nodeup --install-systemd-unit --conf=${INSTALL_DIR}/conf/kube_env.yaml --v=8 )

0 commit comments

Comments
 (0)