Commit Graph

268 Commits (616e467d687cb69c6e64144a757d78c5f0b2815f)

Author SHA1 Message Date
hui luo 6c8aabc832 Check KUBE_SERVER_PLATFORMS existence
when compile kubectl on platform other than
linux/amd64, we need to check the KUBE_SERVER_PLATFORMS
array emptiness before assign it.

the example command is:
make WHAT=cmd/kubectl KUBE_BUILD_PLATFORMS="darwin/amd64 windows/amd64"
2019-05-18 09:17:22 -07:00
Christoph Blecker b8481b62fc
Don't use declare -g in build 2019-05-17 12:22:42 -07:00
adisky 7e2aa46f64
fix unbound variable release.sh 2019-05-16 23:09:19 +05:30
adisky 38b7f2125f
fix unbound array variable 2019-05-15 13:47:48 +05:30
Christoph Blecker eaafa5952f
Don't use mapfile as it isn't bash 3 compatible 2019-05-06 15:55:12 -07:00
Michael Taufen dcee810a3f Restrict builds to officially supported platforms
Prior to this change, including windows/amd64 in KUBE_BUILD_PLATFORMS
would, for example, attempt to build the server binaries/tars/images for
Windows, which is not supported. This can break downstream build steps.
2019-04-25 14:05:44 -07:00
Christoph Blecker 4543e68ae5
Fix shellcheck in hack/lib/golang.sh 2019-04-18 18:53:13 -07:00
Davanum Srinivas 7e01702a88
Move "-s -w" flags to GOLDFLAGS as an overridable default.
If GOLDFLAGS is set, whether it is empty or not, we should honor it.
Only if the GOLDFLAGS is totally not set, then we use "-s -w"

See Parameter Expansion section in the urls below:

https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash/16753536
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02

Change-Id: I826c34efc63c77f0e3e9677fff30a3eb2219a377
2019-04-17 21:55:13 -04:00
Jordan Liggitt 2ea3cbdcbc Update hack scripts to use go mod 2019-04-03 10:19:39 -04:00
Kubernetes Prow Robot f6c51d6e99
Merge pull request #75751 from BenTheElder/bash-fun
fix kube::golang::is_instrumented_package
2019-03-26 23:19:01 -07:00
Benjamin Elder 0833a9cc38 fix kube::golang::is_instrumented_package 2019-03-26 17:17:16 -07:00
Ed Bartosh 3d5d38607d fix 'make generated_files' build on MacOS
Recent change to hack/lib/golang.sh broke the build on MacOS this way:

$ make clean && make generated_files
+++ [0325 13:38:22] Verifying Prerequisites....
+++ [0325 13:38:23] Removing _output directory
k8s.io/kubernetes/vendor/github.com/spf13/pflag
k8s.io/kubernetes/hack/make-rules/helpers/go2make
+++ [0325 13:38:40] Building go targets for darwin/amd64:
    ./vendor/k8s.io/code-generator/cmd/deepcopy-gen
can't load package: package k8s.io/kubernetes: no Go files in k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes
!!! [0325 13:38:40] Call tree:
!!! [0325 13:38:40]  1: k8s.io/kubernetes/hack/lib/golang.sh:629 kube::golang::build_some_binaries(...)
!!! [0325 13:38:40]  2: k8s.io/kubernetes/hack/lib/golang.sh:764 kube::golang::build_binaries_for_platform(...)
!!! [0325 13:38:40]  3: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
make[1]: *** [_output/bin/deepcopy-gen] Error 1
make: *** [generated_files] Error 2

It was caused by 'binaries' array not being declared with 'local -a'.
It looks like MacOS' old bash version makes an array to contain first
empty element if declared this way.

The fix has been tested on MacOS High Sierra and Linux openSUSE 42.3 (x86_64)

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
2019-03-25 17:08:13 +01:00
toyoda a52af3a9d5 fix shellcheck failure golang.sh 2019-03-22 13:29:26 +09:00
Han Kang a5ddc3943a bump required minimum go version to 1.12.1 (strings package compatibility) 2019-03-20 16:07:07 -07:00
Roy Lenferink b18bc2ea79 Improved some more bash script variable definitions 2019-01-21 23:11:58 +01:00
Roy Lenferink a5d0616bdc Improving syntax for bash scripts 2019-01-18 19:17:16 +01:00
Kubernetes Prow Robot 152226c557
Merge pull request #71198 from cofyc/go1.11-GOFLAGS-env
No need to pass GOFLAGS to $goflags variables with go 1.11
2019-01-09 23:35:09 -08:00
Jeff Grafton e3fac7690b Make Bazel not follow the infinite symlink in _output/local/go
Otherwise, calling make followed by bazel might fail, requiring one to
run make clean first.

Additionally, add comments explaining why we must do this.
2018-11-29 10:47:36 -08:00
Yecheng Fu ce22322ef1 No need to pass GOFLAGS to $goflags variables.
In go 1.11, go commands will use `GOFLAGS` as default flags, see
https://golang.org/doc/go1.11#go_command.

There is no need to pass GOFLAGS to $goflags, and if we do, go commands
will fail with "duplicate flags" error, e.g.

```
$ make test-integration WHAT=./test/integration/scheduler GOFLAGS="-v"
...
go test: v flag may be set only once
run "go help test" or "go help testflag" for more information
...
```
2018-11-27 09:53:02 +08:00
Katharine Berry 9ec5b7ffde Include vendor/k8s.io in coverage. 2018-10-17 17:15:27 -07:00
Davanum Srinivas 6830bad2a6
upstream heptio/kube-conformance
Pick up some code from https://github.com/heptio/kube-conformance
Fix up build scripts for the new conformance image
Fix Header template and Copyright to make verify job go green
update README and add execute permissions for script

Change-Id: Ib6509acd816cc2fb3a516bfb8e0ff9e32bff8f79
2018-10-12 15:33:15 -04:00
Christoph Blecker 962fdbcbca
Bump golang version to 1.11.1 2018-10-05 12:58:56 -07:00
Davanum Srinivas a89242b7fd
Remove extra debugging log::status call
Introduced by mistake in:
d9cfd77149

Change-Id: I71ddf7131c47e74dddfa1f8ccc69cc980eeefb94
2018-09-27 17:36:44 -04:00
Davanum Srinivas d9cfd77149
Ensure reproducible builds - support for SOURCE_DATE_EPOCH with dockerized builds
- Pass in SOURCE_DATE_EPOCH when we run the docker container
- Looks like cleaning up symbol table also helps
- Also trimming the path

Tips from
- https://blog.filippo.io/reproducing-go-binaries-byte-by-byte/
- https://blog.filippo.io/shrink-your-go-binaries-with-this-one-weird-trick/

Change-Id: Iedba85d9c1a36790fb8814795f7c27c1371cff1b
2018-09-26 07:28:09 -04:00
Katharine Berry 449e94b295 Use KUBE_BUILD_WITH_COVERAGE directly. 2018-09-07 08:48:16 -07:00
Kubernetes Submit Queue 68d22a878d
Merge pull request #67971 from Katharine/coverage-instrumentation
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here: https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md.

Add ability to build with runtime coverage instrumentation

**What this PR does / why we need it**:

This PR adds the ability to instrument a subset of kubernetes binaries to report code coverage information. The specific use-case is to help determine coverage of our end-to-end Conformance tests, as well as provide data that can be used to help determine where to focus. This PR focuses on making it possible to build with instrumentation; collecting and using the generated coverage data will be done in later PRs. For more details as to the intent, see the [design doc](https://docs.google.com/document/d/1FKMBFxz7vtA-6ZgUkA47F8m6yR00fwqLcXMVJqsHt0g/edit?usp=sharing) (google doc; requires kubernetes-dev membership).

Specifically, this PR adds a new `KUBE_BUILD_WITH_COVERAGE` make variable, which when set will cause `kube-apiserver`, `kube-controller-manager`, `kube-scheduler`, `kube-proxy` and `kubelet` to be built with coverage instrumentation. These coverage-instrumented binaries will flush coverage information to disk every five seconds, defaulting to a temporary directory unless the `KUBE_COVERAGE_FILE` environment variable is set at launch, in which case it will write to that file instead.

The mechanism used to achieve coverage instrumentation is to build the targeted binaries as "unit tests" with coverage enabled, and then rigging the unit tests to just execute the binary's usual entry point. This is implemented only for the bash build system.

/sig testing

```release-note
NONE
```
2018-09-01 01:32:52 -07:00
Katharine Berry 9b790dab7d Address shell-related comments. 2018-08-31 17:07:25 -07:00
Katharine Berry facce197b1 Update stale comment. 2018-08-31 16:04:48 -07:00
Benjamin Elder 037fabd842 add make targets for building server images 2018-08-31 14:31:21 -07:00
Katharine Berry 0fb4b920b5 Address review comments. 2018-08-31 10:49:36 -07:00
Katharine Berry 9d499cd005 Be sure we delete the dummy tests. 2018-08-30 18:32:22 -07:00
Katharine Berry 8fe6467013 Improve bash formatting. 2018-08-30 16:18:15 -07:00
Katharine Berry da4bbd421c Add runtime coverage support. 2018-08-29 14:48:24 -07:00
Katharine Berry aa2a7d001a Build relevant binaries with coverage. 2018-08-29 14:48:24 -07:00
Davanum Srinivas a66e1f089e
Drop kube-aggregator container image from release
First version of this was only standalone, now the code is being
vendored by anyone who wants to use it. So the standalone binary and
container are no longer useful.

Change-Id: Ib9369de66b4ecb3451f73ba2a252526d6615b96f
2018-08-08 15:57:52 -04:00
Jeff Grafton e4ded2b3ec Explictly enable cgo when building kubectl for darwin from darwin 2018-05-23 12:32:01 -07:00
Jeff Grafton dca376a03e Add KUBE_CGO_OVERRIDES env var to force enabling CGO 2018-05-23 12:31:57 -07:00
Mark Janssen ac731ed2e5 Update to go1.10.2 2018-05-04 00:39:21 +02:00
Kubernetes Submit Queue b5f61ac129
Merge pull request #62657 from matthyx/master
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Update all script shebangs to use /usr/bin/env interpreter instead of /bin/interpreter

This is required to support systems where bash doesn't reside in /bin (such as NixOS, or the *BSD family) and allow users to specify a different interpreter version through $PATH manipulation.
https://www.cyberciti.biz/tips/finding-bash-perl-python-portably-using-env.html
```release-note
Use /usr/bin/env in all script shebangs to increase portability.
```
2018-05-02 19:44:32 -07:00
Kubernetes Submit Queue 42415e3186
Merge pull request #63046 from cblecker/go-go-minimum
Automatic merge from submit-queue (batch tested with PRs 63046, 62925, 63014). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Bump minimum required go version to 1.10.1

**What this PR does / why we need it**:
We have supported go1.10.x for a few weeks now (#60597). CI has all been updated. This enforces it as the new minimum go version required go k8s >=1.11

**Release note**:
No release note, as #60597 already had one.
```release-note
NONE
```
2018-04-24 00:42:09 -07:00
Christoph Blecker 94d56ffbde
Bump minimum required go version to 1.10.1 2018-04-23 18:08:10 -07:00
Matthias Bertschy 9b15af19b2 Update all script to use /usr/bin/env bash in shebang 2018-04-19 13:20:13 +02:00
Tim Hockin 59ef5e2379 Generate bindata through make 2018-04-10 20:55:03 -07:00
Tim Hockin 57d60ece72 Don't support `go build` any more.
Given run-in-gopath.sh, I can't see why we need it.  It is slower and
produces no better results.
2018-04-10 20:38:08 -07:00
Tim Hockin 46146f6f3d Remove 'teststale'
As of go 1.10, go's own build cache will ensure we do not rebuild or
relink tests.
2018-04-10 20:38:08 -07:00
Tim Hockin 5433ebd629 Simplify static build, rely on go's cache
As of go 1.10, we do not need to explicitly build the stdlib for static
any more.  That happens automatically.  Timing tests show no discernible
difference between a `go install` with and without it.

Also use 'static' suffix instead of 'cgo'.
2018-04-10 20:38:08 -07:00
Tim Hockin c773e88941 Set GOCACHE (1.10) as a subdir of GOPATH 2018-04-10 20:38:08 -07:00
Ismo Puustinen 173f8e2e4a hack/lib/golang.sh: use double quotes.
It's admittedly extremely unlikely that the host platform name would
contain special characters, but still use double quotes to pattern
matching.

Consider this script:

  #!/bin/bash

  bar="foobar"
  foo="foo*"

  [[ $bar == $foo ]] && echo "first true"
  [[ "$bar" == "$foo" ]] && echo "second true"

We get the output:

  first true

The plan is to move from first case to the second case to prevent
pattern match where there shouldn't be any.
2018-02-26 16:46:18 +02:00
Ismo Puustinen c0c888fdc1 hack/lib/golang.sh: do not split on array items. 2018-02-26 16:45:19 +02:00
Ismo Puustinen 9209953c62 hack/lib/golang.sh: split strings into arrays safely. 2018-02-26 16:45:19 +02:00