Commit Graph

346 Commits

Author SHA1 Message Date
Tim Hockin
7c262b901f
Set GOCACHE and GOMODCACHE
If these are not set, set them.  This ensures that any subsequent
scripts we call (which may call setup_env again) use the same values.
2023-01-21 11:16:14 -08:00
Sascha Grunert
8a96ed0d20
Link kubectl-convert binary statically
The kubectl-convert binary itself only depends on the following runtime
libraries when linking dynamically:

```
> ldd _output/bin/kubectl-convert
        linux-vdso.so.1 (0x00007ffef0786000)
        libpthread.so.0 => /nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib/libpthread.so.0 (0x00007f5f4ac25000)
        libdl.so.2 => /nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib/libdl.so.2 (0x00007f5f4ac20000)
        libc.so.6 => /nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib/libc.so.6 (0x00007f5f4aa00000)
        /nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib/ld-linux-x86-64.so.2 => /nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib64/ld-linux-x86-64.so.2 (0x00007f5f4ac2c000)
```

We now move kubectl-convert to become a static binary as well to achieve
maximum portability.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-12-01 11:23:26 +01:00
Benjamin Elder
db9c760ee7 remove clearly unnecessary lingering BUILD file references 2022-10-04 16:47:25 -07:00
Davanum Srinivas
866ef3c46e
run hack/update-vendor.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-09-24 13:27:13 -04:00
Davanum Srinivas
a2408f39c7
[golang] Fix things commented out in 1.19rc2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-08-04 10:27:09 -04:00
Davanum Srinivas
4784b58e17
golang: Update to 1.19rc2 from 1.18.3
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-07-26 13:14:05 -04:00
Kubernetes Prow Robot
a0fe0d6b37
Merge pull request #111131 from thockin/coverage-handle-relative-paths
Make coverage handle relative-path pkgs
2022-07-15 02:26:25 -07:00
Kubernetes Prow Robot
7e2c02d4c8
Merge pull request #111133 from thockin/comment-build_binaries_for_platform
Add comment on build_binaries_for_platform
2022-07-14 16:26:47 -07:00
Kubernetes Prow Robot
08117cdd76
Merge pull request #111132 from thockin/remove-unused-platform-envs-func
Remove unused `unset_platform_envs` func
2022-07-14 16:26:36 -07:00
Tim Hockin
8461a645d6 Add comment on build_binaries_for_platform 2022-07-13 20:33:32 -07:00
Tim Hockin
4b8e3a0b54 Remove unused unset_platform_envs func 2022-07-13 20:33:24 -07:00
Tim Hockin
15cab6d085 Make coverage handle relative-path pkgs 2022-07-13 20:33:12 -07:00
Tim Hockin
0863919807 Add comments around go install 2022-07-13 20:33:03 -07:00
Patrick Ohly
f7427d07e0 build: add ginkgo aliases for WHAT
The alias for vendor/github.com/onsi/ginkgo/ginkgo ensures that code like
30e99cb2a9/experiment/kind-conformance-image-e2e.sh (L110)
continues to work. The one without "vendor/" is there just in case that it
was used because it also worked.

Long term, "ginkgo" is a nicer, version independent alias. It gets used
internally to avoid future churn and gets documented also publicly in the
Makefile help.

The caveat is that there's no guarantee that a future v3 CLI will be compatible
with current invocations. But the most common usage is through
hack/ginkgo-e2e.sh, which can deal with such differences.
2022-07-08 10:46:11 +08:00
Dave Chen
375b2a5fb2 Build Ginkgo binary
Signed-off-by: Dave Chen <dave.chen@arm.com>
2022-07-08 10:46:11 +08:00
Hemant Kumar
86cd654371 We need to all all=-N -l because some objects are being optimzied away
Without all=-N -l, some objects are being optimized away and
impossible to debug
2022-06-13 14:31:37 -04:00
Hemant Kumar
bfe34ab224 Disable trimpath in debug mode
This allows remote debugging with debuggers like vscode and Goland
2022-06-12 07:53:18 -04:00
Kubernetes Prow Robot
2d7dcf928c
Merge pull request #109594 from linux-on-ibm-z/fastbuild_s390x
Add fast build support for s390x
2022-06-05 23:42:23 -07:00
Jordan Liggitt
6cdaecfe0a Build in hermetic module mode 2022-05-05 08:47:33 -04:00
Jordan Liggitt
2a10ca650d drop vendor from test targets 2022-05-05 08:47:33 -04:00
vitt-bagal
969ddfbd72 Add fast build support for s390x 2022-04-21 01:47:26 -07:00
Jordan Liggitt
f97bc825d5 Update min golang version to 1.18.1 2022-04-14 09:53:20 -04:00
Kir Kolyshkin
d8fdb00b34 Fix verify: generated-stable-metrics wrt go 1.18
This should fix the following error when running
./hack/update-generated-stable-metrics.sh:

	'go get' is no longer supported outside a module.
	To build and install a command, use 'go install' with a version,
	like 'go install example.com/cmd@latest'
	For more information, see https://golang.org/doc/go-get-install-deprecation
	or run 'go help get' or 'go help install'.

Using `go get` to download gopkg.in/yaml.v2 package into
KUBE_EXTRA_GOPATH directory no longer works. Interestingly, main repo
already has gopkg.in/yaml.v2@v2.4.0, same version that was installed by
that go get.

I guess that GOPATH with multiple elements no longer works either,
and since this code was the only user of KUBE_EXTRA_GOPATH, let's remove
it as well.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-03-23 10:19:59 -07:00
Davanum Srinivas
d8f1da5ecb
golang: Update to 1.18 from 1.18rc1
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-03-22 09:47:35 -04:00
Tim Hockin
bf27cad256 Build flags: use all= syntax
This has somewhat subtle implications.  For a concrete example, this
changes the `-trimpath` behavior from only affecting the named pkg to
affecting all pkgs, which broke ginkgo, which seems to try to strip its
own `pwd` prefix.  But since that runs in run-in-gopath, and not in
KUBE_ROOT, it fails to strip anything.

e.g.

before this, strings in the binary would be like
    /home/user/kube/_output/local/go/src/k8s.io/kubernetes/vendor/github.com/onsi/ginkgo/...
Ginkgo would find its own root as
    /home/user/kube/_output/local/go/src/k8s.io/kubernetes/
so it would produce
    vendor/github.com/onsi/ginkgo/...
in logs.

after this, strings in the binary strip the KUBE_ROOT and be like:
    _output/local/go/src/k8s.io/kubernetes/vendor/github.com/onsi/ginkgo/...
Ginkgo would find its own root as
    /home/user/kube/_output/local/go/src/k8s.io/kubernetes/
so it would not strip anything, and produce
    _output/local/go/src/k8s.io/kubernetes/vendor/github.com/onsi/ginkgo/...
in logs.
2022-03-01 08:48:31 -08:00
Tim Hockin
ed5e549cde Makefile: Add a DBG flag to build debug binaries
Now `make DBG=1` will produce binaries with no optimizaions and no
inlining, but with symbols and DWARF information.
2022-03-01 08:47:34 -08:00
Tim Hockin
4a0c6c2444 Slightly nicer output when building
before:

```
$ make generated_files
+++ [0226 13:42:17] Building go targets for linux/amd64:
    hack/make-rules/helpers/go2make
> non-static build: k8s.io/kubernetes/hack/make-rules/helpers/go2make
```

after:

```
$ make generated_files
+++ [0226 14:30:08] Building go targets for linux/amd64
    k8s.io/kubernetes/hack/make-rules/helpers/go2make (non-static)
```
2022-02-27 10:29:59 -08:00
Kubernetes Prow Robot
da73a24f6a
Merge pull request #106123 from pohly/log-go-runner-windows
package log runner as part of Kubernetes releases
2021-11-15 09:04:48 -08:00
Patrick Ohly
c3cd9a3902 kubemark: static binary, replace deprecated --log-file parameter
The --log-file parameter will be deprecated as of Kubernetes 1.23 and should be
avoided. The replacement for distroless images is the image with go-runner, a
tool that handles output redirection.

For kubemark to run in that image it must be built as static binary.
2021-11-04 20:52:56 +01:00
Patrick Ohly
d2a8a81639 Package kube-log-runner as part of Kubernetes releases
kube-log-runner was formerly known as go-runner when it was originally introduced
in 393e0952e9
It was moved to kubernetes/release/images/build/go-runner later but is now
needed again in Kubernetes itself as replacement for the deprecated --log-file
klog feature: when bringing up a Windows node, kube-proxy.exe and kubelet.exe must be wrapped
with the helper binary to redirect output.

It got renamed to avoid a naming conflict with
test/conformance/image/go-runner and because the name was too vague.

Other downstream Kubernetes users may have a similar need, therefore it makes
sense to provide a prebuilt binary also in the release archives.
2021-11-04 10:00:26 +01:00
Kubernetes Prow Robot
a7c67c03ff
Merge pull request #105399 from mopsfelder/ppc64le
Allow fast builds on ppc64le
2021-10-11 22:21:46 -07:00
Kubernetes Prow Robot
f31453fe5b
Merge pull request #104894 from pacoxu/windows-arm
add windows arm support on client-side since go 1.17 supports
2021-10-04 04:19:07 -07:00
Murilo Opsfelder Araujo
1589605a7c Allow fast builds on ppc64le
On a ppc64le host, fast build was failing:

    # make KUBE_FASTBUILD=true quick-release
    +++ [0908 15:56:36] Verifying Prerequisites....
    +++ [0908 15:56:36] Building Docker image kube-build:build-fd009aaa81-5-v1.23.0-go1.17-buster.0
    +++ [0908 15:56:44] Syncing sources to container
    +++ [0908 15:56:48] Running build command...
    +++ [0908 15:56:56] Building go targets for linux/ppc64le:
        ./vendor/k8s.io/code-generator/cmd/prerelease-lifecycle-gen
    > non-static build: k8s.io/kubernetes/./vendor/k8s.io/code-generator/cmd/prerelease-lifecycle-gen
    touch: cannot touch '_output/bin/prerelease-lifecycle-gen': No such file or directory
    make[2]: *** [Makefile.generated_files:209: _output/bin/prerelease-lifecycle-gen] Error 1
    make[1]: *** [Makefile:552: generated_files] Error 2
    make: *** [Makefile:512: cross] Error 1
    !!! [0908 15:56:58] Call tree:
    !!! [0908 15:56:58]  1: build/../build/common.sh:476 kube::build::run_build_command_ex(...)
    !!! [0908 15:56:58]  2: build/release.sh:36 kube::build::run_build_command(...)
    make: *** [Makefile:454: quick-release] Error 1

This error happened because the _output/bin/ directory didn't exist at
the moment the file _output/bin/prerelease-lifecycle-gen was touched, so
the path didn't exist.

The _output/bin symlink was not created by kube::golang::place_bins()
because kube::golang::setup_platforms() assumed
KUBE_CLIENT_PLATFORMS=linux/amd64 despite being on a ppc64le host.

Fix build error by not assuming host_arch=amd64 when on ppc64le in
kube::golang::setup_platforms().

Signed-off-by: Murilo Opsfelder Araujo <muriloo@linux.ibm.com>
2021-10-01 09:31:10 -03:00
Elana Hashman
132fa1cbf3
Revert "Build non-static binaries with PIE buildmode" 2021-09-29 11:36:20 -07:00
Paco Xu
9a2a4f1051 add windows arm support on client-side since go 1.17 supports 2021-09-10 15:42:45 +08:00
Stephen Augustus
e8d2bff6ba
[go1.17] Update to go1.17
Signed-off-by: Stephen Augustus <foo@auggie.dev>
2021-08-24 15:47:41 -04:00
Yaakov Selkowitz
67e14290aa Fix build with multiple GOFLAGS
The tag extraction from GOFLAGS doesn't do anything if -tags is not
present in GOFLAGS.  Not only does that mean non-sensical tags are
passed, but because GOFLAGS is a space-separated variable, the build
will fail because the build flags because -tags must be comma-separated.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2021-08-11 19:23:41 -04:00
Kubernetes Prow Robot
0427b17395
Merge pull request #104164 from dims/allow-override-of-cgo-enabled
Allow override of KUBE_CGO_OVERRIDES (for switching on/off of `CGO_ENABLED`)
2021-08-05 16:37:26 -07:00
Davanum Srinivas
af2129b77d
Allow override of CGO_ENABLED=0
When building inside a docker container, we fail to pass along enough
information for KUBE_CGO_OVERRIDES. The original PR was geared towards
building the binary from the command line

- dca376a03e
- e4ded2b3ec

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-08-05 10:45:14 -04:00
Jordan Liggitt
4115bef826 Update references to test/conformance/image 2021-07-23 11:26:54 -04:00
Sascha Grunert
39d9e98a6f
Build non-static binaries with PIE buildmode
We now add the `-buildmode pie` flag when building non-static binaries,
which enables the ASLR security mechanism.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2021-05-27 14:51:36 +02:00
Sascha Grunert
746ec78ebf
Stop unsetting the golang buildid
Golang fixed the issue with the non-reproducible buildid already in
v1.15.3:

c5f6920212
a3e965ce8a

This means we can now use the internal buildid instead of the unset one.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2021-04-23 10:21:00 +02:00
Kubernetes Prow Robot
d62a9b2179
Merge pull request #99773 from saschagrunert/build-memory
Change KUBE_PARALLEL_BUILD_MEMORY to 20 GiB
2021-03-09 16:08:07 -08:00
Benjamin Elder
8f3cbc923a drop bazel logic from hack/lib/golang.sh 2021-03-07 13:11:29 -08:00
Benjamin Elder
a0cd54a7f1 fix trivial shell quoting issues surfaced by shellcheck v0.7.1 2021-03-06 13:19:17 -08:00
Kubernetes Prow Robot
2e39df89ac
Merge pull request #97743 from dims/support-m1-macbook-darwin/arm64-as-client
Support M1 MacBooks darwin/arm64 on the client-side
2021-03-04 04:18:09 -08:00
Sascha Grunert
abf85d70c2
Change KUBE_PARALLEL_BUILD_MEMORY to 20 GiB
A benchmark with go1.16 on amd64 resulted in an overall maximum memory
usage of 15GiB. This means we now lower the `KUBE_PARALLEL_BUILD_MEMORY`
to `20` to still have some room left.

The benchmark has been done with the following `Dockerfile`:

```dockerfile
FROM k8s.gcr.io/build-image/kube-cross:v1.16.0-1
RUN apt-get update && apt-get install -y time

WORKDIR /go/src/k8s.io/kubernetes
RUN git clone https://github.com/kubernetes/kubernetes
ENV KUBE_PARALLEL_BUILD_MEMORY=0
RUN /usr/bin/time -v make -C kubernetes cross-in-a-container
```

The value of interest from the output:

```
Maximum resident set size (kbytes): 1847108
```

The RSS is not the only value we have to consider. During the runtime I
measured the usage of the cached memory, which gets peaks up to 15GiB.

Test machine specs:
- CPU: 2 x Intel Scalable Gold 5120 28-Core Processor @ 2.2GHz
- RAM: 384GB
- Disk: 1 x 3.8TB NVME
- OS: Debian 10 (buster)

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2021-03-04 12:11:20 +01:00
Kubernetes Prow Robot
9658145f8a
Merge pull request #99655 from liggitt/min-go-version
Update go version check to 1.16+
2021-03-03 20:13:59 -08:00
Davanum Srinivas
f719624654
Support M1 MacBooks darwin/arm64 on the client-side
testing using:
```
build/run.sh make generated_files && make quick-release-images
```

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-03-02 20:50:00 -05:00
Kubernetes Prow Robot
28feb8e30d
Merge pull request #96882 from saschagrunert/parallel-build-configurable
Make parallel build memory threshold configurable
2021-03-02 16:51:19 -08:00