vendor update for CSI 0.3.0

This commit is contained in:
gman
2018-07-18 16:47:22 +02:00
parent 6f484f92fc
commit 8ea659f0d5
6810 changed files with 438061 additions and 193861 deletions

View File

@ -1,20 +1,21 @@
cluster/images/etcd-version-monitor
cmd/hyperkube
cmd/kube-apiserver/app
cmd/kube-controller-manager/app
cmd/kube-proxy/app
cmd/kube-scheduler/app
cmd/kubeadm/app
cmd/kubeadm/app/apis/kubeadm/v1alpha1
cmd/kubeadm/app/apis/kubeadm/v1alpha2
cmd/kubeadm/app/util/config
cmd/kubelet/app
cmd/kubelet/app/options
cmd/kubemark
examples/guestbook-go
pkg/api/endpoints
pkg/api/ref
pkg/api/testapi
pkg/api/testing
pkg/api/testing/compat
pkg/api/unversioned
pkg/api/v1/endpoints
pkg/api/v1/pod
pkg/api/v1/resource
@ -66,6 +67,7 @@ pkg/apis/rbac/v1beta1
pkg/apis/rbac/validation
pkg/apis/scheduling
pkg/apis/scheduling/v1alpha1
pkg/apis/scheduling/v1beta1
pkg/apis/settings
pkg/apis/settings/v1alpha1
pkg/apis/storage
@ -100,7 +102,6 @@ pkg/controller/deployment/util
pkg/controller/disruption
pkg/controller/endpoint
pkg/controller/garbagecollector
pkg/controller/garbagecollector/metaonly
pkg/controller/job
pkg/controller/namespace
pkg/controller/namespace/deletion
@ -135,22 +136,24 @@ pkg/kubeapiserver/authorizer/modes
pkg/kubeapiserver/options
pkg/kubeapiserver/server
pkg/kubectl
pkg/kubectl/categories
pkg/kubectl/cmd
pkg/kubectl/cmd/auth
pkg/kubectl/cmd/config
pkg/kubectl/cmd/create
pkg/kubectl/cmd/get
pkg/kubectl/cmd/rollout
pkg/kubectl/cmd/set
pkg/kubectl/cmd/templates
pkg/kubectl/cmd/testing
pkg/kubectl/cmd/util
pkg/kubectl/cmd/util/editor
pkg/kubectl/cmd/util/jsonmerge
pkg/kubectl/cmd/util/sanity
pkg/kubectl/cmd/wait
pkg/kubectl/genericclioptions
pkg/kubectl/genericclioptions/printers
pkg/kubectl/genericclioptions/resource
pkg/kubectl/metricsutil
pkg/kubectl/resource
pkg/kubectl/util
pkg/kubectl/util/crlf
pkg/kubectl/util/slice
pkg/kubelet
pkg/kubelet/apis
@ -160,10 +163,15 @@ pkg/kubelet/apis/deviceplugin/v1alpha
pkg/kubelet/apis/deviceplugin/v1beta1
pkg/kubelet/apis/kubeletconfig
pkg/kubelet/apis/kubeletconfig/v1beta1
pkg/kubelet/apis/pluginregistration/v1alpha1
pkg/kubelet/cadvisor
pkg/kubelet/cadvisor/testing
pkg/kubelet/checkpoint
pkg/kubelet/checkpointmanager/checksum
pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1
pkg/kubelet/client
pkg/kubelet/cm
pkg/kubelet/cm/devicemanager/checkpoint
pkg/kubelet/cm/util
pkg/kubelet/config
pkg/kubelet/configmap
@ -172,22 +180,19 @@ pkg/kubelet/custommetrics
pkg/kubelet/dockershim
pkg/kubelet/dockershim/cm
pkg/kubelet/dockershim/libdocker
pkg/kubelet/dockershim/testing
pkg/kubelet/dockershim/network
pkg/kubelet/dockershim/network/cni
pkg/kubelet/dockershim/network/cni/testing
pkg/kubelet/dockershim/network/hostport
pkg/kubelet/dockershim/network/hostport/testing
pkg/kubelet/dockershim/network/kubenet
pkg/kubelet/dockershim/network/testing
pkg/kubelet/events
pkg/kubelet/gpu
pkg/kubelet/images
pkg/kubelet/kuberuntime
pkg/kubelet/leaky
pkg/kubelet/lifecycle
pkg/kubelet/metrics
pkg/kubelet/network
pkg/kubelet/network/cni
pkg/kubelet/network/cni/testing
pkg/kubelet/network/hairpin
pkg/kubelet/network/hostport
pkg/kubelet/network/hostport/testing
pkg/kubelet/network/kubenet
pkg/kubelet/network/testing
pkg/kubelet/pleg
pkg/kubelet/pod
pkg/kubelet/pod/testing
@ -197,7 +202,6 @@ pkg/kubelet/prober/results
pkg/kubelet/prober/testing
pkg/kubelet/qos
pkg/kubelet/remote
pkg/kubelet/rkt
pkg/kubelet/secret
pkg/kubelet/server
pkg/kubelet/server/portforward
@ -211,12 +215,16 @@ pkg/kubelet/sysctl
pkg/kubelet/types
pkg/kubelet/util
pkg/kubelet/util/cache
pkg/kubelet/util/pluginwatcher
pkg/kubelet/util/pluginwatcher/example_plugin_apis/v1beta1
pkg/kubelet/util/pluginwatcher/example_plugin_apis/v1beta2
pkg/kubelet/util/queue
pkg/kubelet/util/sliceutils
pkg/kubemark
pkg/master
pkg/master/controller/crdregistration
pkg/master/tunneler
pkg/printers
pkg/printers/internalversion
pkg/printers/storage
pkg/probe
@ -324,7 +332,6 @@ pkg/registry/storage/rest
pkg/registry/storage/storageclass
pkg/registry/storage/storageclass/storage
pkg/routes
pkg/scheduler/api
pkg/security/apparmor
pkg/security/podsecuritypolicy
pkg/security/podsecuritypolicy/group
@ -374,7 +381,9 @@ pkg/volume/azure_dd
pkg/volume/azure_file
pkg/volume/cephfs
pkg/volume/configmap
pkg/volume/csi
pkg/volume/csi/fake
pkg/volume/csi/labelmanager
pkg/volume/empty_dir
pkg/volume/fc
pkg/volume/flexvolume
@ -400,10 +409,8 @@ pkg/volume/vsphere_volume
plugin/pkg/admission/antiaffinity
plugin/pkg/admission/eventratelimit/apis/eventratelimit
plugin/pkg/admission/eventratelimit/apis/eventratelimit/v1alpha1
plugin/pkg/admission/initialresources
plugin/pkg/admission/limitranger
plugin/pkg/admission/noderestriction
plugin/pkg/admission/persistentvolume/label
plugin/pkg/admission/podnodeselector
plugin/pkg/admission/podpreset
plugin/pkg/admission/podtolerationrestriction
@ -443,18 +450,13 @@ staging/src/k8s.io/api/rbac/v1
staging/src/k8s.io/api/rbac/v1alpha1
staging/src/k8s.io/api/rbac/v1beta1
staging/src/k8s.io/api/scheduling/v1alpha1
staging/src/k8s.io/api/scheduling/v1beta1
staging/src/k8s.io/api/settings/v1alpha1
staging/src/k8s.io/api/storage/v1
staging/src/k8s.io/api/storage/v1alpha1
staging/src/k8s.io/api/storage/v1beta1
staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr
staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1
staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned
staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/fake
staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/scheme
staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1
staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/fake
staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/internalinterfaces
staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions
staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1
staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver
@ -469,8 +471,6 @@ staging/src/k8s.io/apimachinery/pkg/api/testing/fuzzer
staging/src/k8s.io/apimachinery/pkg/api/testing/roundtrip
staging/src/k8s.io/apimachinery/pkg/api/validation
staging/src/k8s.io/apimachinery/pkg/api/validation/path
staging/src/k8s.io/apimachinery/pkg/apimachinery/announced
staging/src/k8s.io/apimachinery/pkg/apimachinery/registered
staging/src/k8s.io/apimachinery/pkg/apis/meta/fuzzer
staging/src/k8s.io/apimachinery/pkg/apis/meta/internalversion
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured
@ -505,7 +505,6 @@ staging/src/k8s.io/apimachinery/pkg/util/proxy
staging/src/k8s.io/apimachinery/pkg/util/rand
staging/src/k8s.io/apimachinery/pkg/util/remotecommand
staging/src/k8s.io/apimachinery/pkg/util/runtime
staging/src/k8s.io/apimachinery/pkg/util/sets
staging/src/k8s.io/apimachinery/pkg/util/sets/types
staging/src/k8s.io/apimachinery/pkg/util/strategicpatch
staging/src/k8s.io/apimachinery/pkg/util/uuid
@ -552,6 +551,7 @@ staging/src/k8s.io/apiserver/pkg/endpoints/handlers
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/negotiation
staging/src/k8s.io/apiserver/pkg/endpoints/metrics
staging/src/k8s.io/apiserver/pkg/endpoints/openapi/testing
staging/src/k8s.io/apiserver/pkg/endpoints/request
staging/src/k8s.io/apiserver/pkg/endpoints/testing
staging/src/k8s.io/apiserver/pkg/features
staging/src/k8s.io/apiserver/pkg/registry/generic
@ -591,6 +591,7 @@ staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/oidc
staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/tokentest
staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook
staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook
staging/src/k8s.io/client-go/deprecated-dynamic
staging/src/k8s.io/client-go/discovery/cached
staging/src/k8s.io/client-go/dynamic
staging/src/k8s.io/client-go/dynamic/fake
@ -706,6 +707,7 @@ test/e2e/ui
test/e2e/upgrades
test/e2e/upgrades/apps
test/e2e/upgrades/storage
test/e2e_kubeadm
test/e2e_node
test/e2e_node/builder
test/e2e_node/environment

View File

@ -19,7 +19,6 @@ filegroup(
srcs = [
":package-srcs",
"//hack/boilerplate:all-srcs",
"//hack/cmd/teststale:all-srcs",
"//hack/e2e-internal:all-srcs",
"//hack/lib:all-srcs",
"//hack/make-rules:all-srcs",
@ -72,3 +71,10 @@ go_library(
srcs = ["e2e.go"],
importpath = "k8s.io/kubernetes/hack",
)
sh_binary(
name = "update-mirror",
srcs = ["update-workspace-mirror.sh"],
args = ["$(location @workspace_urls//:urls.txt)"],
data = ["@workspace_urls//:urls.txt"],
)

View File

@ -4,8 +4,8 @@ reviewers:
- fejta
- ixdy
- jbeda
- juanvallejo
- lavalamp
- spxtr
- zmerlynn
- sttts
- gmarek
@ -21,9 +21,10 @@ approvers:
- madhusudancs
- pwittrock
- shashidharatd
- spxtr
- zmerlynn
- sttts
- gmarek
- vishh
- liggitt
- soltysh # for sig-cli related stuff
- dims # for local-up-cluster related files

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -0,0 +1,16 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

View File

@ -17,10 +17,9 @@
from __future__ import print_function
import argparse
import datetime
import difflib
import glob
import json
import mmap
import os
import re
import sys
@ -62,6 +61,14 @@ def get_refs():
return refs
def is_generated_file(filename, data, regexs):
for d in skipped_ungenerated_files:
if d in filename:
return False
p = regexs["generated"]
return p.search(data)
def file_passes(filename, refs, regexs):
try:
f = open(filename, 'r')
@ -72,15 +79,22 @@ def file_passes(filename, refs, regexs):
data = f.read()
f.close()
# determine if the file is automatically generated
generated = is_generated_file(filename, data, regexs)
basename = os.path.basename(filename)
extension = file_extension(filename)
if generated:
extension = "generatego"
else:
extension = file_extension(filename)
if extension != "":
ref = refs[extension]
else:
ref = refs[basename]
# remove build tags from the top of Go files
if extension == "go":
if extension == "go" or extension =="generatego":
p = regexs["go_build_constraints"]
(data, found) = p.subn("", data, 1)
@ -104,15 +118,19 @@ def file_passes(filename, refs, regexs):
p = regexs["year"]
for d in data:
if p.search(d):
print('File %s is missing the year' % filename, file=verbose_out)
if generated:
print('File %s has the YEAR field, but it should not be in generated file' % filename, file=verbose_out)
else:
print('File %s has the YEAR field, but missing the year of date' % filename, file=verbose_out)
return False
# Replace all occurrences of the regex "2014|2015|2016|2017|2018" with "YEAR"
p = regexs["date"]
for i, d in enumerate(data):
(data[i], found) = p.subn('YEAR', d)
if found != 0:
break
if not generated:
# Replace all occurrences of the regex "2014|2015|2016|2017|2018" with "YEAR"
p = regexs["date"]
for i, d in enumerate(data):
(data[i], found) = p.subn('YEAR', d)
if found != 0:
break
# if we don't match the reference at this point, fail
if ref != data:
@ -133,6 +151,10 @@ skipped_dirs = ['Godeps', 'third_party', '_gopath', '_output', '.git', 'cluster/
"vendor", "test/e2e/generated/bindata.go", "hack/boilerplate/test",
"pkg/generated/bindata.go"]
# list all the files contain 'DO NOT EDIT', but are not generated
skipped_ungenerated_files = ['hack/build-ui.sh', 'hack/lib/swagger.sh',
'hack/boilerplate/boilerplate.py']
def normalize_files(files):
newfiles = []
for pathname in files:
@ -171,16 +193,23 @@ def get_files(extensions):
outfiles.append(pathname)
return outfiles
def get_dates():
years = datetime.datetime.now().year
return '(%s)' % '|'.join((str(year) for year in range(2014, years+1)))
def get_regexs():
regexs = {}
# Search for "YEAR" which exists in the boilerplate, but shouldn't in the real thing
regexs["year"] = re.compile( 'YEAR' )
# dates can be 2014, 2015, 2016, 2017, or 2018; company holder names can be anything
regexs["date"] = re.compile( '(2014|2015|2016|2017|2018)' )
# get_dates return 2014, 2015, 2016, 2017, or 2018 until the current year as a regex like: "(2014|2015|2016|2017|2018)";
# company holder names can be anything
regexs["date"] = re.compile(get_dates())
# strip // +build \n\n build constraints
regexs["go_build_constraints"] = re.compile(r"^(// \+build.*\n)+\n", re.MULTILINE)
# strip #!.* from shell scripts
regexs["shebang"] = re.compile(r"^(#!.*\n)\n*", re.MULTILINE)
# Search for generated files
regexs["generated"] = re.compile( 'DO NOT EDIT' )
return regexs
def main():

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#
@ -30,7 +30,8 @@ if ! which go-bindata > /dev/null 2>&1 ; then
exit 1
fi
readonly TMP_DATAFILE="/tmp/datafile.go"
kube::util::ensure-temp-dir
readonly TMP_DATAFILE="${KUBE_TEMP}/datafile.go"
readonly SWAGGER_SRC="third_party/swagger-ui/..."
readonly SWAGGER_PKG="swagger"
@ -42,7 +43,7 @@ function kube::hack::build_ui() {
go-bindata -nocompress -o "${output_file}" -prefix ${PWD} -pkg "${pkg}" "${src}"
local year=$(date +%Y)
cat hack/boilerplate/boilerplate.go.txt | sed "s/YEAR/${year}/" > "${TMP_DATAFILE}"
cat hack/boilerplate/boilerplate.generatego.txt > "${TMP_DATAFILE}"
echo -e "// generated by hack/build-ui.sh; DO NOT EDIT\n" >> "${TMP_DATAFILE}"
cat "${output_file}" >> "${TMP_DATAFILE}"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,39 +0,0 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
"go_test",
)
go_binary(
name = "teststale",
embed = [":go_default_library"],
)
go_test(
name = "go_default_test",
srcs = ["teststale_test.go"],
embed = [":go_default_library"],
)
go_library(
name = "go_default_library",
srcs = ["teststale.go"],
importpath = "k8s.io/kubernetes/hack/cmd/teststale",
deps = ["//vendor/github.com/golang/glog:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

View File

@ -1,209 +0,0 @@
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// teststale checks the staleness of a test binary. go test -c builds a test
// binary but it does no staleness check. In other words, every time one runs
// go test -c, it compiles the test packages and links the binary even when
// nothing has changed. This program helps to mitigate that problem by allowing
// to check the staleness of a given test package and its binary.
package main
import (
"encoding/json"
"flag"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"time"
"github.com/golang/glog"
)
const usageHelp = "" +
`This program checks the staleness of a given test package and its test
binary so that one can make a decision about re-building the test binary.
Usage:
teststale -binary=/path/to/test/binary -package=package
Example:
teststale -binary="$HOME/gosrc/bin/e2e.test" -package="k8s.io/kubernetes/test/e2e"
`
var (
binary = flag.String("binary", "", "filesystem path to the test binary file. Example: \"$HOME/gosrc/bin/e2e.test\"")
pkgPath = flag.String("package", "", "import path of the test package in the format used while importing packages. Example: \"k8s.io/kubernetes/test/e2e\"")
)
func usage() {
fmt.Fprintln(os.Stderr, usageHelp)
fmt.Fprintln(os.Stderr, "Flags:")
flag.PrintDefaults()
os.Exit(2)
}
// golist is an interface emulating the `go list` command to get package information.
// TODO: Evaluate using `go/build` package instead. It doesn't provide staleness
// information, but we can probably run `go list` and `go/build.Import()` concurrently
// in goroutines and merge the results. Evaluate if that's faster.
type golist interface {
pkgInfo(pkgPaths []string) ([]pkg, error)
}
// execmd implements the `golist` interface.
type execcmd struct {
cmd string
args []string
env []string
}
func (e *execcmd) pkgInfo(pkgPaths []string) ([]pkg, error) {
args := append(e.args, pkgPaths...)
cmd := exec.Command(e.cmd, args...)
cmd.Env = e.env
stdout, err := cmd.StdoutPipe()
if err != nil {
return nil, fmt.Errorf("failed to obtain the metadata output stream: %v", err)
}
dec := json.NewDecoder(stdout)
// Start executing the command
if err := cmd.Start(); err != nil {
return nil, fmt.Errorf("command did not start: %v", err)
}
var pkgs []pkg
for {
var p pkg
if err := dec.Decode(&p); err == io.EOF {
break
} else if err != nil {
return nil, fmt.Errorf("failed to unmarshal metadata for package %s: %v", p.ImportPath, err)
}
pkgs = append(pkgs, p)
}
if err := cmd.Wait(); err != nil {
return nil, fmt.Errorf("command did not complete: %v", err)
}
return pkgs, nil
}
type pkg struct {
Dir string
ImportPath string
Target string
Stale bool
TestGoFiles []string
TestImports []string
XTestGoFiles []string
XTestImports []string
}
func (p *pkg) isNewerThan(cmd golist, buildTime time.Time) bool {
// If the package itself is stale, then we have to rebuild the whole thing anyway.
if p.Stale {
return true
}
// Test for file staleness
for _, f := range p.TestGoFiles {
if isNewerThan(filepath.Join(p.Dir, f), buildTime) {
glog.V(4).Infof("test Go file %s is stale", f)
return true
}
}
for _, f := range p.XTestGoFiles {
if isNewerThan(filepath.Join(p.Dir, f), buildTime) {
glog.V(4).Infof("external test Go file %s is stale", f)
return true
}
}
imps := []string{}
imps = append(imps, p.TestImports...)
imps = append(imps, p.XTestImports...)
// This calls `go list` the second time. This is required because the first
// call to `go list` checks the staleness of the package in question by
// looking the non-test dependencies, but it doesn't look at the test
// dependencies. However, it returns the list of test dependencies. This
// second call to `go list` checks the staleness of all the test
// dependencies.
pkgs, err := cmd.pkgInfo(imps)
if err != nil || len(pkgs) < 1 {
glog.V(4).Infof("failed to obtain metadata for packages %s: %v", imps, err)
return true
}
for _, p := range pkgs {
if p.Stale {
glog.V(4).Infof("import %q is stale", p.ImportPath)
return true
}
}
return false
}
func isNewerThan(filename string, buildTime time.Time) bool {
stat, err := os.Stat(filename)
if err != nil {
return true
}
return stat.ModTime().After(buildTime)
}
// isTestStale checks if the test binary is stale and needs to rebuilt.
// Some of the ideas here are inspired by how Go does staleness checks.
func isTestStale(cmd golist, binPath, pkgPath string) bool {
bStat, err := os.Stat(binPath)
if err != nil {
glog.V(4).Infof("Couldn't obtain the modified time of the binary %s: %v", binPath, err)
return true
}
buildTime := bStat.ModTime()
pkgs, err := cmd.pkgInfo([]string{pkgPath})
if err != nil || len(pkgs) < 1 {
glog.V(4).Infof("Couldn't retrieve test package information for package %s: %v", pkgPath, err)
return false
}
return pkgs[0].isNewerThan(cmd, buildTime)
}
func main() {
flag.Usage = usage
flag.Parse()
cmd := &execcmd{
cmd: "go",
args: []string{
"list",
"-json",
},
env: os.Environ(),
}
if !isTestStale(cmd, *binary, *pkgPath) {
os.Exit(1)
}
}

View File

@ -1,325 +0,0 @@
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"fmt"
"io/ioutil"
"math/rand"
"os"
"path"
"path/filepath"
"testing"
"time"
)
const (
// seed for rand.Source to generate data for files
seed int64 = 42
// 1K binary file
binLen = 1024
// Directory of the test package relative to $GOPATH
testImportDir = "example.com/proj/pkg"
)
var (
pastHour = time.Now().Add(-1 * time.Hour)
// The test package we are testing against
testPkg = path.Join(testImportDir, "test")
)
// fakegolist implements the `golist` interface providing fake package information for testing.
type fakegolist struct {
dir string
importMap map[string]pkg
testFiles []string
binfile string
}
func newFakegolist() (*fakegolist, error) {
dir, err := ioutil.TempDir("", "teststale")
if err != nil {
// test can't proceed without a temp directory.
return nil, fmt.Errorf("failed to create a temp directory for testing: %v", err)
}
// Set the temp directory as the $GOPATH
if err := os.Setenv("GOPATH", dir); err != nil {
// can't proceed without pointing the $GOPATH to the temp directory.
return nil, fmt.Errorf("failed to set \"$GOPATH\" pointing to %q: %v", dir, err)
}
// Setup $GOPATH directory layout.
// Yeah! I am bored of repeatedly writing "if err != nil {}"!
if os.MkdirAll(filepath.Join(dir, "bin"), 0750) != nil ||
os.MkdirAll(filepath.Join(dir, "pkg", "linux_amd64"), 0750) != nil ||
os.MkdirAll(filepath.Join(dir, "src"), 0750) != nil {
return nil, fmt.Errorf("failed to setup the $GOPATH directory structure")
}
// Create a temp file to represent the test binary.
binfile, err := ioutil.TempFile("", "testbin")
if err != nil {
return nil, fmt.Errorf("failed to create the temp file to represent the test binary: %v", err)
}
// Could have used crypto/rand instead, but it doesn't matter.
rr := rand.New(rand.NewSource(42))
bin := make([]byte, binLen)
if _, err = rr.Read(bin); err != nil {
return nil, fmt.Errorf("couldn't read from the random source: %v", err)
}
if _, err := binfile.Write(bin); err != nil {
return nil, fmt.Errorf("couldn't write to the binary file %q: %v", binfile.Name(), err)
}
if err := binfile.Close(); err != nil {
// It is arguable whether this should be fatal.
return nil, fmt.Errorf("failed to close the binary file %q: %v", binfile.Name(), err)
}
if err := os.Chtimes(binfile.Name(), time.Now(), time.Now()); err != nil {
return nil, fmt.Errorf("failed to modify the mtime of the binary file %q: %v", binfile.Name(), err)
}
// Create test source files directory.
testdir := filepath.Join(dir, "src", testPkg)
if err := os.MkdirAll(testdir, 0750); err != nil {
return nil, fmt.Errorf("failed to create test source directory %q: %v", testdir, err)
}
fgl := &fakegolist{
dir: dir,
importMap: map[string]pkg{
"example.com/proj/pkg/test": {
Dir: path.Join(dir, "src", testPkg),
ImportPath: testPkg,
Target: path.Join(dir, "pkg", "linux_amd64", testImportDir, "test.a"),
Stale: false,
TestGoFiles: []string{
"foo_test.go",
"bar_test.go",
},
TestImports: []string{
"example.com/proj/pkg/p1",
"example.com/proj/pkg/p1/c11",
"example.com/proj/pkg/p2",
"example.com/proj/cmd/p3/c12/c23",
"strings",
"testing",
},
XTestGoFiles: []string{
"xfoo_test.go",
"xbar_test.go",
"xbaz_test.go",
},
XTestImports: []string{
"example.com/proj/pkg/test",
"example.com/proj/pkg/p1",
"example.com/proj/cmd/p3/c12/c23",
"os",
"testing",
},
},
"example.com/proj/pkg/p1": {Stale: false},
"example.com/proj/pkg/p1/c11": {Stale: false},
"example.com/proj/pkg/p2": {Stale: false},
"example.com/proj/cmd/p3/c12/c23": {Stale: false},
"strings": {Stale: false},
"testing": {Stale: false},
"os": {Stale: false},
},
testFiles: []string{
"foo_test.go",
"bar_test.go",
"xfoo_test.go",
"xbar_test.go",
"xbaz_test.go",
},
binfile: binfile.Name(),
}
// Create test source files.
for _, fn := range fgl.testFiles {
fp := filepath.Join(testdir, fn)
if _, err := os.Create(fp); err != nil {
return nil, fmt.Errorf("failed to create the test file %q: %v", fp, err)
}
if err := os.Chtimes(fp, time.Now(), pastHour); err != nil {
return nil, fmt.Errorf("failed to modify the mtime of the test file %q: %v", binfile.Name(), err)
}
}
return fgl, nil
}
func (fgl *fakegolist) pkgInfo(pkgPaths []string) ([]pkg, error) {
var pkgs []pkg
for _, path := range pkgPaths {
p, ok := fgl.importMap[path]
if !ok {
return nil, fmt.Errorf("package %q not found", path)
}
pkgs = append(pkgs, p)
}
return pkgs, nil
}
func (fgl *fakegolist) chMtime(filename string, mtime time.Time) error {
for _, fn := range fgl.testFiles {
if fn == filename {
fp := filepath.Join(fgl.dir, "src", testPkg, fn)
if err := os.Chtimes(fp, time.Now(), mtime); err != nil {
return fmt.Errorf("failed to modify the mtime of %q: %v", filename, err)
}
return nil
}
}
return fmt.Errorf("file %q not found", filename)
}
func (fgl *fakegolist) chStale(pkg string, stale bool) error {
if p, ok := fgl.importMap[pkg]; ok {
p.Stale = stale
fgl.importMap[pkg] = p
return nil
}
return fmt.Errorf("package %q not found", pkg)
}
func (fgl *fakegolist) cleanup() {
os.RemoveAll(fgl.dir)
os.Remove(fgl.binfile)
}
func TestIsTestStale(t *testing.T) {
cases := []struct {
fileMtime map[string]time.Time
pkgStaleness map[string]bool
result bool
}{
// Basic test: binary is fresh, all modifications were before the binary was built.
{
result: false,
},
// A local test file is new, hence binary must be stale.
{
fileMtime: map[string]time.Time{
"foo_test.go": time.Now().Add(1 * time.Hour),
},
result: true,
},
// Test package is new, so binary must be stale.
{
pkgStaleness: map[string]bool{
"example.com/proj/pkg/test": true,
},
result: true,
},
// Test package dependencies are new, so binary must be stale.
{
pkgStaleness: map[string]bool{
"example.com/proj/cmd/p3/c12/c23": true,
"strings": true,
},
result: true,
},
// External test files are new, hence binary must be stale.
{
fileMtime: map[string]time.Time{
"xfoo_test.go": time.Now().Add(1 * time.Hour),
"xbar_test.go": time.Now().Add(2 * time.Hour),
},
result: true,
},
// External test dependency is new, so binary must be stale.
{
pkgStaleness: map[string]bool{
"os": true,
},
result: true,
},
// Multiple source files and dependencies are new, so binary must be stale.
{
fileMtime: map[string]time.Time{
"foo_test.go": time.Now().Add(1 * time.Hour),
"xfoo_test.go": time.Now().Add(2 * time.Hour),
"xbar_test.go": time.Now().Add(3 * time.Hour),
},
pkgStaleness: map[string]bool{
"example.com/proj/pkg/p1": true,
"example.com/proj/pkg/p1/c11": true,
"example.com/proj/pkg/p2": true,
"example.com/proj/cmd/p3/c12/c23": true,
"strings": true,
"os": true,
},
result: true,
},
// Everything is new, so binary must be stale.
{
fileMtime: map[string]time.Time{
"foo_test.go": time.Now().Add(3 * time.Hour),
"bar_test.go": time.Now().Add(1 * time.Hour),
"xfoo_test.go": time.Now().Add(2 * time.Hour),
"xbar_test.go": time.Now().Add(1 * time.Hour),
"xbaz_test.go": time.Now().Add(2 * time.Hour),
},
pkgStaleness: map[string]bool{
"example.com/proj/pkg/p1": true,
"example.com/proj/pkg/p1/c11": true,
"example.com/proj/pkg/p2": true,
"example.com/proj/cmd/p3/c12/c23": true,
"example.com/proj/pkg/test": true,
"strings": true,
"testing": true,
"os": true,
},
result: true,
},
}
for _, tc := range cases {
fgl, err := newFakegolist()
if err != nil {
t.Fatalf("failed to setup the test: %v", err)
}
defer fgl.cleanup()
for fn, mtime := range tc.fileMtime {
if err := fgl.chMtime(fn, mtime); err != nil {
t.Fatalf("failed to change the mtime of %q: %v", fn, err)
}
}
for pkg, stale := range tc.pkgStaleness {
if err := fgl.chStale(pkg, stale); err != nil {
t.Fatalf("failed to change the staleness of %q: %v", pkg, err)
}
}
if tc.result != isTestStale(fgl, fgl.binfile, testPkg) {
if tc.result {
t.Errorf("Expected test package %q to be stale", testPkg)
} else {
t.Errorf("Expected test package %q to be not stale", testPkg)
}
}
}
}

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#

View File

@ -46,6 +46,7 @@ func parse(args []string) (flags, error) {
fs := flag.NewFlagSet(args[0], flag.ContinueOnError)
get := fs.Bool("get", getDefault, "go get -u kubetest if old or not installed")
old := fs.Duration("old", oldDefault, "Consider kubetest old if it exceeds this")
verbose := fs.Bool("v", true, "this flag is translated to kubetest's --verbose-commands")
var a []string
if err := fs.Parse(args[1:]); err == flag.ErrHelp {
os.Stderr.WriteString(" -- kubetestArgs\n")
@ -58,7 +59,8 @@ func parse(args []string) (flags, error) {
log.Print(" The -- flag separator also suppresses this message")
a = args[len(args)-fs.NArg()-1:]
} else {
a = fs.Args()
a = append(a, fmt.Sprintf("--verbose-commands=%t", *verbose))
a = append(a, fs.Args()...)
}
return flags{*get, *old, a}, nil
}

View File

@ -62,14 +62,24 @@ func TestParse(t *testing.T) {
expected flags
err error
}{
{
[]string{"foo", "-v=false"},
flags{getDefault, oldDefault, []string{"--verbose-commands=false"}},
nil,
},
{
[]string{"foo", "-v"},
flags{getDefault, oldDefault, []string{"--verbose-commands=true"}},
nil,
},
{
[]string{"hello", "world"},
flags{getDefault, oldDefault, []string{"world"}},
flags{getDefault, oldDefault, []string{"--verbose-commands=true", "world"}},
nil,
},
{
[]string{"hello", "--", "--venus", "--karaoke"},
flags{getDefault, oldDefault, []string{"--venus", "--karaoke"}},
flags{getDefault, oldDefault, []string{"--verbose-commands=true", "--venus", "--karaoke"}},
nil,
},
{
@ -84,12 +94,12 @@ func TestParse(t *testing.T) {
},
{
[]string{"omg", "--get=false", "--", "ugh"},
flags{false, oldDefault, []string{"ugh"}},
flags{false, oldDefault, []string{"--verbose-commands=true", "ugh"}},
nil,
},
{
[]string{"wee", "--old=5m", "--get"},
flags{true, 5 * time.Minute, []string{}},
flags{true, 5 * time.Minute, []string{"--verbose-commands=true"}},
nil,
},
{
@ -104,7 +114,7 @@ func TestParse(t *testing.T) {
},
{
[]string{"wut", "--", "-h"},
flags{getDefault, oldDefault, []string{"-h"}},
flags{getDefault, oldDefault, []string{"--verbose-commands=true", "-h"}},
nil,
},
}

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#
@ -18,20 +18,18 @@ set -o errexit
set -o pipefail
set -o nounset
if [[ -z "${KUBE_ROOT:-}" ]]; then
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
fi
export KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
source "${KUBE_ROOT}/hack/lib/logging.sh"
if [[ ! -d "${KUBE_ROOT}/examples" ]]; then
echo "${KUBE_ROOT}/examples not detected. This script should be run from a location where the source dirs are available."
if [[ ! -d "${KUBE_ROOT}/pkg" ]]; then
echo "${KUBE_ROOT}/pkg not detected. This script should be run from a location where the source dirs are available."
exit 1
fi
# kube::golang::build_kube_toolchain installs the vendored go-bindata in
# $GOPATH/bin, so make sure that's explicitly part of our $PATH.
export PATH="${GOPATH}/bin:${PATH}"
export PATH="${KUBE_OUTPUT_BINPATH}:${PATH}"
if ! which go-bindata &>/dev/null ; then
echo "Cannot find go-bindata."
@ -43,9 +41,10 @@ pushd "${KUBE_ROOT}" >/dev/null
# These are files for e2e tests.
BINDATA_OUTPUT="test/e2e/generated/bindata.go"
# IMPORTANT: if you make any changes to these arguments, you must also update
# test/e2e/generated/BUILD and/or build/bindata.bzl.
go-bindata -nometadata -o "${BINDATA_OUTPUT}.tmp" -pkg generated \
-ignore .jpg -ignore .png -ignore .md \
"examples/..." \
-ignore .jpg -ignore .png -ignore .md -ignore 'BUILD(\.bazel)?' \
"test/e2e/testing-manifests/..." \
"test/images/..." \
"test/fixtures/..."
@ -66,8 +65,10 @@ rm -f "${BINDATA_OUTPUT}.tmp"
# These are files for runtime code
BINDATA_OUTPUT="pkg/generated/bindata.go"
# IMPORTANT: if you make any changes to these arguments, you must also update
# pkg/generated/BUILD and/or build/bindata.bzl.
go-bindata -nometadata -nocompress -o "${BINDATA_OUTPUT}.tmp" -pkg generated \
-ignore .jpg -ignore .png -ignore .md \
-ignore .jpg -ignore .png -ignore .md -ignore 'BUILD(\.bazel)?' \
"translations/..."
gofmt -s -w "${BINDATA_OUTPUT}.tmp"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#
@ -159,7 +159,8 @@ export PATH=$(dirname "${e2e_test}"):"${PATH}"
--network="${KUBE_GCE_NETWORK:-${KUBE_GKE_NETWORK:-e2e}}" \
--node-tag="${NODE_TAG:-}" \
--master-tag="${MASTER_TAG:-}" \
--cluster-monitoring-mode="${KUBE_ENABLE_CLUSTER_MONITORING:-influxdb}" \
--cluster-monitoring-mode="${KUBE_ENABLE_CLUSTER_MONITORING:-standalone}" \
--prometheus-monitoring="${KUBE_ENABLE_PROMETHEUS_MONITORING:-false}" \
${KUBE_CONTAINER_RUNTIME:+"--container-runtime=${KUBE_CONTAINER_RUNTIME}"} \
${MASTER_OS_DISTRIBUTION:+"--master-os-distro=${MASTER_OS_DISTRIBUTION}"} \
${NODE_OS_DISTRIBUTION:+"--node-os-distro=${NODE_OS_DISTRIBUTION}"} \

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2017 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#
@ -59,6 +59,8 @@ REQUIRED_BINS=(
"github.com/jteeuwen/go-bindata/go-bindata"
"github.com/tools/godep"
"github.com/client9/misspell/cmd/misspell"
"github.com/bazelbuild/bazel-gazelle/cmd/gazelle"
"github.com/kubernetes/repo-infra/kazel"
"./..."
)
@ -81,6 +83,11 @@ done
rm -rf vendor/github.com/docker/docker/project/
kube::log::status "Updating BUILD files"
# Assume that anything imported through godep doesn't need Bazel to build.
# Prune out any Bazel build files, since these can break the build due to
# missing dependencies that aren't included by godep.
find vendor/ -type f \( -name BUILD -o -name BUILD.bazel -o -name WORKSPACE \) \
-exec rm -f {} \;
hack/update-bazel.sh >/dev/null
kube::log::status "Updating LICENSES file"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -17,6 +17,15 @@
ignoredSubTrees:
- "./pkg/apis/core/validation"
- baseImportPath: "./pkg/kubectl/genericclioptions/"
allowedImports:
- k8s.io/apimachinery
- k8s.io/client-go
# TODO this one should be tightened. We depend on it for testing, but we should instead create our own scheme
- k8s.io/api/core/v1
- k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers
- k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource
- baseImportPath: "./vendor/k8s.io/apimachinery/"
allowedImports:
- k8s.io/apimachinery
@ -41,6 +50,28 @@
- k8s.io/apimachinery
- k8s.io/client-go
# prevent core machinery from taking explicit v1 references unless
# necessary
- baseImportPath: "./vendor/k8s.io/client-go/rest/"
excludeTests: true
allowedImports:
- k8s.io/apimachinery
- k8s.io/client-go
- baseImportPath: "./vendor/k8s.io/client-go/tools/"
excludeTests: true
ignoredSubTrees:
- "./vendor/k8s.io/client-go/tools/bootstrap/token/api"
- "./vendor/k8s.io/client-go/tools/cache/testing"
- "./vendor/k8s.io/client-go/tools/leaderelection/resourcelock"
- "./vendor/k8s.io/client-go/tools/portforward"
- "./vendor/k8s.io/client-go/tools/record"
- "./vendor/k8s.io/client-go/tools/reference"
- "./vendor/k8s.io/client-go/tools/remotecommand"
allowedImports:
- k8s.io/apimachinery
- k8s.io/client-go
- baseImportPath: "./vendor/k8s.io/apiserver/"
allowedImports:
- k8s.io/api

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#
@ -40,5 +40,4 @@ export LOG_LEVEL=4
cd /go/src/k8s.io/kubernetes
./hack/install-etcd.sh
make verify

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#
@ -16,7 +16,7 @@
# A set of helpers for starting/running etcd for tests
ETCD_VERSION=${ETCD_VERSION:-3.2.14}
ETCD_VERSION=${ETCD_VERSION:-3.2.18}
ETCD_HOST=${ETCD_HOST:-127.0.0.1}
ETCD_PORT=${ETCD_PORT:-2379}
@ -103,6 +103,9 @@ kube::etcd::cleanup() {
kube::etcd::install() {
(
cd "${KUBE_ROOT}/third_party"
if [[ $(readlink etcd) == etcd-v${ETCD_VERSION}-* ]]; then
return # already installed
fi
if [[ $(uname) == "Darwin" ]]; then
download_file="etcd-v${ETCD_VERSION}-darwin-amd64.zip"
url="https://github.com/coreos/etcd/releases/download/v${ETCD_VERSION}/${download_file}"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#
@ -213,17 +213,27 @@ readonly KUBE_STATIC_LIBRARIES=(
kubectl
)
# Add any files with those //generate annotations in the array below.
readonly KUBE_BINDATAS=(
test/e2e/generated/gobindata_util.go
)
# KUBE_CGO_OVERRIDES is a space-separated list of binaries which should be built
# with CGO enabled, assuming CGO is supported on the target platform.
# This overrides any entry in KUBE_STATIC_LIBRARIES.
IFS=" " read -ra KUBE_CGO_OVERRIDES <<< "${KUBE_CGO_OVERRIDES:-}"
readonly KUBE_CGO_OVERRIDES
# KUBE_STATIC_OVERRIDES is a space-separated list of binaries which should be
# built with CGO disabled. This is in addition to the list in
# KUBE_STATIC_LIBRARIES.
IFS=" " read -ra KUBE_STATIC_OVERRIDES <<< "${KUBE_STATIC_OVERRIDES:-}"
readonly KUBE_STATIC_OVERRIDES
kube::golang::is_statically_linked_library() {
local e
# Explicitly enable cgo when building kubectl for darwin from darwin.
[[ "$(go env GOHOSTOS)" == "darwin" && "$(go env GOOS)" == "darwin" &&
"$1" == *"/kubectl" ]] && return 1
if [[ -n "${KUBE_CGO_OVERRIDES:+x}" ]]; then
for e in "${KUBE_CGO_OVERRIDES[@]}"; do [[ "$1" == *"/$e" ]] && return 1; done;
fi
for e in "${KUBE_STATIC_LIBRARIES[@]}"; do [[ "$1" == *"/$e" ]] && return 0; done;
# Allow individual overrides--e.g., so that you can get a static build of
# kubectl for inclusion in a container.
if [ -n "${KUBE_STATIC_OVERRIDES:+x}" ]; then
if [[ -n "${KUBE_STATIC_OVERRIDES:+x}" ]]; then
for e in "${KUBE_STATIC_OVERRIDES[@]}"; do [[ "$1" == *"/$e" ]] && return 0; done;
fi
return 1;
@ -326,7 +336,7 @@ EOF
local go_version
IFS=" " read -ra go_version <<< "$(go version)"
local minimum_go_version
minimum_go_version=go1.9.1
minimum_go_version=go1.10.2
if [[ "${minimum_go_version}" != $(echo -e "${minimum_go_version}\n${go_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) && "${go_version[2]}" != "devel" ]]; then
kube::log::usage_from_stdin <<EOF
Detected go version: ${go_version[*]}.
@ -355,6 +365,7 @@ kube::golang::setup_env() {
kube::golang::create_gopath_tree
export GOPATH="${KUBE_GOPATH}"
export GOCACHE="${KUBE_GOPATH}/cache"
# Append KUBE_EXTRA_GOPATH to the GOPATH if it is defined.
if [[ -n ${KUBE_EXTRA_GOPATH:-} ]]; then
@ -416,52 +427,9 @@ kube::golang::place_bins() {
done
}
kube::golang::fallback_if_stdlib_not_installable() {
local go_root_dir=$(go env GOROOT);
local go_host_os=$(go env GOHOSTOS);
local go_host_arch=$(go env GOHOSTARCH);
local cgo_pkg_dir=${go_root_dir}/pkg/${go_host_os}_${go_host_arch}_cgo;
if [ -e ${cgo_pkg_dir} ]; then
return 0;
fi
if [ -w ${go_root_dir}/pkg ]; then
return 0;
fi
kube::log::status "+++ Warning: stdlib pkg with cgo flag not found.";
kube::log::status "+++ Warning: stdlib pkg cannot be rebuilt since ${go_root_dir}/pkg is not writable by `whoami`";
kube::log::status "+++ Warning: Make ${go_root_dir}/pkg writable for `whoami` for a one-time stdlib install, Or"
kube::log::status "+++ Warning: Rebuild stdlib using the command 'CGO_ENABLED=0 go install -a -installsuffix cgo std'";
kube::log::status "+++ Falling back to go build, which is slower";
use_go_build=true
}
# Builds the toolchain necessary for building kube. This needs to be
# built only on the host platform.
# TODO: Find this a proper home.
# Ideally, not a shell script because testing shell scripts is painful.
kube::golang::build_kube_toolchain() {
local targets=(
hack/cmd/teststale
vendor/github.com/jteeuwen/go-bindata/go-bindata
)
local binaries
binaries=($(kube::golang::binaries_from_targets "${targets[@]}"))
kube::log::status "Building the toolchain targets:" "${binaries[@]}"
go install "${goflags[@]:+${goflags[@]}}" \
-gcflags "${gogcflags}" \
-ldflags "${goldflags}" \
"${binaries[@]:+${binaries[@]}}"
}
# Try and replicate the native binary placement of go install without
# calling go install.
kube::golang::output_filename_for_binary() {
kube::golang::outfile_for_binary() {
local binary=$1
local platform=$2
local output_path="${KUBE_GOPATH}/bin"
@ -477,7 +445,6 @@ kube::golang::output_filename_for_binary() {
kube::golang::build_binaries_for_platform() {
local platform=$1
local use_go_build=${2-}
local -a statics=()
local -a nonstatics=()
@ -496,79 +463,25 @@ kube::golang::build_binaries_for_platform() {
done
if [[ "${#statics[@]}" != 0 ]]; then
kube::golang::fallback_if_stdlib_not_installable;
CGO_ENABLED=0 go install -installsuffix static "${goflags[@]:+${goflags[@]}}" \
-gcflags "${gogcflags}" \
-ldflags "${goldflags}" \
"${statics[@]:+${statics[@]}}"
fi
if [[ -n ${use_go_build:-} ]]; then
kube::log::progress " "
for binary in "${statics[@]:+${statics[@]}}"; do
local outfile=$(kube::golang::output_filename_for_binary "${binary}" "${platform}")
CGO_ENABLED=0 go build -o "${outfile}" \
"${goflags[@]:+${goflags[@]}}" \
-gcflags "${gogcflags}" \
-ldflags "${goldflags}" \
"${binary}"
kube::log::progress "*"
done
for binary in "${nonstatics[@]:+${nonstatics[@]}}"; do
local outfile=$(kube::golang::output_filename_for_binary "${binary}" "${platform}")
go build -o "${outfile}" \
"${goflags[@]:+${goflags[@]}}" \
-gcflags "${gogcflags}" \
-ldflags "${goldflags}" \
"${binary}"
kube::log::progress "*"
done
kube::log::progress "\n"
else
# Use go install.
if [[ "${#nonstatics[@]}" != 0 ]]; then
go install "${goflags[@]:+${goflags[@]}}" \
-gcflags "${gogcflags}" \
-ldflags "${goldflags}" \
"${nonstatics[@]:+${nonstatics[@]}}"
fi
if [[ "${#statics[@]}" != 0 ]]; then
CGO_ENABLED=0 go install -installsuffix cgo "${goflags[@]:+${goflags[@]}}" \
-gcflags "${gogcflags}" \
-ldflags "${goldflags}" \
"${statics[@]:+${statics[@]}}"
fi
if [[ "${#nonstatics[@]}" != 0 ]]; then
go install "${goflags[@]:+${goflags[@]}}" \
-gcflags "${gogcflags}" \
-ldflags "${goldflags}" \
"${nonstatics[@]:+${nonstatics[@]}}"
fi
for test in "${tests[@]:+${tests[@]}}"; do
local outfile=$(kube::golang::output_filename_for_binary "${test}" \
"${platform}")
local outfile=$(kube::golang::outfile_for_binary "${test}" "${platform}")
local testpkg="$(dirname ${test})"
# Staleness check always happens on the host machine, so we don't
# have to locate the `teststale` binaries for the other platforms.
# Since we place the host binaries in `$KUBE_GOPATH/bin`, we can
# assume that the binary exists there, if it exists at all.
# Otherwise, something has gone wrong with building the `teststale`
# binary and we should safely proceed building the test binaries
# assuming that they are stale. There is no good reason to error
# out.
if test -x "${KUBE_GOPATH}/bin/teststale" && ! "${KUBE_GOPATH}/bin/teststale" -binary "${outfile}" -package "${testpkg}"
then
continue
fi
# `go test -c` below directly builds the binary. It builds the packages,
# but it never installs them. `go test -i` only installs the dependencies
# of the test, but not the test package itself. So neither `go test -c`
# nor `go test -i` installs, for example, test/e2e.a. And without that,
# doing a staleness check on k8s.io/kubernetes/test/e2e package always
# returns true (always stale). And that's why we need to install the
# test package.
go install "${goflags[@]:+${goflags[@]}}" \
-gcflags "${gogcflags}" \
-ldflags "${goldflags}" \
"${testpkg}"
mkdir -p "$(dirname ${outfile})"
go test -i -c \
go test -c \
"${goflags[@]:+${goflags[@]}}" \
-gcflags "${gogcflags}" \
-ldflags "${goldflags}" \
@ -629,14 +542,11 @@ kube::golang::build_binaries() {
goldflags="${GOLDFLAGS:-} $(kube::version::ldflags)"
gogcflags="${GOGCFLAGS:-}"
local use_go_build
local -a targets=()
local arg
for arg; do
if [[ "${arg}" == "--use_go_build" ]]; then
use_go_build=true
elif [[ "${arg}" == -* ]]; then
if [[ "${arg}" == -* ]]; then
# Assume arguments starting with a dash are flags to pass to go.
goflags+=("${arg}")
else
@ -671,26 +581,14 @@ kube::golang::build_binaries() {
fi
fi
# First build the toolchain before building any other targets
kube::golang::build_kube_toolchain
kube::log::status "Generating bindata:" "${KUBE_BINDATAS[@]}"
for bindata in "${KUBE_BINDATAS[@]}"; do
# Only try to generate bindata if the file exists, since in some cases
# one-off builds of individual directories may exclude some files.
if [[ -f "${KUBE_ROOT}/${bindata}" ]]; then
go generate "${goflags[@]:+${goflags[@]}}" "${KUBE_ROOT}/${bindata}"
fi
done
if [[ "${parallel}" == "true" ]]; then
kube::log::status "Building go targets for {${platforms[*]}} in parallel (output will appear in a burst when complete):" "${targets[@]}"
local platform
for platform in "${platforms[@]}"; do (
kube::golang::set_platform_envs "${platform}"
kube::log::status "${platform}: go build started"
kube::golang::build_binaries_for_platform ${platform} ${use_go_build:-}
kube::log::status "${platform}: go build finished"
kube::log::status "${platform}: build started"
kube::golang::build_binaries_for_platform ${platform}
kube::log::status "${platform}: build finished"
) &> "/tmp//${platform//\//_}.build" &
done
@ -709,7 +607,7 @@ kube::golang::build_binaries() {
kube::log::status "Building go targets for ${platform}:" "${targets[@]}"
(
kube::golang::set_platform_envs "${platform}"
kube::golang::build_binaries_for_platform ${platform} ${use_go_build:-}
kube::golang::build_binaries_for_platform ${platform}
)
done
fi

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#
@ -81,6 +81,7 @@ rbac.authorization.k8s.io/v1 \
rbac.authorization.k8s.io/v1beta1 \
rbac.authorization.k8s.io/v1alpha1 \
scheduling.k8s.io/v1alpha1 \
scheduling.k8s.io/v1beta1 \
settings.k8s.io/v1alpha1 \
storage.k8s.io/v1beta1 \
storage.k8s.io/v1 \

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2017 The Kubernetes Authors.
#
@ -71,8 +71,7 @@ function kube::protoc::format() {
local package=${1}
# Update boilerplate for the generated file.
echo "$(cat hack/boilerplate/boilerplate.go.txt ${package}/api.pb.go)" > ${package}/api.pb.go
sed -i".bak" "s/Copyright YEAR/Copyright $(date '+%Y')/g" ${package}/api.pb.go
echo "$(cat hack/boilerplate/boilerplate.generatego.txt ${package}/api.pb.go)" > ${package}/api.pb.go
# Run gofmt to clean up the generated code.
kube::golang::verify_go_version

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#
@ -34,7 +34,7 @@ kube::swagger::gen_types_swagger_doc() {
echo "Generating swagger type docs for ${group_version} at ${gv_dir}"
sed 's/YEAR/2016/' hack/boilerplate/boilerplate.go.txt > "$TMPFILE"
echo -e "$(cat hack/boilerplate/boilerplate.generatego.txt)\n" > "$TMPFILE"
echo "package ${group_version##*/}" >> "$TMPFILE"
cat >> "$TMPFILE" <<EOF
@ -48,7 +48,7 @@ kube::swagger::gen_types_swagger_doc() {
//
// Those methods can be generated by using hack/update-generated-swagger-docs.sh
// AUTO-GENERATED FUNCTIONS START HERE
// AUTO-GENERATED FUNCTIONS START HERE. DO NOT EDIT.
EOF
go run cmd/genswaggertypedocs/swagger_type_docs.go -s \

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#
@ -76,7 +76,7 @@ kube::test::object_assert() {
local args=${5:-}
for j in $(seq 1 ${tries}); do
res=$(eval kubectl get -a "${kube_flags[@]}" ${args} $object -o go-template=\"$request\")
res=$(eval kubectl get "${kube_flags[@]}" ${args} $object -o go-template=\"$request\")
if [[ "$res" =~ ^$expected$ ]]; then
echo -n ${green}
echo "$(kube::test::get_caller 3): Successful get $object $request: $res"
@ -103,7 +103,7 @@ kube::test::get_object_jsonpath_assert() {
local request=$2
local expected=$3
res=$(eval kubectl get -a "${kube_flags[@]}" $object -o jsonpath=\"$request\")
res=$(eval kubectl get "${kube_flags[@]}" $object -o jsonpath=\"$request\")
if [[ "$res" =~ ^$expected$ ]]; then
echo -n ${green}

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#
@ -23,6 +23,7 @@ kube::util::wait_for_url() {
local prefix=${2:-}
local wait=${3:-1}
local times=${4:-30}
local maxtime=${5:-1}
which curl >/dev/null || {
kube::log::usage "curl must be installed"
@ -32,7 +33,7 @@ kube::util::wait_for_url() {
local i
for i in $(seq 1 "$times"); do
local out
if out=$(curl --max-time 1 -gkfs "$url" 2>/dev/null); then
if out=$(curl --max-time "$maxtime" -gkfs "$url" 2>/dev/null); then
kube::log::status "On try ${i}, ${prefix}: ${out}"
return 0
fi
@ -275,9 +276,6 @@ kube::util::group-version-to-pkg-path() {
meta/v1beta1)
echo "vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1"
;;
unversioned)
echo "pkg/api/unversioned"
;;
*.k8s.io)
echo "pkg/apis/${group_version%.*k8s.io}"
;;
@ -430,7 +428,7 @@ kube::util::ensure_clean_working_dir() {
# Ensure that the given godep version is installed and in the path. Almost
# nobody should use any version but the default.
kube::util::ensure_godep_version() {
GODEP_VERSION=${1:-"v79"} # this version is known to work
GODEP_VERSION=${1:-"v80"} # this version is known to work
if [[ "$(godep version 2>/dev/null)" == *"godep ${GODEP_VERSION}"* ]]; then
return
@ -438,12 +436,19 @@ kube::util::ensure_godep_version() {
kube::log::status "Installing godep version ${GODEP_VERSION}"
go install ./vendor/github.com/tools/godep/
GP="$(echo $GOPATH | cut -f1 -d:)"
hash -r # force bash to clear PATH cache
PATH="${GP}/bin:${PATH}"
if ! which godep >/dev/null 2>&1; then
kube::log::error "Can't find godep - is your GOPATH 'bin' in your PATH?"
kube::log::error " GOPATH: ${GOPATH}"
kube::log::error " PATH: ${PATH}"
return 1
fi
if [[ "$(godep version 2>/dev/null)" != *"godep ${GODEP_VERSION}"* ]]; then
kube::log::error "Expected godep ${GODEP_VERSION}, got $(godep version)"
kube::log::error "Wrong godep version - is your GOPATH 'bin' in your PATH?"
kube::log::error " expected: godep ${GODEP_VERSION}"
kube::log::error " got: $(godep version)"
kube::log::error " GOPATH: ${GOPATH}"
kube::log::error " PATH: ${PATH}"
return 1
fi
}
@ -469,23 +474,6 @@ kube::util::ensure_no_staging_repos_in_gopath() {
fi
}
# Installs the specified go package at a particular commit.
kube::util::go_install_from_commit() {
local -r pkg=$1
local -r commit=$2
kube::util::ensure-temp-dir
mkdir -p "${KUBE_TEMP}/go/src"
GOPATH="${KUBE_TEMP}/go" go get -d -u "${pkg}"
(
cd "${KUBE_TEMP}/go/src/${pkg}"
git checkout -q "${commit}"
GOPATH="${KUBE_TEMP}/go" go install "${pkg}"
)
PATH="${KUBE_TEMP}/go/bin:${PATH}"
hash -r # force bash to clear PATH cache
}
# Checks that the GOPATH is simple, i.e. consists only of one directory, not multiple.
kube::util::ensure_single_dir_gopath() {
if [[ "${GOPATH}" == *:* ]]; then
@ -566,7 +554,7 @@ function kube::util::create_signing_certkey {
local id=$3
local purpose=$4
# Create client ca
${sudo} /bin/bash -e <<EOF
${sudo} /usr/bin/env bash -e <<EOF
rm -f "${dest_dir}/${id}-ca.crt" "${dest_dir}/${id}-ca.key"
${OPENSSL_BIN} req -x509 -sha256 -new -nodes -days 365 -newkey rsa:2048 -keyout "${dest_dir}/${id}-ca.key" -out "${dest_dir}/${id}-ca.crt" -subj "/C=xx/ST=x/L=x/O=x/OU=x/CN=ca/emailAddress=x/"
echo '{"signing":{"default":{"expiry":"43800h","usages":["signing","key encipherment",${purpose}]}}}' > "${dest_dir}/${id}-ca-config.json"
@ -588,7 +576,7 @@ function kube::util::create_client_certkey {
SEP=","
shift 1
done
${sudo} /bin/bash -e <<EOF
${sudo} /usr/bin/env bash -e <<EOF
cd ${dest_dir}
echo '{"CN":"${cn}","names":[${groups}],"hosts":[""],"key":{"algo":"rsa","size":2048}}' | ${CFSSL_BIN} gencert -ca=${ca}.crt -ca-key=${ca}.key -config=${ca}-config.json - | ${CFSSLJSON_BIN} -bare client-${id}
mv "client-${id}-key.pem" "client-${id}.key"
@ -612,7 +600,7 @@ function kube::util::create_serving_certkey {
SEP=","
shift 1
done
${sudo} /bin/bash -e <<EOF
${sudo} /usr/bin/env bash -e <<EOF
cd ${dest_dir}
echo '{"CN":"${cn}","hosts":[${hosts}],"key":{"algo":"rsa","size":2048}}' | ${CFSSL_BIN} gencert -ca=${ca}.crt -ca-key=${ca}.key -config=${ca}-config.json - | ${CFSSLJSON_BIN} -bare serving-${id}
mv "serving-${id}-key.pem" "serving-${id}.key"
@ -654,7 +642,7 @@ EOF
# flatten the kubeconfig files to make them self contained
username=$(whoami)
${sudo} /bin/bash -e <<EOF
${sudo} /usr/bin/env bash -e <<EOF
$(kube::util::find-binary kubectl) --kubeconfig="${dest_dir}/${client_id}.kubeconfig" config view --minify --flatten > "/tmp/${client_id}.kubeconfig"
mv -f "/tmp/${client_id}.kubeconfig" "${dest_dir}/${client_id}.kubeconfig"
chown ${username} "${dest_dir}/${client_id}.kubeconfig"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#
@ -45,7 +45,7 @@ kube::version::get_version_vars() {
# When a 'git archive' is exported, the '$Format:%D$' below will look
# something like 'HEAD -> release-1.8, tag: v1.8.3' where then 'tag: '
# can be extracted from it.
if [[ '$Format:%D$' =~ tag:\ (v[^ ]+) ]]; then
if [[ '$Format:%D$' =~ tag:\ (v[^ ,]+) ]]; then
KUBE_GIT_VERSION="${BASH_REMATCH[1]}"
fi
fi
@ -99,7 +99,7 @@ kube::version::get_version_vars() {
# If KUBE_GIT_VERSION is not a valid Semantic Version, then refuse to build.
if ! [[ "${KUBE_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
echo "KUBE_GIT_VERSION should be a valid Semantic Version"
echo "KUBE_GIT_VERSION should be a valid Semantic Version. Current value: ${KUBE_GIT_VERSION}"
echo "Please see more details here: https://semver.org"
exit 1
fi

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#
@ -22,6 +22,7 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
DOCKER_OPTS=${DOCKER_OPTS:-""}
DOCKER=(docker ${DOCKER_OPTS})
DOCKERIZE_KUBELET=${DOCKERIZE_KUBELET:-""}
DOCKER_ROOT=${DOCKER_ROOT:-""}
ALLOW_PRIVILEGED=${ALLOW_PRIVILEGED:-""}
DENY_SECURITY_CONTEXT_ADMISSION=${DENY_SECURITY_CONTEXT_ADMISSION:-""}
PSP_ADMISSION=${PSP_ADMISSION:-""}
@ -31,6 +32,7 @@ KUBELET_AUTHORIZATION_WEBHOOK=${KUBELET_AUTHORIZATION_WEBHOOK:-""}
KUBELET_AUTHENTICATION_WEBHOOK=${KUBELET_AUTHENTICATION_WEBHOOK:-""}
POD_MANIFEST_PATH=${POD_MANIFEST_PATH:-"/var/run/kubernetes/static-pods"}
KUBELET_FLAGS=${KUBELET_FLAGS:-""}
KUBELET_IMAGE=${KUBELET_IMAGE:-""}
# many dev environments run with swap on, so we don't fail in this env
FAIL_SWAP_ON=${FAIL_SWAP_ON:-"false"}
# Name of the network plugin, eg: "kubenet"
@ -61,8 +63,9 @@ KUBE_PROXY_MODE=${KUBE_PROXY_MODE:-""}
ENABLE_CLUSTER_DNS=${KUBE_ENABLE_CLUSTER_DNS:-true}
DNS_SERVER_IP=${KUBE_DNS_SERVER_IP:-10.0.0.10}
DNS_DOMAIN=${KUBE_DNS_NAME:-"cluster.local"}
KUBECTL=${KUBECTL:-cluster/kubectl.sh}
KUBECTL=${KUBECTL:-"${KUBE_ROOT}/cluster/kubectl.sh"}
WAIT_FOR_URL_API_SERVER=${WAIT_FOR_URL_API_SERVER:-60}
MAX_TIME_FOR_URL_API_SERVER=${MAX_TIME_FOR_URL_API_SERVER:-1}
ENABLE_DAEMON=${ENABLE_DAEMON:-false}
HOSTNAME_OVERRIDE=${HOSTNAME_OVERRIDE:-"127.0.0.1"}
EXTERNAL_CLOUD_PROVIDER=${EXTERNAL_CLOUD_PROVIDER:-false}
@ -71,6 +74,8 @@ CLOUD_PROVIDER=${CLOUD_PROVIDER:-""}
CLOUD_CONFIG=${CLOUD_CONFIG:-""}
FEATURE_GATES=${FEATURE_GATES:-"AllAlpha=false"}
STORAGE_BACKEND=${STORAGE_BACKEND:-"etcd3"}
# preserve etcd data. you also need to set ETCD_DIR.
PRESERVE_ETCD="${PRESERVE_ETCD:-false}"
# enable swagger ui
ENABLE_SWAGGER_UI=${ENABLE_SWAGGER_UI:-false}
# enable Pod priority and preemption
@ -90,8 +95,9 @@ AUTH_ARGS=${AUTH_ARGS:-""}
# Install a default storage class (enabled by default)
DEFAULT_STORAGE_CLASS=${KUBE_DEFAULT_STORAGE_CLASS:-true}
# start the cache mutation detector by default so that cache mutators will be found
KUBE_CACHE_MUTATION_DETECTOR="${KUBE_CACHE_MUTATION_DETECTOR:-true}"
# Do not run the mutation detector by default on a local cluster.
# It is intended for a specific type of testing and inherently leaks memory.
KUBE_CACHE_MUTATION_DETECTOR="${KUBE_CACHE_MUTATION_DETECTOR:-false}"
export KUBE_CACHE_MUTATION_DETECTOR
# panic the server on watch decode errors since they are considered coder mistakes
@ -120,13 +126,11 @@ if [ "${CLOUD_PROVIDER}" == "openstack" ]; then
fi
fi
# set feature gates if using ipvs mode
# load required kernel modules if proxy mode is set to "ipvs".
if [ "${KUBE_PROXY_MODE}" == "ipvs" ]; then
# If required kernel modules are not available, fall back to iptables.
sudo modprobe -a ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh nf_conntrack_ipv4
if [[ $? -eq 0 ]]; then
FEATURE_GATES="${FEATURE_GATES},SupportIPVSProxyMode=true"
else
if [[ $? -ne 0 ]]; then
echo "Required kernel modules for ipvs not found. Falling back to iptables mode."
KUBE_PROXY_MODE=iptables
fi
@ -139,7 +143,7 @@ fi
# warn if users are running with swap allowed
if [ "${FAIL_SWAP_ON}" == "false" ]; then
echo "WARNING : The kubelet is configured to not fail if swap is enabled; production deployments should disable swap."
echo "WARNING : The kubelet is configured to not fail even if swap is enabled; production deployments should disable swap."
fi
if [ "$(id -u)" != "0" ]; then
@ -203,23 +207,6 @@ else
echo "skipped the build."
fi
function test_rkt {
if [[ -n "${RKT_PATH}" ]]; then
${RKT_PATH} list 2> /dev/null 1> /dev/null
if [ "$?" != "0" ]; then
echo "Failed to successfully run 'rkt list', please verify that ${RKT_PATH} is the path of rkt binary."
exit 1
fi
else
rkt list 2> /dev/null 1> /dev/null
if [ "$?" != "0" ]; then
echo "Failed to successfully run 'rkt list', please verify that rkt is in \$PATH."
exit 1
fi
fi
}
# Shut down anyway if there's an error.
set +e
@ -230,6 +217,7 @@ API_SECURE_PORT=${API_SECURE_PORT:-6443}
API_HOST=${API_HOST:-localhost}
API_HOST_IP=${API_HOST_IP:-"127.0.0.1"}
ADVERTISE_ADDRESS=${ADVERTISE_ADDRESS:-""}
NODE_PORT_RANGE=${NODE_PORT_RANGE:-""}
API_BIND_ADDR=${API_BIND_ADDR:-"0.0.0.0"}
EXTERNAL_HOSTNAME=${EXTERNAL_HOSTNAME:-localhost}
@ -244,8 +232,6 @@ LOG_DIR=${LOG_DIR:-"/tmp"}
CONTAINER_RUNTIME=${CONTAINER_RUNTIME:-"docker"}
CONTAINER_RUNTIME_ENDPOINT=${CONTAINER_RUNTIME_ENDPOINT:-""}
IMAGE_SERVICE_ENDPOINT=${IMAGE_SERVICE_ENDPOINT:-""}
RKT_PATH=${RKT_PATH:-""}
RKT_STAGE1_IMAGE=${RKT_STAGE1_IMAGE:-""}
CHAOS_CHANCE=${CHAOS_CHANCE:-0.0}
CPU_CFS_QUOTA=${CPU_CFS_QUOTA:-true}
ENABLE_HOSTPATH_PROVISIONER=${ENABLE_HOSTPATH_PROVISIONER:-"false"}
@ -355,6 +341,13 @@ cleanup_dockerized_kubelet()
if [[ -e $KUBELET_CIDFILE ]]; then
docker kill $(<$KUBELET_CIDFILE) > /dev/null
rm -f $KUBELET_CIDFILE
# Save the docker logs
if [[ -f /var/log/docker.log ]]; then
sudo cp /var/log/docker.log ${LOG_DIR}/docker.log
elif command -v journalctl &>/dev/null; then
journalctl -u docker --no-pager > ${LOG_DIR}/docker.log
fi
fi
}
@ -371,35 +364,73 @@ cleanup()
# Check if the API server is still running
[[ -n "${APISERVER_PID-}" ]] && APISERVER_PIDS=$(pgrep -P ${APISERVER_PID} ; ps -o pid= -p ${APISERVER_PID})
[[ -n "${APISERVER_PIDS-}" ]] && sudo kill ${APISERVER_PIDS}
[[ -n "${APISERVER_PIDS-}" ]] && sudo kill ${APISERVER_PIDS} 2>/dev/null
# Check if the controller-manager is still running
[[ -n "${CTLRMGR_PID-}" ]] && CTLRMGR_PIDS=$(pgrep -P ${CTLRMGR_PID} ; ps -o pid= -p ${CTLRMGR_PID})
[[ -n "${CTLRMGR_PIDS-}" ]] && sudo kill ${CTLRMGR_PIDS}
[[ -n "${CTLRMGR_PIDS-}" ]] && sudo kill ${CTLRMGR_PIDS} 2>/dev/null
if [[ -n "$DOCKERIZE_KUBELET" ]]; then
cleanup_dockerized_kubelet
else
# Check if the kubelet is still running
[[ -n "${KUBELET_PID-}" ]] && KUBELET_PIDS=$(pgrep -P ${KUBELET_PID} ; ps -o pid= -p ${KUBELET_PID})
[[ -n "${KUBELET_PIDS-}" ]] && sudo kill ${KUBELET_PIDS}
[[ -n "${KUBELET_PIDS-}" ]] && sudo kill ${KUBELET_PIDS} 2>/dev/null
fi
# Check if the proxy is still running
[[ -n "${PROXY_PID-}" ]] && PROXY_PIDS=$(pgrep -P ${PROXY_PID} ; ps -o pid= -p ${PROXY_PID})
[[ -n "${PROXY_PIDS-}" ]] && sudo kill ${PROXY_PIDS}
[[ -n "${PROXY_PIDS-}" ]] && sudo kill ${PROXY_PIDS} 2>/dev/null
# Check if the scheduler is still running
[[ -n "${SCHEDULER_PID-}" ]] && SCHEDULER_PIDS=$(pgrep -P ${SCHEDULER_PID} ; ps -o pid= -p ${SCHEDULER_PID})
[[ -n "${SCHEDULER_PIDS-}" ]] && sudo kill ${SCHEDULER_PIDS}
[[ -n "${SCHEDULER_PIDS-}" ]] && sudo kill ${SCHEDULER_PIDS} 2>/dev/null
# Check if the etcd is still running
[[ -n "${ETCD_PID-}" ]] && kube::etcd::stop
[[ -n "${ETCD_DIR-}" ]] && kube::etcd::clean_etcd_dir
if [[ "${PRESERVE_ETCD}" == "false" ]]; then
[[ -n "${ETCD_DIR-}" ]] && kube::etcd::clean_etcd_dir
fi
exit 0
}
# Check if all processes are still running. Prints a warning once each time
# a process dies unexpectedly.
function healthcheck {
if [[ -n "${APISERVER_PID-}" ]] && ! sudo kill -0 ${APISERVER_PID} 2>/dev/null; then
warning "API server terminated unexpectedly, see ${APISERVER_LOG}"
APISERVER_PID=
fi
if [[ -n "${CTLRMGR_PID-}" ]] && ! sudo kill -0 ${CTLRMGR_PID} 2>/dev/null; then
warning "kube-controller-manager terminated unexpectedly, see ${CTLRMGR_LOG}"
CTLRMGR_PID=
fi
if [[ -n "$DOCKERIZE_KUBELET" ]]; then
# TODO (https://github.com/kubernetes/kubernetes/issues/62474): check health also in this case
:
elif [[ -n "${KUBELET_PID-}" ]] && ! sudo kill -0 ${KUBELET_PID} 2>/dev/null; then
warning "kubelet terminated unexpectedly, see ${KUBELET_LOG}"
KUBELET_PID=
fi
if [[ -n "${PROXY_PID-}" ]] && ! sudo kill -0 ${PROXY_PID} 2>/dev/null; then
warning "kube-proxy terminated unexpectedly, see ${PROXY_LOG}"
PROXY_PID=
fi
if [[ -n "${SCHEDULER_PID-}" ]] && ! sudo kill -0 ${SCHEDULER_PID} 2>/dev/null; then
warning "scheduler terminated unexpectedly, see ${SCHEDULER_LOG}"
SCHEDULER_PID=
fi
if [[ -n "${ETCD_PID-}" ]] && ! sudo kill -0 ${ETCD_PID} 2>/dev/null; then
warning "etcd terminated unexpectedly"
ETCD_PID=
fi
}
function warning {
message=$1
@ -446,7 +477,7 @@ function start_apiserver {
# Admission Controllers to invoke prior to persisting objects in cluster
#
# The order defined here dose not matter.
ENABLE_ADMISSION_PLUGINS=Initializers,LimitRanger,ServiceAccount${security_admission},DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota,PodPreset,StorageObjectInUseProtection
ENABLE_ADMISSION_PLUGINS=Initializers,LimitRanger,ServiceAccount${security_admission},DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota,StorageObjectInUseProtection
audit_arg=""
APISERVER_BASIC_AUDIT_LOG=""
@ -487,13 +518,6 @@ function start_apiserver {
RUNTIME_CONFIG+="admissionregistration.k8s.io/v1alpha1"
fi
if [[ ${ENABLE_ADMISSION_PLUGINS} == *"PodPreset"* ]]; then
if [[ -n "${RUNTIME_CONFIG}" ]]; then
RUNTIME_CONFIG+=","
fi
RUNTIME_CONFIG+="settings.k8s.io/v1alpha1"
fi
runtime_config=""
if [[ -n "${RUNTIME_CONFIG}" ]]; then
runtime_config="--runtime-config=${RUNTIME_CONFIG}"
@ -508,6 +532,10 @@ function start_apiserver {
if [[ "${ADVERTISE_ADDRESS}" != "" ]] ; then
advertise_address="--advertise-address=${ADVERTISE_ADDRESS}"
fi
node_port_range=""
if [[ "${NODE_PORT_RANGE}" != "" ]] ; then
node_port_range="--service-node-port-range=${NODE_PORT_RANGE}"
fi
# Create CA signers
if [[ "${ENABLE_SINGLE_CA_SIGNER:-}" = true ]]; then
@ -549,6 +577,7 @@ function start_apiserver {
${CONTROLPLANE_SUDO} "${GO_OUT}/hyperkube" apiserver ${swagger_arg} ${audit_arg} ${authorizer_arg} ${priv_arg} ${runtime_config} \
${cloud_config_arg} \
${advertise_address} \
${node_port_range} \
--v=${LOG_LEVEL} \
--vmodule="${LOG_SPEC}" \
--cert-dir="${CERT_DIR}" \
@ -581,10 +610,7 @@ function start_apiserver {
# Wait for kube-apiserver to come up before launching the rest of the components.
echo "Waiting for apiserver to come up"
# this uses the API port because if you don't have any authenticator, you can't seem to use the secure port at all.
# this matches what happened with the combination in 1.4.
# TODO change this conditionally based on whether API_PORT is on or off
kube::util::wait_for_url "https://${API_HOST_IP}:${API_SECURE_PORT}/healthz" "apiserver: " 1 ${WAIT_FOR_URL_API_SERVER} \
kube::util::wait_for_url "https://${API_HOST_IP}:${API_SECURE_PORT}/healthz" "apiserver: " 1 ${WAIT_FOR_URL_API_SERVER} ${MAX_TIME_FOR_URL_API_SERVER} \
|| { echo "check apiserver logs: ${APISERVER_LOG}" ; exit 1 ; }
# Create kubeconfigs for all components, using client certs
@ -684,92 +710,94 @@ function start_kubelet {
fi
mkdir -p "/var/lib/kubelet" &>/dev/null || sudo mkdir -p "/var/lib/kubelet"
if [[ -z "${DOCKERIZE_KUBELET}" ]]; then
# Enable dns
if [[ "${ENABLE_CLUSTER_DNS}" = true ]]; then
dns_args="--cluster-dns=${DNS_SERVER_IP} --cluster-domain=${DNS_DOMAIN}"
else
# To start a private DNS server set ENABLE_CLUSTER_DNS and
# DNS_SERVER_IP/DOMAIN. This will at least provide a working
# DNS server for real world hostnames.
dns_args="--cluster-dns=8.8.8.8"
fi
net_plugin_args=""
if [[ -n "${NET_PLUGIN}" ]]; then
net_plugin_args="--network-plugin=${NET_PLUGIN}"
fi
auth_args=""
if [[ -n "${KUBELET_AUTHORIZATION_WEBHOOK:-}" ]]; then
auth_args="${auth_args} --authorization-mode=Webhook"
fi
if [[ -n "${KUBELET_AUTHENTICATION_WEBHOOK:-}" ]]; then
auth_args="${auth_args} --authentication-token-webhook"
fi
if [[ -n "${CLIENT_CA_FILE:-}" ]]; then
auth_args="${auth_args} --client-ca-file=${CLIENT_CA_FILE}"
fi
cni_conf_dir_args=""
if [[ -n "${CNI_CONF_DIR}" ]]; then
cni_conf_dir_args="--cni-conf-dir=${CNI_CONF_DIR}"
fi
cni_bin_dir_args=""
if [[ -n "${CNI_BIN_DIR}" ]]; then
cni_bin_dir_args="--cni-bin-dir=${CNI_BIN_DIR}"
fi
container_runtime_endpoint_args=""
if [[ -n "${CONTAINER_RUNTIME_ENDPOINT}" ]]; then
container_runtime_endpoint_args="--container-runtime-endpoint=${CONTAINER_RUNTIME_ENDPOINT}"
fi
image_service_endpoint_args=""
if [[ -n "${IMAGE_SERVICE_ENDPOINT}" ]]; then
image_service_endpoint_args="--image-service-endpoint=${IMAGE_SERVICE_ENDPOINT}"
fi
sudo -E "${GO_OUT}/hyperkube" kubelet ${priv_arg}\
--v=${LOG_LEVEL} \
--vmodule="${LOG_SPEC}" \
--chaos-chance="${CHAOS_CHANCE}" \
--container-runtime="${CONTAINER_RUNTIME}" \
--rkt-path="${RKT_PATH}" \
--rkt-stage1-image="${RKT_STAGE1_IMAGE}" \
--hostname-override="${HOSTNAME_OVERRIDE}" \
${cloud_config_arg} \
--address="${KUBELET_HOST}" \
--kubeconfig "$CERT_DIR"/kubelet.kubeconfig \
--feature-gates="${FEATURE_GATES}" \
--cpu-cfs-quota=${CPU_CFS_QUOTA} \
--enable-controller-attach-detach="${ENABLE_CONTROLLER_ATTACH_DETACH}" \
--cgroups-per-qos=${CGROUPS_PER_QOS} \
--cgroup-driver=${CGROUP_DRIVER} \
--keep-terminated-pod-volumes=${KEEP_TERMINATED_POD_VOLUMES} \
--eviction-hard=${EVICTION_HARD} \
--eviction-soft=${EVICTION_SOFT} \
--eviction-pressure-transition-period=${EVICTION_PRESSURE_TRANSITION_PERIOD} \
--pod-manifest-path="${POD_MANIFEST_PATH}" \
--fail-swap-on="${FAIL_SWAP_ON}" \
${auth_args} \
${dns_args} \
${cni_conf_dir_args} \
${cni_bin_dir_args} \
${net_plugin_args} \
${container_runtime_endpoint_args} \
${image_service_endpoint_args} \
--port="$KUBELET_PORT" \
${KUBELET_FLAGS} >"${KUBELET_LOG}" 2>&1 &
KUBELET_PID=$!
# Quick check that kubelet is running.
if ps -p $KUBELET_PID > /dev/null ; then
echo "kubelet ( $KUBELET_PID ) is running."
else
cat ${KUBELET_LOG} ; exit 1
fi
# Enable dns
if [[ "${ENABLE_CLUSTER_DNS}" = true ]]; then
dns_args="--cluster-dns=${DNS_SERVER_IP} --cluster-domain=${DNS_DOMAIN}"
else
# To start a private DNS server set ENABLE_CLUSTER_DNS and
# DNS_SERVER_IP/DOMAIN. This will at least provide a working
# DNS server for real world hostnames.
dns_args="--cluster-dns=8.8.8.8"
fi
net_plugin_args=""
if [[ -n "${NET_PLUGIN}" ]]; then
net_plugin_args="--network-plugin=${NET_PLUGIN}"
fi
auth_args=""
if [[ -n "${KUBELET_AUTHORIZATION_WEBHOOK:-}" ]]; then
auth_args="${auth_args} --authorization-mode=Webhook"
fi
if [[ -n "${KUBELET_AUTHENTICATION_WEBHOOK:-}" ]]; then
auth_args="${auth_args} --authentication-token-webhook"
fi
if [[ -n "${CLIENT_CA_FILE:-}" ]]; then
auth_args="${auth_args} --client-ca-file=${CLIENT_CA_FILE}"
fi
cni_conf_dir_args=""
if [[ -n "${CNI_CONF_DIR}" ]]; then
cni_conf_dir_args="--cni-conf-dir=${CNI_CONF_DIR}"
fi
cni_bin_dir_args=""
if [[ -n "${CNI_BIN_DIR}" ]]; then
cni_bin_dir_args="--cni-bin-dir=${CNI_BIN_DIR}"
fi
container_runtime_endpoint_args=""
if [[ -n "${CONTAINER_RUNTIME_ENDPOINT}" ]]; then
container_runtime_endpoint_args="--container-runtime-endpoint=${CONTAINER_RUNTIME_ENDPOINT}"
fi
image_service_endpoint_args=""
if [[ -n "${IMAGE_SERVICE_ENDPOINT}" ]]; then
image_service_endpoint_args="--image-service-endpoint=${IMAGE_SERVICE_ENDPOINT}"
fi
all_kubelet_flags=(
${priv_arg}
--v="${LOG_LEVEL}"
--vmodule="${LOG_SPEC}"
--chaos-chance="${CHAOS_CHANCE}"
--container-runtime="${CONTAINER_RUNTIME}"
--hostname-override="${HOSTNAME_OVERRIDE}"
${cloud_config_arg}
--address="${KUBELET_HOST}"
--kubeconfig "$CERT_DIR"/kubelet.kubeconfig
--feature-gates="${FEATURE_GATES}"
--cpu-cfs-quota="${CPU_CFS_QUOTA}"
--enable-controller-attach-detach="${ENABLE_CONTROLLER_ATTACH_DETACH}"
--cgroups-per-qos="${CGROUPS_PER_QOS}"
--cgroup-driver="${CGROUP_DRIVER}"
--keep-terminated-pod-volumes="${KEEP_TERMINATED_POD_VOLUMES}"
--eviction-hard="${EVICTION_HARD}"
--eviction-soft="${EVICTION_SOFT}"
--eviction-pressure-transition-period="${EVICTION_PRESSURE_TRANSITION_PERIOD}"
--pod-manifest-path="${POD_MANIFEST_PATH}"
--fail-swap-on="${FAIL_SWAP_ON}"
${auth_args}
${dns_args}
${cni_conf_dir_args}
${cni_bin_dir_args}
${net_plugin_args}
${container_runtime_endpoint_args}
${image_service_endpoint_args}
--port="$KUBELET_PORT"
${KUBELET_FLAGS}
)
if [[ -z "${DOCKERIZE_KUBELET}" ]]; then
sudo -E "${GO_OUT}/hyperkube" kubelet "${all_kubelet_flags[@]}" >"${KUBELET_LOG}" 2>&1 &
KUBELET_PID=$!
else
# Build the hyperkube container image if necessary
if [[ -z "$KUBELET_IMAGE" && -n "$DOCKERIZE_KUBELET" ]]; then
HYPERKUBE_BIN="${GO_OUT}/hyperkube" REGISTRY="k8s.gcr.io" VERSION="latest" make -C "${KUBE_ROOT}/cluster/images/hyperkube" build
KUBELET_IMAGE="k8s.gcr.io/hyperkube-amd64:latest"
fi
# Docker won't run a container with a cidfile (container id file)
# unless that file does not already exist; clean up an existing
# dockerized kubelet that might be running.
@ -789,22 +817,51 @@ function start_kubelet {
if [[ -n "${cloud_cred}" ]]; then
cred_bind="--volume=${cloud_cred}:${cloud_cred}:ro"
fi
all_kubelet_flags+=(--containerized)
docker run \
--volume=/:/rootfs:ro \
all_kubelet_volumes=(
--volume=/:/rootfs:ro,rslave \
--volume=/var/run:/var/run:rw \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--volume=/var/lib/kubelet/:/var/lib/kubelet:rw \
--volume=/var/lib/docker/:/var/lib/docker:rslave \
--volume=/var/lib/kubelet/:/var/lib/kubelet:rslave \
--volume=/dev:/dev \
--volume=/run/xtables.lock:/run/xtables.lock:rw \
)
if [[ -n "${DOCKER_ROOT}" ]]; then
all_kubelet_flags+=(--root-dir="${DOCKER_ROOT}")
all_kubelet_volumes+=(--volume="${DOCKER_ROOT}:${DOCKER_ROOT}:rslave")
fi
docker run --rm --name kubelet \
"${all_kubelet_volumes[@]}" \
${cred_bind} \
--net=host \
--pid=host \
--privileged=true \
-i \
--cidfile=$KUBELET_CIDFILE \
k8s.gcr.io/kubelet \
/kubelet --v=${LOG_LEVEL} --containerized ${priv_arg}--chaos-chance="${CHAOS_CHANCE}" --pod-manifest-path="${POD_MANIFEST_PATH}" --hostname-override="${HOSTNAME_OVERRIDE}" ${cloud_config_arg} \ --address="127.0.0.1" --kubeconfig "$CERT_DIR"/kubelet.kubeconfig --port="$KUBELET_PORT" --enable-controller-attach-detach="${ENABLE_CONTROLLER_ATTACH_DETACH}" &> $KUBELET_LOG &
"${KUBELET_IMAGE}" \
/kubelet "${all_kubelet_flags[@]}" >"${KUBELET_LOG}" 2>&1 &
# Get PID of kubelet container.
for i in {1..3}; do
echo -n "Trying to get PID of kubelet container..."
KUBELET_PID=$(docker inspect kubelet -f '{{.State.Pid}}' 2>/dev/null || true)
if [[ -n ${KUBELET_PID} && ${KUBELET_PID} -gt 0 ]]; then
echo " ok, $KUBELET_PID."
break
else
echo " failed, retry in 1 second."
sleep 1
fi
done
fi
# Quick check that kubelet is running.
if [ -n "$KUBELET_PID" ] && ps -p $KUBELET_PID > /dev/null; then
echo "kubelet ( $KUBELET_PID ) is running."
else
cat ${KUBELET_LOG} ; exit 1
fi
}
@ -819,10 +876,18 @@ clientConnection:
hostnameOverride: ${HOSTNAME_OVERRIDE}
mode: ${KUBE_PROXY_MODE}
EOF
if [[ -n ${FEATURE_GATES} ]]; then
echo "featureGates:"
# Convert from foo=true,bar=false to
# foo: true
# bar: false
for gate in $(echo ${FEATURE_GATES} | tr ',' ' '); do
echo $gate | sed -e 's/\(.*\)=\(.*\)/ \1: \2/'
done
fi >>/tmp/kube-proxy.yaml
sudo "${GO_OUT}/hyperkube" proxy \
--v=${LOG_LEVEL} \
--feature-gates="${FEATURE_GATES}" \
--config=/tmp/kube-proxy.yaml \
--master="https://${API_HOST}:${API_SECURE_PORT}" >"${PROXY_LOG}" 2>&1 &
PROXY_PID=$!
@ -838,7 +903,7 @@ EOF
function start_kubedns {
if [[ "${ENABLE_CLUSTER_DNS}" = true ]]; then
cp "${KUBE_ROOT}/cluster/addons/dns/kube-dns.yaml.in" kube-dns.yaml
cp "${KUBE_ROOT}/cluster/addons/dns/kube-dns/kube-dns.yaml.in" kube-dns.yaml
sed -i -e "s/{{ pillar\['dns_domain'\] }}/${DNS_DOMAIN}/g" kube-dns.yaml
sed -i -e "s/{{ pillar\['dns_server'\] }}/${DNS_SERVER_IP}/g" kube-dns.yaml
@ -953,7 +1018,15 @@ if [[ "${KUBETEST_IN_DOCKER:-}" == "true" ]]; then
${KUBE_ROOT}/hack/install-etcd.sh
export PATH="${KUBE_ROOT}/third_party/etcd:${PATH}"
KUBE_FASTBUILD=true make ginkgo cross
apt install -y sudo
apt-get remove -y systemd
# configure shared mounts to prevent failure in DIND scenarios
mount --make-rshared /
# kubekins has a special directory for docker root
DOCKER_ROOT="/docker-graph"
fi
# validate that etcd is: not running, in path, and has minimum required version.
@ -965,10 +1038,6 @@ if [ "${CONTAINER_RUNTIME}" == "docker" ] && ! kube::util::ensure_docker_daemon_
exit 1
fi
if [[ "${CONTAINER_RUNTIME}" == "rkt" ]]; then
test_rkt
fi
if [[ "${START_MODE}" != "kubeletonly" ]]; then
test_apiserver_off
fi
@ -1029,7 +1098,7 @@ fi
print_success
if [[ "${ENABLE_DAEMON}" = false ]]; then
while true; do sleep 1; done
while true; do sleep 1; healthcheck; done
fi
if [[ "${KUBETEST_IN_DOCKER:-}" == "true" ]]; then
@ -1037,4 +1106,4 @@ if [[ "${KUBETEST_IN_DOCKER:-}" == "true" ]]; then
cluster/kubectl.sh config set-credentials myself --client-key=/var/run/kubernetes/client-admin.key --client-certificate=/var/run/kubernetes/client-admin.crt
cluster/kubectl.sh config set-context local --cluster=local --user=myself
cluster/kubectl.sh config use-context local
fi
fi

View File

@ -1,40 +0,0 @@
#!/usr/bin/env python
# Copyright 2015 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Script to print out PR info in release note format.
import json
import sys
import urllib2
PULLQUERY=("https://api.github.com/repos/"
"kubernetes/kubernetes/pulls/{pull}")
LOGIN="login"
TITLE="title"
USER="user"
def print_pulls(pulls):
for pull in pulls:
d = json.loads(urllib2.urlopen(PULLQUERY.format(pull=pull)).read())
print "* {title} #{pull} ({author})".format(
title=d[TITLE], pull=pull, author=d[USER][LOGIN])
if __name__ == "__main__":
if len(sys.argv) < 2:
print ("Usage: {cmd} <pulls>...: Prints out short " +
"markdown description for PRs appropriate for release notes.")
sys.exit(1)
print_pulls(sys.argv[1:])

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2017 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#
@ -47,8 +47,7 @@ function kfind() {
-path ./staging -o \
-path ./_\* -o \
-path ./.\* -o \
-path ./docs -o \
-path ./examples \
-path ./docs \
\) -prune \
\) \
\) \

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#
@ -57,6 +57,7 @@ kube::test::find_dirs() {
-o -path './target/*' \
-o -path './test/e2e/*' \
-o -path './test/e2e_node/*' \
-o -path './test/e2e_kubeadm/*' \
-o -path './test/integration/*' \
-o -path './third_party/*' \
-o -path './staging/*' \
@ -278,12 +279,6 @@ runTests() {
# command, which is much faster.
if [[ ! ${KUBE_COVER} =~ ^[yY]$ ]]; then
kube::log::status "Running tests without code coverage"
# `go test` does not install the things it builds. `go test -i` installs
# the build artifacts but doesn't run the tests. The two together provide
# a large speedup for tests that do not need to be rebuilt.
go test -i "${goflags[@]:+${goflags[@]}}" \
${KUBE_RACE} ${KUBE_TIMEOUT} "${@}" \
"${testargs[@]:+${testargs[@]}}"
go test "${goflags[@]:+${goflags[@]}}" \
${KUBE_RACE} ${KUBE_TIMEOUT} "${@}" \
"${testargs[@]:+${testargs[@]}}" \
@ -319,21 +314,11 @@ runTests() {
for path in $(echo $cover_ignore_dirs | sed 's/|/ /g'); do
echo -e "skipped\tk8s.io/kubernetes/$path"
done
#
# `go test` does not install the things it builds. `go test -i` installs
# the build artifacts but doesn't run the tests. The two together provide
# a large speedup for tests that do not need to be rebuilt.
printf "%s\n" "${@}" \
| grep -Ev $cover_ignore_dirs \
| xargs -I{} -n 1 -P ${KUBE_COVERPROCS} \
bash -c "set -o pipefail; _pkg=\"\$0\"; _pkg_out=\${_pkg//\//_}; \
go test -i ${goflags[@]:+${goflags[@]}} \
${KUBE_RACE} \
${KUBE_TIMEOUT} \
-cover -covermode=\"${KUBE_COVERMODE}\" \
-coverprofile=\"${cover_report_dir}/\${_pkg}/${cover_profile}\" \
\"\${_pkg}\" \
${testargs[@]:+${testargs[@]}}
go test ${goflags[@]:+${goflags[@]}} \
${KUBE_RACE} \
${KUBE_TIMEOUT} \

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#
@ -40,7 +40,6 @@ QUICK_PATTERNS+=(
"verify-api-groups.sh"
"verify-bazel.sh"
"verify-boilerplate.sh"
"verify-generated-files-remake"
"verify-godep-licenses.sh"
"verify-gofmt.sh"
"verify-imports.sh"
@ -73,6 +72,17 @@ function is-quick {
return 1
}
function is-explicitly-chosen {
local name="${1#verify-}"
name="${name%.*}"
for e in ${WHAT}; do
if [[ $e == "$name" ]]; then
return
fi
done
return 1
}
function run-cmd {
local filename="${2##*/verify-}"
local testname="${filename%%.*}"
@ -109,13 +119,19 @@ function run-checks {
for t in $(ls ${pattern})
do
local check_name="$(basename "${t}")"
if is-excluded "${t}" ; then
echo "Skipping ${check_name}"
continue
fi
if ${QUICK} && ! is-quick "${t}" ; then
echo "Skipping ${check_name} in quick mode"
continue
if [[ ! -z ${WHAT:-} ]]; then
if ! is-explicitly-chosen "${check_name}"; then
continue
fi
else
if is-excluded "${t}" ; then
echo "Skipping ${check_name}"
continue
fi
if ${QUICK} && ! is-quick "${t}" ; then
echo "Skipping ${check_name} in quick mode"
continue
fi
fi
echo -e "Verifying ${check_name}"
local start=$(date +%s)

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#
@ -40,7 +40,6 @@ ETCD_PORT=${ETCD_PORT:-2379}
ETCD_PREFIX=${ETCD_PREFIX:-randomPrefix}
API_PORT=${API_PORT:-8080}
API_HOST=${API_HOST:-127.0.0.1}
KUBE_API_VERSIONS=""
RUNTIME_CONFIG=""
ETCDCTL=$(which etcdctl)
@ -51,13 +50,12 @@ DISABLE_ADMISSION_PLUGINS="ServiceAccount,NamespaceLifecycle,LimitRanger,Mutatin
function startApiServer() {
local storage_versions=${1:-""}
local storage_media_type=${2:-""}
kube::log::status "Starting kube-apiserver with KUBE_API_VERSIONS: ${KUBE_API_VERSIONS}"
kube::log::status " and storage-media-type: ${storage_media_type}"
kube::log::status " and runtime-config: ${RUNTIME_CONFIG}"
kube::log::status " and storage-version overrides: ${storage_versions}"
kube::log::status "Starting kube-apiserver with..."
kube::log::status " storage-media-type: ${storage_media_type}"
kube::log::status " runtime-config: ${RUNTIME_CONFIG}"
kube::log::status " storage-version overrides: ${storage_versions}"
KUBE_API_VERSIONS="${KUBE_API_VERSIONS}" \
"${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \
"${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \
--insecure-bind-address="${API_HOST}" \
--bind-address="${API_HOST}" \
--insecure-port="${API_PORT}" \
@ -97,7 +95,6 @@ function cleanup() {
trap cleanup EXIT SIGINT
make -C "${KUBE_ROOT}" WHAT=cmd/kube-apiserver
make -C "${KUBE_ROOT}" WHAT=cluster/images/etcd/attachlease
kube::etcd::start
echo "${ETCD_VERSION}" > "${ETCD_DIR}/version.txt"
@ -106,11 +103,11 @@ echo "${ETCD_VERSION}" > "${ETCD_DIR}/version.txt"
# source_file,resource,namespace,name,old_version,new_version
tests=(
examples/persistent-volume-provisioning/rbd/rbd-storage-class.yaml,storageclasses,,slow,v1beta1,v1
test/e2e/testing-manifests/rbd-storage-class.yaml,storageclasses,,slow,v1beta1,v1
)
KUBE_OLD_API_VERSION="networking.k8s.io/v1,storage.k8s.io/v1beta1,extensions/v1beta1"
KUBE_NEW_API_VERSION="networking.k8s.io/v1,storage.k8s.io/v1,extensions/v1beta1"
KUBE_NEW_API_VERSION="networking.k8s.io/v1,storage.k8s.io/v1,extensions/v1beta1,policy/v1beta1"
KUBE_OLD_STORAGE_VERSIONS="storage.k8s.io/v1beta1"
KUBE_NEW_STORAGE_VERSIONS="storage.k8s.io/v1"
@ -121,8 +118,7 @@ KUBE_NEW_STORAGE_VERSIONS="storage.k8s.io/v1"
# but KUBE_OLD_API_VERSION is the latest (storage) version.
# Additionally use KUBE_STORAGE_MEDIA_TYPE_JSON for storage encoding.
#######################################################
KUBE_API_VERSIONS="v1,${KUBE_OLD_API_VERSION},${KUBE_NEW_API_VERSION}"
RUNTIME_CONFIG="api/all=false,api/v1=true,${KUBE_OLD_API_VERSION}=true,${KUBE_NEW_API_VERSION}=true"
RUNTIME_CONFIG="api/all=false,api/v1=true,apiregistration.k8s.io/v1=true,${KUBE_OLD_API_VERSION}=true,${KUBE_NEW_API_VERSION}=true"
startApiServer ${KUBE_OLD_STORAGE_VERSIONS} ${KUBE_STORAGE_MEDIA_TYPE_JSON}
@ -156,8 +152,7 @@ killApiServer
# Still use KUBE_STORAGE_MEDIA_TYPE_JSON for storage encoding.
#######################################################
KUBE_API_VERSIONS="v1,${KUBE_NEW_API_VERSION},${KUBE_OLD_API_VERSION}"
RUNTIME_CONFIG="api/all=false,api/v1=true,${KUBE_OLD_API_VERSION}=true,${KUBE_NEW_API_VERSION}=true"
RUNTIME_CONFIG="api/all=false,api/v1=true,apiregistration.k8s.io/v1=true,${KUBE_OLD_API_VERSION}=true,${KUBE_NEW_API_VERSION}=true"
startApiServer ${KUBE_NEW_STORAGE_VERSIONS} ${KUBE_STORAGE_MEDIA_TYPE_JSON}
# Update etcd objects, so that will now be stored in the new api version.
@ -187,8 +182,7 @@ killApiServer
# However, change storage encoding to KUBE_STORAGE_MEDIA_TYPE_PROTOBUF.
#######################################################
KUBE_API_VERSIONS="v1,${KUBE_NEW_API_VERSION}"
RUNTIME_CONFIG="api/all=false,api/v1=true,${KUBE_NEW_API_VERSION}=true"
RUNTIME_CONFIG="api/all=false,api/v1=true,apiregistration.k8s.io/v1=true,${KUBE_NEW_API_VERSION}=true"
# This seems to reduce flakiness.
sleep 1

View File

@ -17,6 +17,6 @@ spec:
spec:
containers:
- name: nginx
image: gcr.io/google-containers/nginx:test-cmd
image: k8s.gcr.io/nginx:test-cmd
ports:
- containerPort: 80

View File

@ -1,25 +0,0 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: web
labels:
run: web
initializers:
pending:
- name: podimage.initializer.com
spec:
replicas: 5
selector:
matchLabels:
run: web
template:
metadata:
labels:
run: web
spec:
containers:
- image: nginx:1.10
name: web
ports:
- containerPort: 80
protocol: TCP

View File

@ -9,7 +9,7 @@
"containers": [
{
"name": "kubernetes-pause",
"image": "k8s.gcr.io/pause-amd64:3.1"
"image": "k8s.gcr.io/pause:3.1"
}
],
"restartPolicy": "Never",

View File

@ -1,23 +0,0 @@
apiVersion: extensions/v1beta1
kind: ReplicaSet
metadata:
name: nginx
initializers:
pending:
- name: podimage.initializer.com
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.10
ports:
- containerPort: 80

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#

View File

@ -26,13 +26,14 @@ kube::util::ensure-gnu-sed
# TODO(spxtr): Remove this line once Bazel is the only way to build.
rm -f "${KUBE_ROOT}/pkg/generated/openapi/zz_generated.openapi.go"
# The git commit sha1s here should match the values in $KUBE_ROOT/WORKSPACE.
kube::util::go_install_from_commit \
github.com/kubernetes/repo-infra/kazel \
97099dccc8807e9159dc28f374a8f0602cab07e1
kube::util::go_install_from_commit \
github.com/bazelbuild/bazel-gazelle/cmd/gazelle \
a85b63b06c2e0c75931e57c4a1a18d4e566bb6f4
# Ensure that we find the binaries we build before anything else.
export GOBIN="${KUBE_OUTPUT_BINPATH}"
PATH="${GOBIN}:${PATH}"
# Install tools we need, but only from vendor/...
go install ./vendor/github.com/bazelbuild/bazel-gazelle/cmd/gazelle
go install ./vendor/github.com/kubernetes/repo-infra/kazel
touch "${KUBE_ROOT}/vendor/BUILD"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#
@ -72,7 +72,7 @@ INTERNAL_DIRS_CSV=$(IFS=',';echo "${INTERNAL_DIRS[*]// /,}";IFS=$)
# This can be called with one flag, --verify-only, so it works for both the
# update- and verify- scripts.
${clientgen} --input-base="k8s.io/kubernetes/pkg/apis" --input="${INTERNAL_DIRS_CSV}" "$@"
${clientgen} --output-base "${KUBE_ROOT}/vendor" --output-package="k8s.io/client-go" --clientset-name="kubernetes" --input-base="k8s.io/kubernetes/vendor/k8s.io/api" --input="${GV_DIRS_CSV}" --go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.go.txt "$@"
${clientgen} --output-base "${KUBE_ROOT}/vendor" --output-package="k8s.io/client-go" --clientset-name="kubernetes" --input-base="k8s.io/kubernetes/vendor/k8s.io/api" --input="${GV_DIRS_CSV}" --go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt "$@"
listergen_internal_apis=(
$(
@ -91,7 +91,7 @@ $(
)
)
listergen_external_apis_csv=$(IFS=,; echo "${listergen_external_apis[*]}")
${listergen} --output-base "${KUBE_ROOT}/vendor" --output-package "k8s.io/client-go/listers" --input-dirs "${listergen_external_apis_csv}" --go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.go.txt "$@"
${listergen} --output-base "${KUBE_ROOT}/vendor" --output-package "k8s.io/client-go/listers" --input-dirs "${listergen_external_apis_csv}" --go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt "$@"
informergen_internal_apis=(
$(
@ -105,7 +105,7 @@ ${informergen} \
--input-dirs "${informergen_internal_apis_csv}" \
--internal-clientset-package k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset \
--listers-package k8s.io/kubernetes/pkg/client/listers \
--go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.go.txt \
--go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt \
"$@"
informergen_external_apis=(
@ -125,7 +125,7 @@ ${informergen} \
--input-dirs "${informergen_external_apis_csv}" \
--versioned-clientset-package k8s.io/client-go/kubernetes \
--listers-package k8s.io/client-go/listers \
--go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.go.txt \
--go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt \
"$@"
# You may add additional calls of code generators like set-gen above.
@ -137,3 +137,4 @@ CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/sample-apiserver/hack/u
CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/sample-controller/hack/update-codegen.sh
CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/apiextensions-apiserver/hack/update-codegen.sh
CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/metrics/hack/update-codegen.sh
CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/apiextensions-apiserver/examples/client-go/hack/update-codegen.sh

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2017 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2017 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#
@ -54,8 +54,7 @@ PATH="${gogopath}:${PATH}" \
--gogo_out=plugins=grpc:${KUBE_KMS_GRPC_ROOT} ${KUBE_KMS_GRPC_ROOT}/service.proto
# Update boilerplate for the generated file.
echo "$(cat hack/boilerplate/boilerplate.go.txt ${KUBE_KMS_GRPC_ROOT}/service.pb.go)" > ${KUBE_KMS_GRPC_ROOT}/service.pb.go
sed -i".bak" "s/Copyright YEAR/Copyright $(date '+%Y')/g" ${KUBE_KMS_GRPC_ROOT}/service.pb.go
echo "$(cat hack/boilerplate/boilerplate.generatego.txt ${KUBE_KMS_GRPC_ROOT}/service.pb.go)" > ${KUBE_KMS_GRPC_ROOT}/service.pb.go
# Run gofmt to clean up the generated code.
kube::golang::verify_go_version

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2018 The Kubernetes Authors.
#

View File

@ -0,0 +1,29 @@
#!/bin/bash
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE}")/../" && pwd -P)"
KUBELET_PLUGIN_REGISTRATION_ROOT="${KUBE_ROOT}/pkg/kubelet/apis/pluginregistration/v1alpha1/"
KUBELET_EXAMPLE_PLUGIN_V1BETA1="${KUBE_ROOT}/pkg/kubelet/util/pluginwatcher/example_plugin_apis/v1beta1/"
KUBELET_EXAMPLE_PLUGIN_V1BETA2="${KUBE_ROOT}/pkg/kubelet/util/pluginwatcher/example_plugin_apis/v1beta2/"
source "${KUBE_ROOT}/hack/lib/protoc.sh"
kube::protoc::generate_proto ${KUBELET_PLUGIN_REGISTRATION_ROOT}
kube::protoc::generate_proto ${KUBELET_EXAMPLE_PLUGIN_V1BETA1}
kube::protoc::generate_proto ${KUBELET_EXAMPLE_PLUGIN_V1BETA2}

View File

@ -1,6 +1,6 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors.
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -14,24 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# This script is a vestigial redirection. Please do not add "real" logic.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
# For help output
ARGHELP=""
if [[ "$#" -gt 0 ]]; then
ARGHELP=""
fi
# NOTE: All output from this script needs to be copied back to the calling
# source tree. This is managed in kube::build::copy_output in build/common.sh.
# If the output set is changed update that function.
echo "NOTE: $0 has been replaced by 'make test-cmd'"
echo
echo "The equivalent of this invocation is: "
echo " make test-cmd ${ARGHELP}"
echo
echo
make --no-print-directory -C "${KUBE_ROOT}" test-cmd
${KUBE_ROOT}/build/run.sh hack/update-generated-kubelet-plugin-registration-dockerized.sh "$@"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#
@ -68,6 +68,7 @@ PACKAGES=(
k8s.io/api/certificates/v1beta1
k8s.io/api/imagepolicy/v1alpha1
k8s.io/api/scheduling/v1alpha1
k8s.io/api/scheduling/v1beta1
k8s.io/api/settings/v1alpha1
k8s.io/api/storage/v1alpha1
k8s.io/api/storage/v1beta1
@ -94,5 +95,5 @@ PATH="${KUBE_ROOT}/_output/bin:${PATH}" \
--proto-import="${KUBE_ROOT}/vendor" \
--proto-import="${KUBE_ROOT}/third_party/protobuf" \
--packages=$(IFS=, ; echo "${PACKAGES[*]}") \
--go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.go.txt \
--go-header-file ${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt \
"$@"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#
@ -54,8 +54,7 @@ PATH="${gogopath}:${PATH}" \
--gogo_out=plugins=grpc:${KUBE_REMOTE_RUNTIME_ROOT} ${KUBE_REMOTE_RUNTIME_ROOT}/api.proto
# Update boilerplate for the generated file.
echo "$(cat hack/boilerplate/boilerplate.go.txt ${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go)" > ${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go
sed -i".bak" "s/Copyright YEAR/Copyright $(date '+%Y')/g" ${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go
echo "$(cat hack/boilerplate/boilerplate.generatego.txt ${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go)" > ${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go
# Run gofmt to clean up the generated code.
kube::golang::verify_go_version

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -37,7 +37,7 @@ export LC_ALL=C
# Process package content
#
# @param package The incoming package name
# @param type The type of content (LICENSE or COPYRIGHT)
# @param type The type of content (LICENSE, COPYRIGHT or COPYING)
#
process_content () {
local package=$1
@ -65,15 +65,19 @@ process_content () {
find_maxdepth=3
ensure_pattern="copyright"
;;
COPYING) find_names=(-iname 'copying*')
find_maxdepth=1
ensure_pattern="license|copyright"
;;
esac
# Start search at package root
case ${package} in
github.com/*|golang.org/*|bitbucket.org/*)
package_root=$(echo ${package} |awk -F/ '{ print $1"/"$2"/"$3 }')
package_root=$(echo "${package}" |awk -F/ '{ print $1"/"$2"/"$3 }')
;;
go4.org/*)
package_root=$(echo ${package} |awk -F/ '{ print $1 }')
package_root=$(echo "${package}" |awk -F/ '{ print $1 }')
;;
gopkg.in/*)
# Root of gopkg.in package always ends with '.v(number)' and my contain
@ -81,10 +85,10 @@ process_content () {
# - gopkg.in/yaml.v2
# - gopkg.in/inf.v0
# - gopkg.in/square/go-jose.v2
package_root=$(echo ${package} |grep -oh '.*\.v[0-9]')
package_root=$(echo "${package}" |grep -oh '.*\.v[0-9]')
;;
*)
package_root=$(echo ${package} |awk -F/ '{ print $1"/"$2 }')
package_root=$(echo "${package}" |awk -F/ '{ print $1"/"$2 }')
;;
esac
@ -94,7 +98,7 @@ process_content () {
[[ -d ${DEPS_DIR}/${dir_root} ]] || continue
# One (set) of these is fine
find ${DEPS_DIR}/${dir_root} \
find "${DEPS_DIR}/${dir_root}" \
-xdev -follow -maxdepth ${find_maxdepth} \
-type f "${find_names[@]}"
done | sort -u))
@ -103,9 +107,14 @@ process_content () {
local f
index="${package}-${type}"
if [[ -z "${CONTENT[${index}]-}" ]]; then
for f in ${local_files[@]-}; do
for f in "${local_files[@]-}"; do
if [[ -z "$f" ]]; then
# Set the default value and then check it to prevent
# accessing potentially empty array
continue
fi
# Find some copyright info in any file and break
if egrep -i -wq "${ensure_pattern}" "${f}"; then
if grep -E -i -wq "${ensure_pattern}" "${f}"; then
CONTENT[${index}]="${f}"
break
fi
@ -147,18 +156,17 @@ declare -Ag CONTENT
echo "================================================================================"
echo "= Kubernetes licensed under: ="
echo
cat ${LICENSE_ROOT}/LICENSE
cat "${LICENSE_ROOT}/LICENSE"
echo
echo "= LICENSE $(cat ${LICENSE_ROOT}/LICENSE | md5sum | awk '{print $1}')"
echo "= LICENSE $(cat "${LICENSE_ROOT}/LICENSE" | md5sum | awk '{print $1}')"
echo "================================================================================"
) > ${TMP_LICENSE_FILE}
# Loop through every package in Godeps.json
for PACKAGE in $(cat Godeps/Godeps.json | \
jq -r ".Deps[].ImportPath" | \
sort -f); do
process_content ${PACKAGE} LICENSE
process_content ${PACKAGE} COPYRIGHT
for PACKAGE in $(jq -r ".Deps[].ImportPath" < Godeps/Godeps.json | sort -f); do
process_content "${PACKAGE}" LICENSE
process_content "${PACKAGE}" COPYRIGHT
process_content "${PACKAGE}" COPYING
# display content
echo
@ -171,16 +179,18 @@ for PACKAGE in $(cat Godeps/Godeps.json | \
file="${CONTENT[${PACKAGE}-LICENSE]-}"
elif [[ -n "${CONTENT[${PACKAGE}-COPYRIGHT]-}" ]]; then
file="${CONTENT[${PACKAGE}-COPYRIGHT]-}"
elif [[ -n "${CONTENT[${PACKAGE}-COPYING]-}" ]]; then
file="${CONTENT[${PACKAGE}-COPYING]-}"
fi
if [[ -z "${file}" ]]; then
cat > /dev/stderr << __EOF__
No license could be found for ${PACKAGE} - aborting.
Options:
1. Check if the upstream repository has a newer version with LICENSE and/or
COPYRIGHT files.
2. Contact the author of the package to ensure there is a LICENSE and/or
COPYRIGHT file present.
1. Check if the upstream repository has a newer version with LICENSE, COPYRIGHT and/or
COPYING files.
2. Contact the author of the package to ensure there is a LICENSE, COPYRIGHT and/or
COPYING file present.
3. Do not use this package in Kubernetes.
__EOF__
exit 9
@ -188,7 +198,7 @@ __EOF__
cat "${file}"
echo
echo "= ${file} $(cat ${file} | md5sum | awk '{print $1}')"
echo "= ${file} $(cat "${file}" | md5sum | awk '{print $1}')"
echo "================================================================================"
echo
done >> ${TMP_LICENSE_FILE}

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2014 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors.
#
@ -31,7 +31,11 @@ make -C "${KUBE_ROOT}" WHAT=cmd/kube-apiserver
function cleanup()
{
[[ -n ${APISERVER_PID-} ]] && kill ${APISERVER_PID} 1>&2 2>/dev/null
if [[ -n ${APISERVER_PID-} ]]; then
kill ${APISERVER_PID} 1>&2 2>/dev/null
wait ${APISERVER_PID} || true
fi
unset APISERVER_PID
kube::etcd::cleanup

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2017 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2017 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2017 The Kubernetes Authors.
#
@ -14,6 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/util.sh"
KUBECTL_FILES="pkg/kubectl/cmd/*.go pkg/kubectl/cmd/*/*.go"
generate_pot="false"
@ -62,8 +65,9 @@ if [[ "${generate_pot}" == "true" ]]; then
perl -pi -e 's/CHARSET/UTF-8/' tmp.pot
perl -pi -e 's/\\\(/\\\\\(/g' tmp.pot
perl -pi -e 's/\\\)/\\\\\)/g' tmp.pot
if msgcat -s tmp.pot > /tmp/template.pot; then
mv /tmp/template.pot translations/kubectl/template.pot
kube::util::ensure-temp-dir
if msgcat -s tmp.pot > "${KUBE_TEMP}/template.pot"; then
mv "${KUBE_TEMP}/template.pot" translations/kubectl/template.pot
rm tmp.pot
else
echo "Failed to update template.pot"

43
vendor/k8s.io/kubernetes/hack/update-workspace-mirror.sh generated vendored Executable file
View File

@ -0,0 +1,43 @@
#!/bin/bash
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
if [[ $# -ne 1 ]]; then
echo 'use "bazel run //hack:update-mirror"'
echo "(usage: $0 <file with list of URLs to mirror>)"
exit 1
fi
BUCKET="gs://k8s-bazel-cache"
gsutil acl get "${BUCKET}" > /dev/null
tmpfile=$(mktemp bazel_workspace_mirror.XXXXXX)
trap "rm ${tmpfile}" EXIT
cat "$1" | while read url; do
echo "${url}"
if gsutil ls "${BUCKET}/${url}" &> /dev/null; then
echo present
else
echo missing
if curl -fLag "${url}" > "${tmpfile}"; then
gsutil cp -a public-read "${tmpfile}" "${BUCKET}/${url}"
fi
fi
done

Some files were not shown because too many files have changed in this diff Show More