Skip to content

Commit aed5ffd

Browse files
authored
Merge pull request kubernetes#94449 from justaugustus/go115
[go1.15] Update to go1.15.2
2 parents a464854 + bdadb2a commit aed5ffd

File tree

16 files changed

+157
-145
lines changed

16 files changed

+157
-145
lines changed

build/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ filegroup(
155155
srcs = select(for_platforms(
156156
for_server = [
157157
"//cmd/kubemark",
158-
"//test/e2e_node:e2e_node.test_binary",
158+
"//test/e2e_node:e2e_node.test",
159159
],
160160
for_test = [
161161
"//cmd/gendocs",
@@ -164,7 +164,7 @@ filegroup(
164164
"//cmd/genswaggertypedocs",
165165
"//cmd/genyaml",
166166
"//cmd/linkcheck",
167-
"//test/e2e:e2e.test_binary",
167+
"//test/e2e:e2e.test",
168168
"//vendor/github.com/onsi/ginkgo/ginkgo",
169169
"//cluster/images/conformance/go-runner",
170170
],

build/build-image/cross/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.15.0-1
1+
v1.15.2-1

build/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ readonly KUBE_CONTAINER_RSYNC_PORT=8730
9494
# $1 - server architecture
9595
kube::build::get_docker_wrapped_binaries() {
9696
local debian_iptables_version=v12.1.2
97-
local go_runner_version=buster-v2.0.0
97+
local go_runner_version=buster-v2.0.1
9898
### If you change any of these lists, please also update DOCKERIZED_BINARIES
9999
### in build/BUILD. And kube::golang::server_image_targets
100100
local targets=(

build/dependencies.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies:
1717

1818
# Bazel
1919
- name: "repo-infra"
20-
version: 0.0.12
20+
version: 0.1.1
2121
refPaths:
2222
- path: build/root/WORKSPACE
2323
match: strip_prefix = "repo-infra-\d+.\d+.\d+"
@@ -99,16 +99,18 @@ dependencies:
9999

100100
# Golang
101101
- name: "golang: upstream version"
102-
version: 1.15
102+
version: 1.15.2
103103
refPaths:
104104
- path: build/build-image/cross/VERSION
105105
- path: build/root/WORKSPACE
106106
match: (override_)?go_version = "\d+.\d+(alpha|beta|rc)?\.?\d+"
107107
- path: test/images/Makefile
108108
match: GOLANG_VERSION=\d+.\d+(alpha|beta|rc)?\.?\d+
109+
- path: staging/publishing/rules.yaml
110+
match: 'default-go-version\: \d+.\d+(alpha|beta|rc)?\.?(\d+)?'
109111

110112
- name: "k8s.gcr.io/kube-cross: dependents"
111-
version: v1.15.0-1
113+
version: v1.15.2-1
112114
refPaths:
113115
- path: build/build-image/cross/VERSION
114116
- path: test/images/sample-apiserver/Dockerfile
@@ -142,7 +144,7 @@ dependencies:
142144
match: configs\[DebianIptables\] = Config{buildImageRegistry, "debian-iptables", "v\d+\.\d+.\d+"}
143145

144146
- name: "k8s.gcr.io/go-runner: dependents"
145-
version: buster-v2.0.0
147+
version: buster-v2.0.1
146148
refPaths:
147149
- path: build/common.sh
148150
match: go_runner_version=

build/go.bzl

Lines changed: 78 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -12,92 +12,100 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test")
15+
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_context", "go_test")
16+
load("@io_bazel_rules_go//go/platform:list.bzl", "GOOS_GOARCH")
1617

17-
# Defines several go_binary rules to work around a Bazel issue which makes
18-
# the pure attribute on go_binary not configurable.
19-
# The name provided will have cgo enabled if targeting Linux, and will
20-
# be a pure go binary otherwise. Additionally, if targeting Windows, the
21-
# output filename will have a .exe suffix.
22-
def go_binary_conditional_pure(name, tags = None, **kwargs):
23-
tags = tags or []
24-
tags.append("manual")
18+
# Defines a go_binary rule that enables cgo on platform builds targeting Linux,
19+
# and otherwise builds a pure go binary.
20+
def go_binary_conditional_pure(name, tags = [], **kwargs):
2521
go_binary(
26-
name = "_%s-cgo" % name,
27-
out = name,
28-
pure = "off",
29-
tags = tags,
30-
**kwargs
31-
)
32-
33-
# Define a rule for both Unix and Windows exe suffixes.
34-
[go_binary(
35-
name = "_%s-pure" % out,
36-
out = out,
37-
pure = "on",
38-
tags = tags,
39-
**kwargs
40-
) for out in [name, name + ".exe"]]
41-
42-
# The real magic, where we work around the pure attribute not being
43-
# configurable: select the appropriate go_binary rule above based on the
44-
# configured platform.
45-
native.alias(
4622
name = name,
47-
actual = select({
48-
"@io_bazel_rules_go//go/platform:linux": ":_%s-cgo" % name,
49-
"@io_bazel_rules_go//go/platform:windows": ":_%s.exe-pure" % name,
50-
"//conditions:default": ":_%s-pure" % name,
23+
pure = select({
24+
"@io_bazel_rules_go//go/platform:linux": "off",
25+
"//conditions:default": "on",
5126
}),
27+
tags = ["manual"] + tags,
28+
**kwargs
5229
)
5330

54-
# Defines several go_test rules to work around a Bazel issue which makes
55-
# the pure attribute on go_test not configurable.
56-
# This also defines genrules to produce test binaries named ${out} and
57-
# ${out}.exe, and an alias named ${out}_binary which automatically selects
58-
# the correct filename suffix (i.e. with a .exe on Windows).
59-
def go_test_conditional_pure(name, out, tags = None, **kwargs):
60-
tags = tags or []
31+
# Defines a go_test rule that enables cgo on platform builds targeting Linux,
32+
# and otherwise builds a pure go binary.
33+
def go_test_conditional_pure(name, out, tags = [], **kwargs):
6134
tags.append("manual")
6235

6336
go_test(
64-
name = "_%s-cgo" % name,
65-
pure = "off",
66-
testonly = False,
67-
tags = tags,
68-
**kwargs
69-
)
70-
71-
go_test(
72-
name = "_%s-pure" % name,
73-
pure = "on",
37+
name = out,
38+
pure = select({
39+
"@io_bazel_rules_go//go/platform:linux": "off",
40+
"//conditions:default": "on",
41+
}),
7442
testonly = False,
7543
tags = tags,
7644
**kwargs
7745
)
7846

7947
native.alias(
80-
name = name,
81-
actual = select({
82-
"@io_bazel_rules_go//go/platform:linux": ":_%s-cgo" % name,
83-
"//conditions:default": ":_%s-pure" % name,
84-
}),
48+
name = "name",
49+
actual = out,
8550
)
8651

87-
[native.genrule(
88-
name = "gen_%s" % o,
89-
srcs = [name],
90-
outs = [o],
91-
cmd = "cp $< $@;",
92-
output_to_bindir = True,
93-
executable = True,
94-
tags = tags,
95-
) for o in [out, out + ".exe"]]
52+
_GO_BUILD_MODE_TMPL = "{goos}/{goarch}/pure={pure},static={static},msan={msan},race={race}\n"
9653

97-
native.alias(
98-
name = "%s_binary" % out,
99-
actual = select({
100-
"@io_bazel_rules_go//go/platform:windows": ":gen_%s.exe" % out,
101-
"//conditions:default": ":gen_%s" % out,
102-
}),
54+
def _go_build_mode_aspect_impl(target, ctx):
55+
if (not hasattr(ctx.rule.attr, "_is_executable") or
56+
not ctx.rule.attr._is_executable or
57+
ctx.rule.attr.testonly):
58+
# We only care about exporting platform info for executable targets
59+
# that aren't testonly (e.g. kubectl and e2e.test).
60+
return []
61+
62+
mode = go_context(ctx).mode
63+
64+
out = ctx.actions.declare_file(
65+
target.files_to_run.executable.basename + ".go_build_mode",
66+
sibling = target.files_to_run.executable,
10367
)
68+
ctx.actions.write(out, _GO_BUILD_MODE_TMPL.format(
69+
goos = mode.goos,
70+
goarch = mode.goarch,
71+
pure = str(mode.pure).lower(),
72+
static = str(mode.static).lower(),
73+
msan = str(mode.msan).lower(),
74+
race = str(mode.race).lower(),
75+
))
76+
77+
return [OutputGroupInfo(default = depset([out]))]
78+
79+
# This aspect ouputs a *.go_build_mode metadata for go binaries. This metadata
80+
# is used for executable selection e.g. in CI.
81+
go_build_mode_aspect = aspect(
82+
implementation = _go_build_mode_aspect_impl,
83+
attrs = {
84+
"goos": attr.string(
85+
default = "auto",
86+
values = ["auto"] + {goos: None for goos, _ in GOOS_GOARCH}.keys(),
87+
),
88+
"goarch": attr.string(
89+
default = "auto",
90+
values = ["auto"] + {goarch: None for _, goarch in GOOS_GOARCH}.keys(),
91+
),
92+
"pure": attr.string(
93+
default = "auto",
94+
values = ["auto", "on", "off"],
95+
),
96+
"static": attr.string(
97+
default = "auto",
98+
values = ["auto", "on", "off"],
99+
),
100+
"msan": attr.string(
101+
default = "auto",
102+
values = ["auto", "on", "off"],
103+
),
104+
"race": attr.string(
105+
default = "auto",
106+
values = ["auto", "on", "off"],
107+
),
108+
"_go_context_data": attr.label(default = "@io_bazel_rules_go//:go_context_data"),
109+
},
110+
toolchains = ["@io_bazel_rules_go//go:toolchain"],
111+
)

build/root/.bazelrc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ build --define gotags=selinux
2222
# This flag requires Bazel 0.5.0+
2323
build --sandbox_fake_username
2424

25+
# Output go_build_mode metadata for binaries. This metadata is used for
26+
# executable selection e.g. in CI.
27+
build --aspects //build:go.bzl%go_build_mode_aspect
28+
2529
# Enable go race detection.
26-
build:unit --features=race
27-
test:unit --features=race
30+
build:unit --@io_bazel_rules_go//go/config:race
31+
test:unit --@io_bazel_rules_go//go/config:race
2832

2933
test:unit --build_tests_only
3034
test:unit --test_tag_filters=-e2e,-integration

build/root/WORKSPACE

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ load("//build:workspace_mirror.bzl", "mirror")
55

66
http_archive(
77
name = "io_k8s_repo_infra",
8-
strip_prefix = "repo-infra-0.0.12",
9-
sha256 = "e309a655a5b04fd76b6e950b3371aa8636bb929f2860a7ec22fa9b4b0b7c8236",
8+
strip_prefix = "repo-infra-0.1.1",
9+
sha256 = "6c916da43b701e2947f147f3791b3355d8a342dd6cb81887b7d6db184879e387",
1010
urls = [
11-
"https://github.com/kubernetes/repo-infra/archive/v0.0.12.tar.gz",
11+
"https://github.com/kubernetes/repo-infra/archive/v0.1.1.tar.gz",
1212
],
1313
)
1414

@@ -23,7 +23,7 @@ load("@io_k8s_repo_infra//:repos.bzl", repo_infra_configure = "configure", repo_
2323
# 'override_go_version': used to specify an alternate go version provided
2424
# by kubernetes/repo-infra
2525
repo_infra_configure(
26-
go_version = "1.15",
26+
go_version = "1.15.2",
2727
minimum_bazel_version = "2.2.0",
2828
)
2929

build/workspace.bzl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ _DEBIAN_IPTABLES_DIGEST = {
102102
# Use skopeo to find these values: https://github.com/containers/skopeo
103103
#
104104
# Example
105-
# Manifest: skopeo inspect docker://gcr.io/k8s-staging-build-image/go-runner:buster-v2.0.0
106-
# Arches: skopeo inspect --raw docker://gcr.io/k8s-staging-build-image/go-runner:buster-v2.0.0
105+
# Manifest: skopeo inspect docker://gcr.io/k8s-staging-build-image/go-runner:buster-v2.0.1
106+
# Arches: skopeo inspect --raw docker://gcr.io/k8s-staging-build-image/go-runner:buster-v2.0.1
107107
_GO_RUNNER_DIGEST = {
108-
"manifest": "sha256:ff6e2f3683e7d284674ed18341fc898060204e8c43c9b477e13c6f7faf3e66d4",
109-
"amd64": "sha256:140404aed601b95a2a0a1aeac0608a0fdbd5fc339a8ea6b2ee4a63c7e1f56415",
110-
"arm": "sha256:5d4e8c77bc472610e7e46bbd2b83e167e243434b8287ba2ffe6b09aba9f08ecc",
111-
"arm64": "sha256:62429a05973522064480deb44134e3ca355ee89c7781f3fc3ee9072f17de0085",
112-
"ppc64le": "sha256:05c8575486ccea90c35e8d8ba28c84aee57a03d58329b1354cf7193c372d2de2",
113-
"s390x": "sha256:e886ab4557e60293081f2e47a5b52e84bd3d60290a0f46fb99fac6eec35479ec",
108+
"manifest": "sha256:687c17db2f5cd4aea13faa7ae56bee639a5b11f380c431a9800205624f53541c",
109+
"amd64": "sha256:b02bdb3444b1e7fb14cb5b60174f0e8f0a087ff4c294352e6c31c17da99a4ee2",
110+
"arm": "sha256:0d7563c814c0cd88bc5937b6e606d266409b5b7cee2deb6c04c6dcb6d7daaa5d",
111+
"arm64": "sha256:78f42645ddfd2ab9dfc4053834aa0042c82c8c550f9f61a2a76fd9f1791e5308",
112+
"ppc64le": "sha256:93e3ca63df801a5c1ad15bdbb9c50fa38e5db3479a92d8f4516c00dfd736f227",
113+
"s390x": "sha256:d7ed7bd8d58a6570504f14a50d502c2df97f944378f9f5306519f3379cb92fe2",
114114
}
115115

116116
def _digest(d, arch):
@@ -127,7 +127,7 @@ def image_dependencies():
127127
digest = _digest(_GO_RUNNER_DIGEST, arch),
128128
registry = "k8s.gcr.io/build-image",
129129
repository = "go-runner",
130-
tag = "buster-v2.0.0", # ignored, but kept here for documentation
130+
tag = "buster-v2.0.1", # ignored, but kept here for documentation
131131
)
132132

133133
container_pull(

cluster/images/conformance/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ container_layer(
1515
files = [
1616
"//cluster/images/conformance/go-runner",
1717
"//cmd/kubectl",
18-
"//test/e2e:e2e.test_binary",
18+
"//test/e2e:e2e.test",
1919
"//vendor/github.com/onsi/ginkgo/ginkgo",
2020
],
2121
)

hack/lib/util.sh

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,25 @@ kube::util::find-binary-for-platform() {
207207
"${KUBE_ROOT}/_output/dockerized/go/bin/${lookfor}"
208208
);
209209
fi
210-
# Also search for binary in bazel build tree.
211-
# The bazel go rules place some binaries in subtrees like
212-
# "bazel-bin/source/path/linux_amd64_pure_stripped/binaryname", so make sure
213-
# the platform name is matched in the path.
214-
while IFS=$'\n' read -r location; do
215-
locations+=("$location");
216-
done < <(find "${KUBE_ROOT}/bazel-bin/" -type f -executable \
217-
\( -path "*/${platform/\//_}*/${lookfor}" -o -path "*/${lookfor}" \) 2>/dev/null || true)
218-
# search for executables for non-GNU versions of find (eg. BSD)
219-
while IFS=$'\n' read -r location; do
220-
locations+=("$location");
221-
done < <(find "${KUBE_ROOT}/bazel-bin/" -type f -perm -111 \
222-
\( -path "*/${platform/\//_}*/${lookfor}" -o -path "*/${lookfor}" \) 2>/dev/null || true)
210+
211+
# Also search for binary in bazel build tree if bazel-out/ exists.
212+
if [[ -d "${KUBE_ROOT}/bazel-out" ]]; then
213+
while IFS=$'\n' read -r bin_build_mode; do
214+
if grep -q "${platform}" "${bin_build_mode}"; then
215+
# drop the extension to get the real binary path.
216+
locations+=("${bin_build_mode%.*}")
217+
fi
218+
done < <(find "${KUBE_ROOT}/bazel-out/" -name "${lookfor}.go_build_mode")
219+
fi
223220

224221
# List most recently-updated location.
225222
local -r bin=$( (ls -t "${locations[@]}" 2>/dev/null || true) | head -1 )
223+
224+
if [[ -z "${bin}" ]]; then
225+
kube::log::error "Failed to find binary ${lookfor} for platform ${platform}"
226+
return 1
227+
fi
228+
226229
echo -n "${bin}"
227230
}
228231

@@ -242,11 +245,6 @@ kube::util::gen-docs() {
242245
genkubedocs=$(kube::util::find-binary "genkubedocs")
243246
genman=$(kube::util::find-binary "genman")
244247
genyaml=$(kube::util::find-binary "genyaml")
245-
genfeddocs=$(kube::util::find-binary "genfeddocs")
246-
247-
# TODO: If ${genfeddocs} is not used from anywhere (it isn't used at
248-
# least from k/k tree), remove it completely.
249-
kube::util::sourced_variable "${genfeddocs}"
250248

251249
mkdir -p "${dest}/docs/user-guide/kubectl/"
252250
"${gendocs}" "${dest}/docs/user-guide/kubectl/"
@@ -764,7 +762,7 @@ function kube::util::check-file-in-alphabetical-order {
764762
# Checks whether jq is installed.
765763
function kube::util::require-jq {
766764
if ! command -v jq &>/dev/null; then
767-
echo "jq not found. Please install." 1>&2
765+
kube::log::error "jq not found. Please install."
768766
return 1
769767
fi
770768
}

0 commit comments

Comments
 (0)