Unverified Commit b4bc5cb4 authored by SataQiu's avatar SataQiu Committed by GitHub

Merge branch 'master' into fix-shellcheck-20190418

parents a20aec8d 75d45bdf
...@@ -359,10 +359,11 @@ aliases: ...@@ -359,10 +359,11 @@ aliases:
# - # -
# - # -
# sig-cli-api-reviewers:
# -
# -
sig-cli-api-reviewers:
- pwittrock
- soltysh
sig-cloud-provider-api-reviewers: sig-cloud-provider-api-reviewers:
- andrewsykim - andrewsykim
- cheftako - cheftako
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# This file creates a standard build environment for building cross # This file creates a standard build environment for building cross
# platform go binary for the architecture kubernetes cares about. # platform go binary for the architecture kubernetes cares about.
FROM golang:1.12.1 FROM golang:1.12.4
ENV GOARM 7 ENV GOARM 7
ENV KUBE_DYNAMIC_CROSSPLATFORMS \ ENV KUBE_DYNAMIC_CROSSPLATFORMS \
......
...@@ -21,8 +21,8 @@ http_archive( ...@@ -21,8 +21,8 @@ http_archive(
http_archive( http_archive(
name = "io_bazel_rules_go", name = "io_bazel_rules_go",
sha256 = "6433336b4c5feb54e2f45df4c1c84ea4385b2dc0b6f274ec2cd5d745045eae1f", sha256 = "91b79f4758fd16f2c6426279ce00c1d2d8577d61c519db39675ed84657e1a95e",
urls = mirror("https://github.com/bazelbuild/rules_go/releases/download/0.17.2/rules_go-0.17.2.tar.gz"), urls = mirror("https://github.com/bazelbuild/rules_go/releases/download/0.17.4/rules_go-0.17.4.tar.gz"),
) )
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
...@@ -30,7 +30,7 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe ...@@ -30,7 +30,7 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe
go_rules_dependencies() go_rules_dependencies()
go_register_toolchains( go_register_toolchains(
go_version = "1.12.1", go_version = "1.12.4",
) )
http_archive( http_archive(
......
...@@ -18,7 +18,7 @@ set -o errexit ...@@ -18,7 +18,7 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
KUBE_ROOT=${KUBE_ROOT:-$(dirname "${BASH_SOURCE}")/..} KUBE_ROOT=${KUBE_ROOT:-$(dirname "${BASH_SOURCE[0]}")/..}
# Detect the OS name/arch so that we can find our binary # Detect the OS name/arch so that we can find our binary
case "$(uname -s)" in case "$(uname -s)" in
......
...@@ -20,7 +20,7 @@ set -o errexit ...@@ -20,7 +20,7 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
KUBE_ROOT=$(cd $(dirname "${BASH_SOURCE}")/.. && pwd) KUBE_ROOT=$(cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd)
DEFAULT_KUBECONFIG="${HOME:-.}/.kube/config" DEFAULT_KUBECONFIG="${HOME:-.}/.kube/config"
......
...@@ -39,29 +39,30 @@ ACI_DIR=${STAGING_DIR}/gci-mounter ...@@ -39,29 +39,30 @@ ACI_DIR=${STAGING_DIR}/gci-mounter
CWD=${PWD} CWD=${PWD}
# Cleanup the temporary directories # Cleanup the temporary directories
function cleanup { cleanup() {
rm -rf ${DOWNLOAD_DIR} rm -rf "${DOWNLOAD_DIR}"
rm -rf ${STAGING_DIR} rm -rf "${STAGING_DIR}"
cd ${CWD} cd "${CWD}"
} }
# Delete temporary directories on exit # Delete temporary directories on exit
trap cleanup EXIT trap cleanup EXIT
mkdir ${ACI_DIR} mkdir "${ACI_DIR}"
# Convert docker image to aci and stage it # Convert docker image to aci and stage it
echo "Downloading docker2aci ${DOCKER2ACI_VERSION}" echo "Downloading docker2aci ${DOCKER2ACI_VERSION}"
wget "https://github.com/appc/docker2aci/releases/download/${DOCKER2ACI_VERSION}/docker2aci-${DOCKER2ACI_VERSION}.tar.gz" &> /dev/null wget "https://github.com/appc/docker2aci/releases/download/${DOCKER2ACI_VERSION}/docker2aci-${DOCKER2ACI_VERSION}.tar.gz" >/dev/null 2>&1
echo "Extracting docker2aci ${DOCKER2ACI_VERSION}" echo "Extracting docker2aci ${DOCKER2ACI_VERSION}"
tar xzf docker2aci-${DOCKER2ACI_VERSION}.tar.gz tar xzf docker2aci-${DOCKER2ACI_VERSION}.tar.gz
ACI_IMAGE=$(${DOWNLOAD_DIR}/docker2aci-${DOCKER2ACI_VERSION}/docker2aci ${DOCKER_IMAGE} 2>/dev/null | tail -n 1) ACI_IMAGE=$("${DOWNLOAD_DIR}/docker2aci-${DOCKER2ACI_VERSION}/docker2aci" "${DOCKER_IMAGE}" 2>/dev/null | tail -n 1)
cp ${ACI_IMAGE} ${ACI_DIR}/${MOUNTER_ACI_IMAGE} cp "${ACI_IMAGE}" "${ACI_DIR}/${MOUNTER_ACI_IMAGE}"
# Upload the contents to gcs # Upload the contents to gcs
echo "Uploading gci mounter ACI in ${ACI_DIR} to ${MOUNTER_GCS_DIR}" echo "Uploading gci mounter ACI in ${ACI_DIR} to ${MOUNTER_GCS_DIR}"
gsutil cp ${ACI_DIR}/${MOUNTER_ACI_IMAGE} ${MOUNTER_GCS_DIR} gsutil cp "${ACI_DIR}/${MOUNTER_ACI_IMAGE}" "${MOUNTER_GCS_DIR}"
echo "Upload completed" echo "Upload completed"
echo "Updated gci-mounter ACI version and SHA1 in cluster/gce/gci/configure.sh" echo "Updated gci-mounter ACI version and SHA1 in cluster/gce/gci/configure.sh"
echo "${MOUNTER_ACI_IMAGE} hash: $(sha1sum ${ACI_DIR}/${MOUNTER_ACI_IMAGE})" ACI_HASH=$(sha1sum "${ACI_DIR}/${MOUNTER_ACI_IMAGE}")
echo "${MOUNTER_ACI_IMAGE} hash: ${ACI_HASH}"
...@@ -63,7 +63,7 @@ readonly max_dump_processes=25 ...@@ -63,7 +63,7 @@ readonly max_dump_processes=25
# TODO: Get rid of all the sourcing of bash dependencies eventually. # TODO: Get rid of all the sourcing of bash dependencies eventually.
function setup() { function setup() {
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../.. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
if [[ -z "${use_custom_instance_list}" ]]; then if [[ -z "${use_custom_instance_list}" ]]; then
: ${KUBE_CONFIG_FILE:="config-test.sh"} : ${KUBE_CONFIG_FILE:="config-test.sh"}
echo "Sourcing kube-util.sh" echo "Sourcing kube-util.sh"
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
# pre-existing Kubernetes master. See test/kubemark/pre-existing/README.md # pre-existing Kubernetes master. See test/kubemark/pre-existing/README.md
# for me details on using a pre-existing provider. # for me details on using a pre-existing provider.
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../.. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
source "${KUBE_ROOT}/cluster/common.sh" source "${KUBE_ROOT}/cluster/common.sh"
source "${KUBE_ROOT}/hack/lib/util.sh" source "${KUBE_ROOT}/hack/lib/util.sh"
......
...@@ -21,7 +21,7 @@ set -o errexit ...@@ -21,7 +21,7 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${KUBE_ROOT}/cluster/kube-util.sh" source "${KUBE_ROOT}/cluster/kube-util.sh"
echo "Testing cluster with provider: ${KUBERNETES_PROVIDER}" 1>&2 echo "Testing cluster with provider: ${KUBERNETES_PROVIDER}" 1>&2
......
...@@ -24,7 +24,6 @@ set -o errexit ...@@ -24,7 +24,6 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
KUBE_CONFIG_FILE="config-default.sh"
${KUBE_ROOT}/hack/ginkgo-e2e.sh --ginkgo.focus=Networking "${KUBE_ROOT}/hack/ginkgo-e2e.sh" --ginkgo.focus=Networking
...@@ -23,10 +23,8 @@ set -o errexit ...@@ -23,10 +23,8 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
TEST_ARGS="$@"
SMOKE_TEST_FOCUS_REGEX="Guestbook.application" SMOKE_TEST_FOCUS_REGEX="Guestbook.application"
exec "${KUBE_ROOT}/cluster/test-e2e.sh" -ginkgo.focus="${SMOKE_TEST_FOCUS_REGEX}" ${TEST_ARGS} exec "${KUBE_ROOT}/cluster/test-e2e.sh" -ginkgo.focus="${SMOKE_TEST_FOCUS_REGEX}" "$@"
...@@ -24,7 +24,7 @@ set -o errexit ...@@ -24,7 +24,7 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
if [ -f "${KUBE_ROOT}/cluster/env.sh" ]; then if [ -f "${KUBE_ROOT}/cluster/env.sh" ]; then
source "${KUBE_ROOT}/cluster/env.sh" source "${KUBE_ROOT}/cluster/env.sh"
......
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
kubeadmapiv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1" kubeadmapiv1beta1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options" "k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util" cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
certsphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/certs" certsphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/certs"
"k8s.io/kubernetes/cmd/kubeadm/app/phases/certs/renewal" "k8s.io/kubernetes/cmd/kubeadm/app/phases/certs/renewal"
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util" kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
...@@ -145,11 +146,30 @@ func generateRenewalFunction(cert *certsphase.KubeadmCert, caCert *certsphase.Ku ...@@ -145,11 +146,30 @@ func generateRenewalFunction(cert *certsphase.KubeadmCert, caCert *certsphase.Ku
return return
} }
renewer, err := getRenewer(cfg, caCert.BaseName) var externalCA bool
kubeadmutil.CheckErr(err) switch caCert.BaseName {
case kubeadmconstants.CACertAndKeyBaseName:
// Check if an external CA is provided by the user (when the CA Cert is present but the CA Key is not)
externalCA, _ = certsphase.UsingExternalCA(&internalcfg.ClusterConfiguration)
case kubeadmconstants.FrontProxyCACertAndKeyBaseName:
// Check if an external Front-Proxy CA is provided by the user (when the Front-Proxy CA Cert is present but the Front-Proxy CA Key is not)
externalCA, _ = certsphase.UsingExternalFrontProxyCA(&internalcfg.ClusterConfiguration)
default:
externalCA = false
}
err = renewal.RenewExistingCert(internalcfg.CertificatesDir, cert.BaseName, renewer) if !externalCA {
kubeadmutil.CheckErr(err) renewer, err := getRenewer(cfg, caCert.BaseName)
kubeadmutil.CheckErr(err)
err = renewal.RenewExistingCert(internalcfg.CertificatesDir, cert.BaseName, renewer)
kubeadmutil.CheckErr(err)
fmt.Printf("Certificate %s renewed\n", cert.Name)
return
}
fmt.Printf("Detected external %s, certificate %s can't be renewed\n", cert.CAName, cert.Name)
} }
} }
......
...@@ -45,5 +45,8 @@ go_test( ...@@ -45,5 +45,8 @@ go_test(
name = "go_default_test", name = "go_default_test",
srcs = ["token_test.go"], srcs = ["token_test.go"],
embed = [":go_default_library"], embed = [":go_default_library"],
deps = ["//staging/src/k8s.io/client-go/tools/clientcmd/api:go_default_library"], deps = [
"//staging/src/k8s.io/client-go/tools/clientcmd/api:go_default_library",
"//vendor/github.com/pkg/errors:go_default_library",
],
) )
...@@ -17,10 +17,11 @@ limitations under the License. ...@@ -17,10 +17,11 @@ limitations under the License.
package token package token
import ( import (
"fmt"
"testing" "testing"
"time" "time"
"github.com/pkg/errors"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api" clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
) )
...@@ -71,7 +72,7 @@ func TestFetchKubeConfigWithTimeout(t *testing.T) { ...@@ -71,7 +72,7 @@ func TestFetchKubeConfigWithTimeout(t *testing.T) {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
cfg, err := fetchKubeConfigWithTimeout(testAPIEndpoint, test.discoveryTimeout, func(apiEndpoint string) (*clientcmdapi.Config, error) { cfg, err := fetchKubeConfigWithTimeout(testAPIEndpoint, test.discoveryTimeout, func(apiEndpoint string) (*clientcmdapi.Config, error) {
if apiEndpoint != testAPIEndpoint { if apiEndpoint != testAPIEndpoint {
return nil, fmt.Errorf("unexpected API server endpoint:\n\texpected: %q\n\tgot: %q", testAPIEndpoint, apiEndpoint) return nil, errors.Errorf("unexpected API server endpoint:\n\texpected: %q\n\tgot: %q", testAPIEndpoint, apiEndpoint)
} }
time.Sleep(3 * time.Second) time.Sleep(3 * time.Second)
......
...@@ -59,21 +59,6 @@ type kubeConfigSpec struct { ...@@ -59,21 +59,6 @@ type kubeConfigSpec struct {
ClientCertAuth *clientCertAuth ClientCertAuth *clientCertAuth
} }
// CreateInitKubeConfigFiles will create and write to disk all kubeconfig files necessary in the kubeadm init phase
// to establish the control plane, including also the admin kubeconfig file.
// If kubeconfig files already exists, they are used only if evaluated equal; otherwise an error is returned.
func CreateInitKubeConfigFiles(outDir string, cfg *kubeadmapi.InitConfiguration) error {
klog.V(1).Infoln("creating all kubeconfig files")
return createKubeConfigFiles(
outDir,
cfg,
kubeadmconstants.AdminKubeConfigFileName,
kubeadmconstants.KubeletKubeConfigFileName,
kubeadmconstants.ControllerManagerKubeConfigFileName,
kubeadmconstants.SchedulerKubeConfigFileName,
)
}
// CreateJoinControlPlaneKubeConfigFiles will create and write to disk the kubeconfig files required by kubeadm // CreateJoinControlPlaneKubeConfigFiles will create and write to disk the kubeconfig files required by kubeadm
// join --control-plane workflow, plus the admin kubeconfig file used by the administrator and kubeadm itself; the // join --control-plane workflow, plus the admin kubeconfig file used by the administrator and kubeadm itself; the
// kubelet.conf file must not be created because it will be created and signed by the kubelet TLS bootstrap process. // kubelet.conf file must not be created because it will be created and signed by the kubelet TLS bootstrap process.
......
...@@ -289,16 +289,6 @@ func TestCreateKubeconfigFilesAndWrappers(t *testing.T) { ...@@ -289,16 +289,6 @@ func TestCreateKubeconfigFilesAndWrappers(t *testing.T) {
}, },
expectedError: true, expectedError: true,
}, },
{ // Test CreateInitKubeConfigFiles (wrapper to createKubeConfigFile)
name: "CreateInitKubeConfigFiles",
createKubeConfigFunction: CreateInitKubeConfigFiles,
expectedFiles: []string{
kubeadmconstants.AdminKubeConfigFileName,
kubeadmconstants.KubeletKubeConfigFileName,
kubeadmconstants.ControllerManagerKubeConfigFileName,
kubeadmconstants.SchedulerKubeConfigFileName,
},
},
{ // Test CreateJoinControlPlaneKubeConfigFiles (wrapper to createKubeConfigFile) { // Test CreateJoinControlPlaneKubeConfigFiles (wrapper to createKubeConfigFile)
name: "CreateJoinControlPlaneKubeConfigFiles", name: "CreateJoinControlPlaneKubeConfigFiles",
createKubeConfigFunction: CreateJoinControlPlaneKubeConfigFiles, createKubeConfigFunction: CreateJoinControlPlaneKubeConfigFiles,
......
...@@ -1088,10 +1088,6 @@ func RunPullImagesCheck(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigur ...@@ -1088,10 +1088,6 @@ func RunPullImagesCheck(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigur
// RunChecks runs each check, displays it's warnings/errors, and once all // RunChecks runs each check, displays it's warnings/errors, and once all
// are processed will exit if any errors occurred. // are processed will exit if any errors occurred.
func RunChecks(checks []Checker, ww io.Writer, ignorePreflightErrors sets.String) error { func RunChecks(checks []Checker, ww io.Writer, ignorePreflightErrors sets.String) error {
type checkErrors struct {
Name string
Errors []error
}
var errsBuffer bytes.Buffer var errsBuffer bytes.Buffer
for _, c := range checks { for _, c := range checks {
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
./cluster/gce/gci/flexvolume_node_setup.sh ./cluster/gce/gci/flexvolume_node_setup.sh
./cluster/gce/gci/health-monitor.sh ./cluster/gce/gci/health-monitor.sh
./cluster/gce/gci/master-helper.sh ./cluster/gce/gci/master-helper.sh
./cluster/gce/gci/mounter/stage-upload.sh
./cluster/gce/gci/shutdown.sh ./cluster/gce/gci/shutdown.sh
./cluster/gce/list-resources.sh ./cluster/gce/list-resources.sh
./cluster/gce/upgrade-aliases.sh ./cluster/gce/upgrade-aliases.sh
...@@ -21,10 +20,7 @@ ...@@ -21,10 +20,7 @@
./cluster/pre-existing/util.sh ./cluster/pre-existing/util.sh
./cluster/restore-from-backup.sh ./cluster/restore-from-backup.sh
./cluster/test-e2e.sh ./cluster/test-e2e.sh
./cluster/test-network.sh
./cluster/test-smoke.sh
./cluster/validate-cluster.sh ./cluster/validate-cluster.sh
./hack/cherry_pick_pull.sh
./hack/ginkgo-e2e.sh ./hack/ginkgo-e2e.sh
./hack/grab-profiles.sh ./hack/grab-profiles.sh
./hack/lib/init.sh ./hack/lib/init.sh
...@@ -47,7 +43,6 @@ ...@@ -47,7 +43,6 @@
./hack/verify-codegen.sh ./hack/verify-codegen.sh
./hack/verify-golint.sh ./hack/verify-golint.sh
./hack/verify-no-vendor-cycles.sh ./hack/verify-no-vendor-cycles.sh
./hack/verify-readonly-packages.sh
./hack/verify-test-featuregates.sh ./hack/verify-test-featuregates.sh
./test/cmd/apply.sh ./test/cmd/apply.sh
./test/cmd/apps.sh ./test/cmd/apps.sh
......
...@@ -84,8 +84,10 @@ shift 1 ...@@ -84,8 +84,10 @@ shift 1
declare -r PULLS=( "$@" ) declare -r PULLS=( "$@" )
function join { local IFS="$1"; shift; echo "$*"; } function join { local IFS="$1"; shift; echo "$*"; }
declare -r PULLDASH=$(join - "${PULLS[@]/#/#}") # Generates something like "#12345-#56789" PULLDASH=$(join - "${PULLS[@]/#/#}") # Generates something like "#12345-#56789"
declare -r PULLSUBJ=$(join " " "${PULLS[@]/#/#}") # Generates something like "#12345 #56789" declare -r PULLDASH
PULLSUBJ=$(join " " "${PULLS[@]/#/#}") # Generates something like "#12345 #56789"
declare -r PULLSUBJ
echo "+++ Updating remotes..." echo "+++ Updating remotes..."
git remote update "${UPSTREAM_REMOTE}" "${FORK_REMOTE}" git remote update "${UPSTREAM_REMOTE}" "${FORK_REMOTE}"
...@@ -96,9 +98,12 @@ if ! git log -n1 --format=%H "${BRANCH}" >/dev/null 2>&1; then ...@@ -96,9 +98,12 @@ if ! git log -n1 --format=%H "${BRANCH}" >/dev/null 2>&1; then
exit 1 exit 1
fi fi
declare -r NEWBRANCHREQ="automated-cherry-pick-of-${PULLDASH}" # "Required" portion for tools. NEWBRANCHREQ="automated-cherry-pick-of-${PULLDASH}" # "Required" portion for tools.
declare -r NEWBRANCH="$(echo "${NEWBRANCHREQ}-${BRANCH}" | sed 's/\//-/g')" declare -r NEWBRANCHREQ
declare -r NEWBRANCHUNIQ="${NEWBRANCH}-$(date +%s)" NEWBRANCH="$(echo "${NEWBRANCHREQ}-${BRANCH}" | sed 's/\//-/g')"
declare -r NEWBRANCH
NEWBRANCHUNIQ="${NEWBRANCH}-$(date +%s)"
declare -r NEWBRANCHUNIQ
echo "+++ Creating local branch ${NEWBRANCHUNIQ}" echo "+++ Creating local branch ${NEWBRANCHUNIQ}"
cleanbranch="" cleanbranch=""
...@@ -128,7 +133,8 @@ trap return_to_kansas EXIT ...@@ -128,7 +133,8 @@ trap return_to_kansas EXIT
SUBJECTS=() SUBJECTS=()
function make-a-pr() { function make-a-pr() {
local rel="$(basename "${BRANCH}")" local rel
rel="$(basename "${BRANCH}")"
echo echo
echo "+++ Creating a pull request on GitHub at ${GITHUB_USER}:${NEWBRANCH}" echo "+++ Creating a pull request on GitHub at ${GITHUB_USER}:${NEWBRANCH}"
...@@ -137,7 +143,8 @@ function make-a-pr() { ...@@ -137,7 +143,8 @@ function make-a-pr() {
# when we shove the heredoc at hub directly, tickling the ioctl # when we shove the heredoc at hub directly, tickling the ioctl
# crash. # crash.
prtext="$(mktemp -t prtext.XXXX)" # cleaned in return_to_kansas prtext="$(mktemp -t prtext.XXXX)" # cleaned in return_to_kansas
local numandtitle=$(printf '%s\n' "${SUBJECTS[@]}") local numandtitle
numandtitle=$(printf '%s\n' "${SUBJECTS[@]}")
cat >"${prtext}" <<EOF cat >"${prtext}" <<EOF
Automated cherry pick of ${numandtitle} Automated cherry pick of ${numandtitle}
...@@ -218,7 +225,7 @@ if [[ -n "${DRY_RUN}" ]]; then ...@@ -218,7 +225,7 @@ if [[ -n "${DRY_RUN}" ]]; then
exit 0 exit 0
fi fi
if git remote -v | grep ^${FORK_REMOTE} | grep ${MAIN_REPO_ORG}/${MAIN_REPO_NAME}.git; then if git remote -v | grep ^"${FORK_REMOTE}" | grep "${MAIN_REPO_ORG}/${MAIN_REPO_NAME}.git"; then
echo "!!! You have ${FORK_REMOTE} configured as your ${MAIN_REPO_ORG}/${MAIN_REPO_NAME}.git" echo "!!! You have ${FORK_REMOTE} configured as your ${MAIN_REPO_ORG}/${MAIN_REPO_NAME}.git"
echo "This isn't normal. Leaving you with push instructions:" echo "This isn't normal. Leaving you with push instructions:"
echo echo
......
...@@ -112,9 +112,9 @@ kube::etcd::install() { ...@@ -112,9 +112,9 @@ kube::etcd::install() {
cd "${KUBE_ROOT}/third_party" || return 1 cd "${KUBE_ROOT}/third_party" || return 1
if [[ $(readlink etcd) == etcd-v${ETCD_VERSION}-${os}-* ]]; then if [[ $(readlink etcd) == etcd-v${ETCD_VERSION}-${os}-* ]]; then
kube::log::info "etcd v${ETCD_VERSION} already installed at path:" kube::log::info "etcd v${ETCD_VERSION} already installed. To use:"
kube::log::info "$(pwd)/$(readlink etcd)" kube::log::info "export PATH=\"$(pwd)/etcd:\${PATH}\""
return # already installed return #already installed
fi fi
if [[ ${os} == "darwin" ]]; then if [[ ${os} == "darwin" ]]; then
...@@ -133,6 +133,6 @@ kube::etcd::install() { ...@@ -133,6 +133,6 @@ kube::etcd::install() {
rm "${download_file}" rm "${download_file}"
fi fi
kube::log::info "etcd v${ETCD_VERSION} installed. To use:" kube::log::info "etcd v${ETCD_VERSION} installed. To use:"
kube::log::info "export PATH=$(pwd)/etcd:\${PATH}" kube::log::info "export PATH=\"$(pwd)/etcd:\${PATH}\""
) )
} }
...@@ -22,7 +22,7 @@ set -o errexit ...@@ -22,7 +22,7 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${KUBE_ROOT}/hack/lib/init.sh" source "${KUBE_ROOT}/hack/lib/init.sh"
readonly branch=${1:-${KUBE_VERIFY_GIT_BRANCH:-master}} readonly branch=${1:-${KUBE_VERIFY_GIT_BRANCH:-master}}
...@@ -43,14 +43,13 @@ find_files() { ...@@ -43,14 +43,13 @@ find_files() {
\) -name '.readonly' \) -name '.readonly'
} }
IFS=$'\n' conflicts=()
conflicts=($(find_files | sed 's|/.readonly||' | while read dir; do while IFS=$'\n' read -r dir; do
dir=${dir#./} dir=${dir#./}
if kube::util::has_changes "${branch}" "^${dir}/[^/]*\$" '/\.readonly$|/BUILD$|/zz_generated|/\.generated\.|\.proto$|\.pb\.go$' >/dev/null; then if kube::util::has_changes "${branch}" "^${dir}/[^/]*\$" '/\.readonly$|/BUILD$|/zz_generated|/\.generated\.|\.proto$|\.pb\.go$' >/dev/null; then
echo "${dir}" conflicts+=("${dir}")
fi fi
done)) done < <(find_files | sed 's|/.readonly||')
unset IFS
if [ ${#conflicts[@]} -gt 0 ]; then if [ ${#conflicts[@]} -gt 0 ]; then
exec 1>&2 exec 1>&2
......
...@@ -268,9 +268,3 @@ func collectSecretPaths(t *testing.T, path *field.Path, name string, tp reflect. ...@@ -268,9 +268,3 @@ func collectSecretPaths(t *testing.T, path *field.Path, name string, tp reflect.
return secretPaths return secretPaths
} }
func newHostPathType(pathType string) *corev1.HostPathType {
hostPathType := new(corev1.HostPathType)
*hostPathType = corev1.HostPathType(pathType)
return hostPathType
}
...@@ -17,7 +17,6 @@ limitations under the License. ...@@ -17,7 +17,6 @@ limitations under the License.
package validation package validation
import ( import (
"fmt"
"strings" "strings"
"testing" "testing"
...@@ -68,12 +67,6 @@ func getValidPodTemplateSpecForGenerated(selector *metav1.LabelSelector) api.Pod ...@@ -68,12 +67,6 @@ func getValidPodTemplateSpecForGenerated(selector *metav1.LabelSelector) api.Pod
} }
} }
func featureToggle(feature utilfeature.Feature) []string {
enabled := fmt.Sprintf("%s=%t", feature, true)
disabled := fmt.Sprintf("%s=%t", feature, false)
return []string{enabled, disabled}
}
func TestValidateJob(t *testing.T) { func TestValidateJob(t *testing.T) {
validManualSelector := getValidManualSelector() validManualSelector := getValidManualSelector()
validPodTemplateSpecForManual := getValidPodTemplateSpecForManual(validManualSelector) validPodTemplateSpecForManual := getValidPodTemplateSpecForManual(validManualSelector)
......
...@@ -18,13 +18,8 @@ package v1beta1 ...@@ -18,13 +18,8 @@ package v1beta1
import ( import (
policyv1beta1 "k8s.io/api/policy/v1beta1" policyv1beta1 "k8s.io/api/policy/v1beta1"
"k8s.io/apimachinery/pkg/runtime"
) )
func addDefaultingFuncs(scheme *runtime.Scheme) error {
return RegisterDefaults(scheme)
}
func SetDefaults_PodSecurityPolicySpec(obj *policyv1beta1.PodSecurityPolicySpec) { func SetDefaults_PodSecurityPolicySpec(obj *policyv1beta1.PodSecurityPolicySpec) {
// This field was added after PodSecurityPolicy was released. // This field was added after PodSecurityPolicy was released.
// Policies that do not include this field must remain as permissive as they were prior to the introduction of this field. // Policies that do not include this field must remain as permissive as they were prior to the introduction of this field.
......
...@@ -568,16 +568,6 @@ func extractResourceGroupByNicID(nicID string) (string, error) { ...@@ -568,16 +568,6 @@ func extractResourceGroupByNicID(nicID string) (string, error) {
return matches[1], nil return matches[1], nil
} }
// extractResourceGroupByPipID extracts the resource group name by publicIP ID.
func extractResourceGroupByPipID(pipID string) (string, error) {
matches := publicIPResourceGroupRE.FindStringSubmatch(pipID)
if len(matches) != 2 {
return "", fmt.Errorf("error of extracting resourceGroup from pipID %q", pipID)
}
return matches[1], nil
}
// getPrimaryInterfaceWithVMSet gets machine primary network interface by node name and vmSet. // getPrimaryInterfaceWithVMSet gets machine primary network interface by node name and vmSet.
func (as *availabilitySet) getPrimaryInterfaceWithVMSet(nodeName, vmSetName string) (network.Interface, error) { func (as *availabilitySet) getPrimaryInterfaceWithVMSet(nodeName, vmSetName string) (network.Interface, error) {
var machine compute.VirtualMachine var machine compute.VirtualMachine
......
...@@ -81,11 +81,6 @@ const ( ...@@ -81,11 +81,6 @@ const (
gceComputeAPIEndpointBeta = "https://www.googleapis.com/compute/beta/" gceComputeAPIEndpointBeta = "https://www.googleapis.com/compute/beta/"
) )
// gceObject is an abstraction of all GCE API object in go client
type gceObject interface {
MarshalJSON() ([]byte, error)
}
var _ cloudprovider.Interface = (*Cloud)(nil) var _ cloudprovider.Interface = (*Cloud)(nil)
var _ cloudprovider.Instances = (*Cloud)(nil) var _ cloudprovider.Instances = (*Cloud)(nil)
var _ cloudprovider.LoadBalancer = (*Cloud)(nil) var _ cloudprovider.LoadBalancer = (*Cloud)(nil)
......
...@@ -244,10 +244,6 @@ func makeGoogleAPINotFoundError(message string) error { ...@@ -244,10 +244,6 @@ func makeGoogleAPINotFoundError(message string) error {
return &googleapi.Error{Code: http.StatusNotFound, Message: message} return &googleapi.Error{Code: http.StatusNotFound, Message: message}
} }
func makeGoogleAPIError(code int, message string) error {
return &googleapi.Error{Code: code, Message: message}
}
// TODO(#51665): Remove this once Network Tiers becomes Beta in GCP. // TODO(#51665): Remove this once Network Tiers becomes Beta in GCP.
func handleAlphaNetworkTierGetError(err error) (string, error) { func handleAlphaNetworkTierGetError(err error) (string, error) {
if isForbidden(err) { if isForbidden(err) {
......
...@@ -85,8 +85,6 @@ type LbaasV2 struct { ...@@ -85,8 +85,6 @@ type LbaasV2 struct {
LoadBalancer LoadBalancer
} }
type empty struct{}
func networkExtensions(client *gophercloud.ServiceClient) (map[string]bool, error) { func networkExtensions(client *gophercloud.ServiceClient) (map[string]bool, error) {
seen := make(map[string]bool) seen := make(map[string]bool)
......
...@@ -389,22 +389,6 @@ func TestCPUEmptyMetricsForOnePod(t *testing.T) { ...@@ -389,22 +389,6 @@ func TestCPUEmptyMetricsForOnePod(t *testing.T) {
tc.runTest(t) tc.runTest(t)
} }
func testCollapseTimeSamples(t *testing.T) {
now := time.Now()
metrics := heapster.MetricResult{
Metrics: []heapster.MetricPoint{
{Timestamp: now, Value: 50, FloatValue: nil},
{Timestamp: now.Add(-15 * time.Second), Value: 100, FloatValue: nil},
{Timestamp: now.Add(-60 * time.Second), Value: 100000, FloatValue: nil}},
LatestTimestamp: now,
}
val, timestamp, hadMetrics := collapseTimeSamples(metrics, time.Minute)
assert.True(t, hadMetrics, "should report that it received a populated list of metrics")
assert.InEpsilon(t, float64(75), val, 0.1, "collapsed sample value should be as expected")
assert.True(t, timestamp.Equal(now), "timestamp should be the current time (the newest)")
}
func offsetTimestampBy(t int) time.Time { func offsetTimestampBy(t int) time.Time {
return fixedTimestamp.Add(time.Duration(t) * time.Minute) return fixedTimestamp.Add(time.Duration(t) * time.Minute)
} }
...@@ -702,16 +702,6 @@ func (e *TokensController) listTokenSecrets(serviceAccount *v1.ServiceAccount) ( ...@@ -702,16 +702,6 @@ func (e *TokensController) listTokenSecrets(serviceAccount *v1.ServiceAccount) (
return items, nil return items, nil
} }
// serviceAccountNameAndUID is a helper method to get the ServiceAccount Name and UID from the given secret
// Returns "","" if the secret is not a ServiceAccountToken secret
// If the name or uid annotation is missing, "" is returned instead
func serviceAccountNameAndUID(secret *v1.Secret) (string, string) {
if secret.Type != v1.SecretTypeServiceAccountToken {
return "", ""
}
return secret.Annotations[v1.ServiceAccountNameKey], secret.Annotations[v1.ServiceAccountUIDKey]
}
func getSecretReferences(serviceAccount *v1.ServiceAccount) sets.String { func getSecretReferences(serviceAccount *v1.ServiceAccount) sets.String {
references := sets.NewString() references := sets.NewString()
for _, secret := range serviceAccount.Secrets { for _, secret := range serviceAccount.Secrets {
......
...@@ -234,14 +234,6 @@ func TestControllerCacheParsingError(t *testing.T) { ...@@ -234,14 +234,6 @@ func TestControllerCacheParsingError(t *testing.T) {
} }
} }
func addVolumeAnnotation(volume *v1.PersistentVolume, annName, annValue string) *v1.PersistentVolume {
if volume.Annotations == nil {
volume.Annotations = make(map[string]string)
}
volume.Annotations[annName] = annValue
return volume
}
func makePVCClass(scName *string, hasSelectNodeAnno bool) *v1.PersistentVolumeClaim { func makePVCClass(scName *string, hasSelectNodeAnno bool) *v1.PersistentVolumeClaim {
claim := &v1.PersistentVolumeClaim{ claim := &v1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
......
...@@ -160,26 +160,26 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, node *v1.Node) (unboundVolume ...@@ -160,26 +160,26 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, node *v1.Node) (unboundVolume
}() }()
var ( var (
matchedClaims []*bindingInfo matchedBindings []*bindingInfo
provisionedClaims []*v1.PersistentVolumeClaim provisionedClaims []*v1.PersistentVolumeClaim
) )
defer func() { defer func() {
// We recreate bindings for each new schedule loop. // We recreate bindings for each new schedule loop.
if len(matchedClaims) == 0 && len(provisionedClaims) == 0 { if len(matchedBindings) == 0 && len(provisionedClaims) == 0 {
// Clear cache if no claims to bind or provision for this node. // Clear cache if no claims to bind or provision for this node.
b.podBindingCache.ClearBindings(pod, node.Name) b.podBindingCache.ClearBindings(pod, node.Name)
return return
} }
// Although we do not distinguish nil from empty in this function, for // Although we do not distinguish nil from empty in this function, for
// easier testing, we normalize empty to nil. // easier testing, we normalize empty to nil.
if len(matchedClaims) == 0 { if len(matchedBindings) == 0 {
matchedClaims = nil matchedBindings = nil
} }
if len(provisionedClaims) == 0 { if len(provisionedClaims) == 0 {
provisionedClaims = nil provisionedClaims = nil
} }
// Mark cache with all matched and provisioned claims for this node // Mark cache with all matched and provisioned claims for this node
b.podBindingCache.UpdateBindings(pod, node.Name, matchedClaims, provisionedClaims) b.podBindingCache.UpdateBindings(pod, node.Name, matchedBindings, provisionedClaims)
}() }()
// The pod's volumes need to be processed in one call to avoid the race condition where // The pod's volumes need to be processed in one call to avoid the race condition where
...@@ -225,7 +225,7 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, node *v1.Node) (unboundVolume ...@@ -225,7 +225,7 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, node *v1.Node) (unboundVolume
// Find matching volumes // Find matching volumes
if len(claimsToFindMatching) > 0 { if len(claimsToFindMatching) > 0 {
var unboundClaims []*v1.PersistentVolumeClaim var unboundClaims []*v1.PersistentVolumeClaim
unboundVolumesSatisfied, matchedClaims, unboundClaims, err = b.findMatchingVolumes(pod, claimsToFindMatching, node) unboundVolumesSatisfied, matchedBindings, unboundClaims, err = b.findMatchingVolumes(pod, claimsToFindMatching, node)
if err != nil { if err != nil {
return false, false, err return false, false, err
} }
...@@ -598,10 +598,10 @@ func (b *volumeBinder) arePodVolumesBound(pod *v1.Pod) bool { ...@@ -598,10 +598,10 @@ func (b *volumeBinder) arePodVolumesBound(pod *v1.Pod) bool {
// getPodVolumes returns a pod's PVCs separated into bound, unbound with delayed binding (including provisioning) // getPodVolumes returns a pod's PVCs separated into bound, unbound with delayed binding (including provisioning)
// and unbound with immediate binding (including prebound) // and unbound with immediate binding (including prebound)
func (b *volumeBinder) getPodVolumes(pod *v1.Pod) (boundClaims []*v1.PersistentVolumeClaim, unboundClaims []*v1.PersistentVolumeClaim, unboundClaimsImmediate []*v1.PersistentVolumeClaim, err error) { func (b *volumeBinder) getPodVolumes(pod *v1.Pod) (boundClaims []*v1.PersistentVolumeClaim, unboundClaimsDelayBinding []*v1.PersistentVolumeClaim, unboundClaimsImmediate []*v1.PersistentVolumeClaim, err error) {
boundClaims = []*v1.PersistentVolumeClaim{} boundClaims = []*v1.PersistentVolumeClaim{}
unboundClaimsImmediate = []*v1.PersistentVolumeClaim{} unboundClaimsImmediate = []*v1.PersistentVolumeClaim{}
unboundClaims = []*v1.PersistentVolumeClaim{} unboundClaimsDelayBinding = []*v1.PersistentVolumeClaim{}
for _, vol := range pod.Spec.Volumes { for _, vol := range pod.Spec.Volumes {
volumeBound, pvc, err := b.isVolumeBound(pod.Namespace, &vol) volumeBound, pvc, err := b.isVolumeBound(pod.Namespace, &vol)
...@@ -621,7 +621,7 @@ func (b *volumeBinder) getPodVolumes(pod *v1.Pod) (boundClaims []*v1.PersistentV ...@@ -621,7 +621,7 @@ func (b *volumeBinder) getPodVolumes(pod *v1.Pod) (boundClaims []*v1.PersistentV
// Prebound PVCs are treated as unbound immediate binding // Prebound PVCs are treated as unbound immediate binding
if delayBindingMode && pvc.Spec.VolumeName == "" { if delayBindingMode && pvc.Spec.VolumeName == "" {
// Scheduler path // Scheduler path
unboundClaims = append(unboundClaims, pvc) unboundClaimsDelayBinding = append(unboundClaimsDelayBinding, pvc)
} else { } else {
// !delayBindingMode || pvc.Spec.VolumeName != "" // !delayBindingMode || pvc.Spec.VolumeName != ""
// Immediate binding should have already been bound // Immediate binding should have already been bound
...@@ -629,7 +629,7 @@ func (b *volumeBinder) getPodVolumes(pod *v1.Pod) (boundClaims []*v1.PersistentV ...@@ -629,7 +629,7 @@ func (b *volumeBinder) getPodVolumes(pod *v1.Pod) (boundClaims []*v1.PersistentV
} }
} }
} }
return boundClaims, unboundClaims, unboundClaimsImmediate, nil return boundClaims, unboundClaimsDelayBinding, unboundClaimsImmediate, nil
} }
func (b *volumeBinder) checkBoundClaims(claims []*v1.PersistentVolumeClaim, node *v1.Node, podName string) (bool, error) { func (b *volumeBinder) checkBoundClaims(claims []*v1.PersistentVolumeClaim, node *v1.Node, podName string) (bool, error) {
...@@ -654,7 +654,7 @@ func (b *volumeBinder) checkBoundClaims(claims []*v1.PersistentVolumeClaim, node ...@@ -654,7 +654,7 @@ func (b *volumeBinder) checkBoundClaims(claims []*v1.PersistentVolumeClaim, node
// findMatchingVolumes tries to find matching volumes for given claims, // findMatchingVolumes tries to find matching volumes for given claims,
// and return unbound claims for further provision. // and return unbound claims for further provision.
func (b *volumeBinder) findMatchingVolumes(pod *v1.Pod, claimsToBind []*v1.PersistentVolumeClaim, node *v1.Node) (foundMatches bool, matchedClaims []*bindingInfo, unboundClaims []*v1.PersistentVolumeClaim, err error) { func (b *volumeBinder) findMatchingVolumes(pod *v1.Pod, claimsToBind []*v1.PersistentVolumeClaim, node *v1.Node) (foundMatches bool, bindings []*bindingInfo, unboundClaims []*v1.PersistentVolumeClaim, err error) {
podName := getPodName(pod) podName := getPodName(pod)
// Sort all the claims by increasing size request to get the smallest fits // Sort all the claims by increasing size request to get the smallest fits
sort.Sort(byPVCSize(claimsToBind)) sort.Sort(byPVCSize(claimsToBind))
...@@ -662,7 +662,6 @@ func (b *volumeBinder) findMatchingVolumes(pod *v1.Pod, claimsToBind []*v1.Persi ...@@ -662,7 +662,6 @@ func (b *volumeBinder) findMatchingVolumes(pod *v1.Pod, claimsToBind []*v1.Persi
chosenPVs := map[string]*v1.PersistentVolume{} chosenPVs := map[string]*v1.PersistentVolume{}
foundMatches = true foundMatches = true
matchedClaims = []*bindingInfo{}
for _, pvc := range claimsToBind { for _, pvc := range claimsToBind {
// Get storage class name from each PVC // Get storage class name from each PVC
...@@ -688,7 +687,7 @@ func (b *volumeBinder) findMatchingVolumes(pod *v1.Pod, claimsToBind []*v1.Persi ...@@ -688,7 +687,7 @@ func (b *volumeBinder) findMatchingVolumes(pod *v1.Pod, claimsToBind []*v1.Persi
// matching PV needs to be excluded so we don't select it again // matching PV needs to be excluded so we don't select it again
chosenPVs[pv.Name] = pv chosenPVs[pv.Name] = pv
matchedClaims = append(matchedClaims, &bindingInfo{pv: pv, pvc: pvc}) bindings = append(bindings, &bindingInfo{pv: pv, pvc: pvc})
klog.V(5).Infof("Found matching PV %q for PVC %q on node %q for pod %q", pv.Name, pvcName, node.Name, podName) klog.V(5).Infof("Found matching PV %q for PVC %q on node %q for pod %q", pv.Name, pvcName, node.Name, podName)
} }
......
...@@ -63,16 +63,6 @@ type authDirective struct { ...@@ -63,16 +63,6 @@ type authDirective struct {
realm string realm string
} }
type accessTokenPayload struct {
TenantID string `json:"tid"`
}
type acrTokenPayload struct {
Expiration int64 `json:"exp"`
TenantID string `json:"tenant"`
Credential string `json:"credential"`
}
type acrAuthResponse struct { type acrAuthResponse struct {
RefreshToken string `json:"refresh_token"` RefreshToken string `json:"refresh_token"`
} }
......
...@@ -151,8 +151,6 @@ func (mk MergeKeys) GetMergeKeyValue(i interface{}) (MergeKeyValue, error) { ...@@ -151,8 +151,6 @@ func (mk MergeKeys) GetMergeKeyValue(i interface{}) (MergeKeyValue, error) {
return result, nil return result, nil
} }
type source int
// CombinedPrimitiveSlice implements a slice of primitives // CombinedPrimitiveSlice implements a slice of primitives
type CombinedPrimitiveSlice struct { type CombinedPrimitiveSlice struct {
Items []*PrimitiveListItem Items []*PrimitiveListItem
......
...@@ -28,7 +28,6 @@ go_library( ...@@ -28,7 +28,6 @@ go_library(
"//pkg/kubectl/util/templates:go_default_library", "//pkg/kubectl/util/templates:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/rbac/v1:go_default_library", "//staging/src/k8s.io/api/rbac/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
......
...@@ -17,17 +17,13 @@ limitations under the License. ...@@ -17,17 +17,13 @@ limitations under the License.
package set package set
import ( import (
"fmt"
"io"
"strings" "strings"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/strategicpatch" "k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/cli-runtime/pkg/resource" "k8s.io/cli-runtime/pkg/resource"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
) )
// selectContainers allows one or more containers to be matched against a string or wildcard // selectContainers allows one or more containers to be matched against a string or wildcard
...@@ -44,33 +40,6 @@ func selectContainers(containers []v1.Container, spec string) ([]*v1.Container, ...@@ -44,33 +40,6 @@ func selectContainers(containers []v1.Container, spec string) ([]*v1.Container,
return out, skipped return out, skipped
} }
// handlePodUpdateError prints a more useful error to the end user when mutating a pod.
func handlePodUpdateError(out io.Writer, err error, resource string) {
if statusError, ok := err.(*errors.StatusError); ok && errors.IsInvalid(err) {
errorDetails := statusError.Status().Details
if errorDetails.Kind == "Pod" {
all, match := true, false
for _, cause := range errorDetails.Causes {
if cause.Field == "spec" && strings.Contains(cause.Message, "may not update fields other than") {
fmt.Fprintf(out, "error: may not update %s in pod %q directly\n", resource, errorDetails.Name)
match = true
} else {
all = false
}
}
if all && match {
return
}
} else {
if ok := cmdutil.PrintErrorWithCauses(err, out); ok {
return
}
}
}
fmt.Fprintf(out, "error: %v\n", err)
}
// selectString returns true if the provided string matches spec, where spec is a string with // selectString returns true if the provided string matches spec, where spec is a string with
// a non-greedy '*' wildcard operator. // a non-greedy '*' wildcard operator.
// TODO: turn into a regex and handle greedy matches and backtracking. // TODO: turn into a regex and handle greedy matches and backtracking.
......
...@@ -212,13 +212,6 @@ func NewInternalNamespacedType(kind, apiversion, name, namespace string) *Intern ...@@ -212,13 +212,6 @@ func NewInternalNamespacedType(kind, apiversion, name, namespace string) *Intern
var errInvalidVersion = errors.New("not a version") var errInvalidVersion = errors.New("not a version")
func versionErrIfFalse(b bool) error {
if b {
return nil
}
return errInvalidVersion
}
// ValidVersion of API // ValidVersion of API
var ValidVersion = "v1" var ValidVersion = "v1"
......
...@@ -88,6 +88,9 @@ func NewCmdVersion(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *co ...@@ -88,6 +88,9 @@ func NewCmdVersion(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *co
// Complete completes all the required options // Complete completes all the required options
func (o *Options) Complete(f cmdutil.Factory, cmd *cobra.Command) error { func (o *Options) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
var err error var err error
if o.ClientOnly {
return nil
}
o.discoveryClient, err = f.ToDiscoveryClient() o.discoveryClient, err = f.ToDiscoveryClient()
// if we had an empty rest.Config, continue and just print out client information. // if we had an empty rest.Config, continue and just print out client information.
// if we had an error other than being unable to build a rest.Config, fail. // if we had an error other than being unable to build a rest.Config, fail.
......
...@@ -735,6 +735,9 @@ func describePod(pod *corev1.Pod, events *corev1.EventList) (string, error) { ...@@ -735,6 +735,9 @@ func describePod(pod *corev1.Pod, events *corev1.EventList) (string, error) {
} else { } else {
w.Write(LEVEL_0, "QoS Class:\t%s\n", qos.GetPodQOS(pod)) w.Write(LEVEL_0, "QoS Class:\t%s\n", qos.GetPodQOS(pod))
} }
if len(pod.Spec.PriorityClassName) > 0 {
w.Write(LEVEL_0, "Priority Class Name:\t%s\n", pod.Spec.PriorityClassName)
}
printLabelsMultiline(w, "Node-Selectors", pod.Spec.NodeSelector) printLabelsMultiline(w, "Node-Selectors", pod.Spec.NodeSelector)
printPodTolerationsMultiline(w, "Tolerations", pod.Spec.Tolerations) printPodTolerationsMultiline(w, "Tolerations", pod.Spec.Tolerations)
if events != nil { if events != nil {
...@@ -1964,6 +1967,9 @@ func DescribePodTemplate(template *corev1.PodTemplateSpec, w PrefixWriter) { ...@@ -1964,6 +1967,9 @@ func DescribePodTemplate(template *corev1.PodTemplateSpec, w PrefixWriter) {
} }
describeContainers("Containers", template.Spec.Containers, nil, nil, w, " ") describeContainers("Containers", template.Spec.Containers, nil, nil, w, " ")
describeVolumes(template.Spec.Volumes, w, " ") describeVolumes(template.Spec.Volumes, w, " ")
if len(template.Spec.PriorityClassName) > 0 {
w.Write(LEVEL_1, "Priority Class Name:\t%s\n", template.Spec.PriorityClassName)
}
} }
// ReplicaSetDescriber generates information about a ReplicaSet and the pods it has created. // ReplicaSetDescriber generates information about a ReplicaSet and the pods it has created.
...@@ -4393,16 +4399,6 @@ func shorten(s string, maxLength int) string { ...@@ -4393,16 +4399,6 @@ func shorten(s string, maxLength int) string {
return s return s
} }
// translateTimestampUntil returns the elapsed time until timestamp in
// human-readable approximation.
func translateTimestampUntil(timestamp metav1.Time) string {
if timestamp.IsZero() {
return "<unknown>"
}
return duration.HumanDuration(time.Until(timestamp.Time))
}
// translateTimestampSince returns the elapsed time since timestamp in // translateTimestampSince returns the elapsed time since timestamp in
// human-readable approximation. // human-readable approximation.
func translateTimestampSince(timestamp metav1.Time) string { func translateTimestampSince(timestamp metav1.Time) string {
......
...@@ -109,7 +109,6 @@ func rsListFromClient(c appsclient.AppsV1Interface) rsListFunc { ...@@ -109,7 +109,6 @@ func rsListFromClient(c appsclient.AppsV1Interface) rsListFunc {
// TODO: switch this to full namespacers // TODO: switch this to full namespacers
type rsListFunc func(string, metav1.ListOptions) ([]*appsv1.ReplicaSet, error) type rsListFunc func(string, metav1.ListOptions) ([]*appsv1.ReplicaSet, error)
type podListFunc func(string, metav1.ListOptions) (*corev1.PodList, error)
// listReplicaSets returns a slice of RSes the given deployment targets. // listReplicaSets returns a slice of RSes the given deployment targets.
// Note that this does NOT attempt to reconcile ControllerRef (adopt/orphan), // Note that this does NOT attempt to reconcile ControllerRef (adopt/orphan),
......
...@@ -18,9 +18,6 @@ package dockershim ...@@ -18,9 +18,6 @@ package dockershim
import ( import (
"fmt" "fmt"
"io/ioutil"
"os"
"path/filepath"
"testing" "testing"
dockertypes "github.com/docker/docker/api/types" dockertypes "github.com/docker/docker/api/types"
...@@ -128,20 +125,6 @@ func TestParsingCreationConflictError(t *testing.T) { ...@@ -128,20 +125,6 @@ func TestParsingCreationConflictError(t *testing.T) {
require.Equal(t, matches[1], "24666ab8c814d16f986449e504ea0159468ddf8da01897144a770f66dce0e14e") require.Equal(t, matches[1], "24666ab8c814d16f986449e504ea0159468ddf8da01897144a770f66dce0e14e")
} }
// writeDockerConfig will write a config file into a temporary dir, and return that dir.
// Caller is responsible for deleting the dir and its contents.
func writeDockerConfig(cfg string) (string, error) {
tmpdir, err := ioutil.TempDir("", "dockershim=helpers_test.go=")
if err != nil {
return "", err
}
dir := filepath.Join(tmpdir, ".docker")
if err := os.Mkdir(dir, 0755); err != nil {
return "", err
}
return tmpdir, ioutil.WriteFile(filepath.Join(dir, "config.json"), []byte(cfg), 0644)
}
func TestEnsureSandboxImageExists(t *testing.T) { func TestEnsureSandboxImageExists(t *testing.T) {
sandboxImage := "gcr.io/test/image" sandboxImage := "gcr.io/test/image"
authConfig := dockertypes.AuthConfig{Username: "user", Password: "pass"} authConfig := dockertypes.AuthConfig{Username: "user", Password: "pass"}
......
...@@ -434,14 +434,6 @@ func formatThreshold(threshold evictionapi.Threshold) string { ...@@ -434,14 +434,6 @@ func formatThreshold(threshold evictionapi.Threshold) string {
return fmt.Sprintf("threshold(signal=%v, operator=%v, value=%v, gracePeriod=%v)", threshold.Signal, threshold.Operator, evictionapi.ThresholdValue(threshold.Value), threshold.GracePeriod) return fmt.Sprintf("threshold(signal=%v, operator=%v, value=%v, gracePeriod=%v)", threshold.Signal, threshold.Operator, evictionapi.ThresholdValue(threshold.Value), threshold.GracePeriod)
} }
// formatevictionapi.ThresholdValue formats a thresholdValue for logging.
func formatThresholdValue(value evictionapi.ThresholdValue) string {
if value.Quantity != nil {
return value.Quantity.String()
}
return fmt.Sprintf("%f%%", value.Percentage*float32(100))
}
// cachedStatsFunc returns a statsFunc based on the provided pod stats. // cachedStatsFunc returns a statsFunc based on the provided pod stats.
func cachedStatsFunc(podStats []statsapi.PodStats) statsFunc { func cachedStatsFunc(podStats []statsapi.PodStats) statsFunc {
uid2PodStats := map[string]statsapi.PodStats{} uid2PodStats := map[string]statsapi.PodStats{}
......
...@@ -167,10 +167,6 @@ func (s sortableNodeAddress) Less(i, j int) bool { ...@@ -167,10 +167,6 @@ func (s sortableNodeAddress) Less(i, j int) bool {
} }
func (s sortableNodeAddress) Swap(i, j int) { s[j], s[i] = s[i], s[j] } func (s sortableNodeAddress) Swap(i, j int) { s[j], s[i] = s[i], s[j] }
func sortNodeAddresses(addrs sortableNodeAddress) {
sort.Sort(addrs)
}
func TestUpdateNewNodeStatus(t *testing.T) { func TestUpdateNewNodeStatus(t *testing.T) {
cases := []struct { cases := []struct {
desc string desc string
......
...@@ -2018,20 +2018,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) { ...@@ -2018,20 +2018,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
} }
} }
type fakeReadWriteCloser struct{}
func (f *fakeReadWriteCloser) Write(data []byte) (int, error) {
return 0, nil
}
func (f *fakeReadWriteCloser) Read(data []byte) (int, error) {
return 0, nil
}
func (f *fakeReadWriteCloser) Close() error {
return nil
}
func TestGetExec(t *testing.T) { func TestGetExec(t *testing.T) {
const ( const (
podName = "podFoo" podName = "podFoo"
......
...@@ -136,22 +136,6 @@ func newTestKubelet(t *testing.T, controllerAttachDetachEnabled bool) *TestKubel ...@@ -136,22 +136,6 @@ func newTestKubelet(t *testing.T, controllerAttachDetachEnabled bool) *TestKubel
return newTestKubeletWithImageList(t, imageList, controllerAttachDetachEnabled, true /*initFakeVolumePlugin*/) return newTestKubeletWithImageList(t, imageList, controllerAttachDetachEnabled, true /*initFakeVolumePlugin*/)
} }
func newTestKubeletWithoutFakeVolumePlugin(t *testing.T, controllerAttachDetachEnabled bool) *TestKubelet {
imageList := []kubecontainer.Image{
{
ID: "abc",
RepoTags: []string{"k8s.gcr.io:v1", "k8s.gcr.io:v2"},
Size: 123,
},
{
ID: "efg",
RepoTags: []string{"k8s.gcr.io:v3", "k8s.gcr.io:v4"},
Size: 456,
},
}
return newTestKubeletWithImageList(t, imageList, controllerAttachDetachEnabled, false /*initFakeVolumePlugin*/)
}
func newTestKubeletWithImageList( func newTestKubeletWithImageList(
t *testing.T, t *testing.T,
imageList []kubecontainer.Image, imageList []kubecontainer.Image,
......
...@@ -257,19 +257,6 @@ func (kl *simpleFakeKubelet) syncPodWithWaitGroup(options syncPodOptions) error ...@@ -257,19 +257,6 @@ func (kl *simpleFakeKubelet) syncPodWithWaitGroup(options syncPodOptions) error
return nil return nil
} }
// byContainerName sort the containers in a running pod by their names.
type byContainerName kubecontainer.Pod
func (b byContainerName) Len() int { return len(b.Containers) }
func (b byContainerName) Swap(i, j int) {
b.Containers[i], b.Containers[j] = b.Containers[j], b.Containers[i]
}
func (b byContainerName) Less(i, j int) bool {
return b.Containers[i].Name < b.Containers[j].Name
}
// TestFakePodWorkers verifies that the fakePodWorkers behaves the same way as the real podWorkers // TestFakePodWorkers verifies that the fakePodWorkers behaves the same way as the real podWorkers
// for their invocation of the syncPodFn. // for their invocation of the syncPodFn.
func TestFakePodWorkers(t *testing.T) { func TestFakePodWorkers(t *testing.T) {
......
...@@ -883,10 +883,6 @@ func getAction() core.GetAction { ...@@ -883,10 +883,6 @@ func getAction() core.GetAction {
return core.GetActionImpl{ActionImpl: core.ActionImpl{Verb: "get", Resource: schema.GroupVersionResource{Resource: "pods"}}} return core.GetActionImpl{ActionImpl: core.ActionImpl{Verb: "get", Resource: schema.GroupVersionResource{Resource: "pods"}}}
} }
func updateAction() core.UpdateAction {
return core.UpdateActionImpl{ActionImpl: core.ActionImpl{Verb: "update", Resource: schema.GroupVersionResource{Resource: "pods"}, Subresource: "status"}}
}
func patchAction() core.PatchAction { func patchAction() core.PatchAction {
return core.PatchActionImpl{ActionImpl: core.ActionImpl{Verb: "patch", Resource: schema.GroupVersionResource{Resource: "pods"}, Subresource: "status"}} return core.PatchActionImpl{ActionImpl: core.ActionImpl{Verb: "patch", Resource: schema.GroupVersionResource{Resource: "pods"}, Subresource: "status"}}
} }
......
...@@ -142,7 +142,6 @@ go_test( ...@@ -142,7 +142,6 @@ go_test(
"//pkg/api/legacyscheme:go_default_library", "//pkg/api/legacyscheme:go_default_library",
"//pkg/api/testapi:go_default_library", "//pkg/api/testapi:go_default_library",
"//pkg/apis/batch:go_default_library", "//pkg/apis/batch:go_default_library",
"//pkg/apis/core:go_default_library",
"//pkg/apis/storage:go_default_library", "//pkg/apis/storage:go_default_library",
"//pkg/generated/openapi:go_default_library", "//pkg/generated/openapi:go_default_library",
"//pkg/kubelet/client:go_default_library", "//pkg/kubelet/client:go_default_library",
......
...@@ -52,7 +52,6 @@ import ( ...@@ -52,7 +52,6 @@ import (
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/api/testapi" "k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/pkg/apis/batch"
api "k8s.io/kubernetes/pkg/apis/core"
apisstorage "k8s.io/kubernetes/pkg/apis/storage" apisstorage "k8s.io/kubernetes/pkg/apis/storage"
kubeletclient "k8s.io/kubernetes/pkg/kubelet/client" kubeletclient "k8s.io/kubernetes/pkg/kubelet/client"
"k8s.io/kubernetes/pkg/master/reconcilers" "k8s.io/kubernetes/pkg/master/reconcilers"
...@@ -233,12 +232,6 @@ func TestVersion(t *testing.T) { ...@@ -233,12 +232,6 @@ func TestVersion(t *testing.T) {
} }
} }
type fakeEndpointReconciler struct{}
func (*fakeEndpointReconciler) ReconcileEndpoints(serviceName string, ip net.IP, endpointPorts []api.EndpointPort, reconcilePorts bool) error {
return nil
}
func makeNodeList(nodes []string, nodeResources apiv1.NodeResources) *apiv1.NodeList { func makeNodeList(nodes []string, nodeResources apiv1.NodeResources) *apiv1.NodeList {
list := apiv1.NodeList{ list := apiv1.NodeList{
Items: make([]apiv1.Node, len(nodes)), Items: make([]apiv1.Node, len(nodes)),
......
...@@ -1010,14 +1010,6 @@ func printServiceList(list *api.ServiceList, options printers.PrintOptions) ([]m ...@@ -1010,14 +1010,6 @@ func printServiceList(list *api.ServiceList, options printers.PrintOptions) ([]m
return rows, nil return rows, nil
} }
// backendStringer behaves just like a string interface and converts the given backend to a string.
func backendStringer(backend *networking.IngressBackend) string {
if backend == nil {
return ""
}
return fmt.Sprintf("%v:%v", backend.ServiceName, backend.ServicePort.String())
}
func formatHosts(rules []networking.IngressRule) string { func formatHosts(rules []networking.IngressRule) string {
list := []string{} list := []string{}
max := 3 max := 3
......
...@@ -327,15 +327,6 @@ func TestDeleteEndpointConnections(t *testing.T) { ...@@ -327,15 +327,6 @@ func TestDeleteEndpointConnections(t *testing.T) {
} }
} }
type fakeClosable struct {
closed bool
}
func (c *fakeClosable) Close() error {
c.closed = true
return nil
}
// fakePortOpener implements portOpener. // fakePortOpener implements portOpener.
type fakePortOpener struct { type fakePortOpener struct {
openPorts []*utilproxy.LocalPort openPorts []*utilproxy.LocalPort
......
...@@ -18,7 +18,6 @@ package componentstatus ...@@ -18,7 +18,6 @@ package componentstatus
import ( import (
"crypto/tls" "crypto/tls"
"net/http"
"sync" "sync"
"time" "time"
...@@ -31,11 +30,6 @@ const ( ...@@ -31,11 +30,6 @@ const (
probeTimeOut = 20 * time.Second probeTimeOut = 20 * time.Second
) )
// TODO: this basic interface is duplicated in N places. consolidate?
type httpGet interface {
Get(url string) (*http.Response, error)
}
type ValidatorFn func([]byte) error type ValidatorFn func([]byte) error
type Server struct { type Server struct {
......
...@@ -9,7 +9,6 @@ go_library( ...@@ -9,7 +9,6 @@ go_library(
importpath = "k8s.io/kubernetes/pkg/scheduler/internal/queue", importpath = "k8s.io/kubernetes/pkg/scheduler/internal/queue",
visibility = ["//pkg/scheduler:__subpackages__"], visibility = ["//pkg/scheduler:__subpackages__"],
deps = [ deps = [
"//pkg/api/v1/pod:go_default_library",
"//pkg/scheduler/algorithm/predicates:go_default_library", "//pkg/scheduler/algorithm/predicates:go_default_library",
"//pkg/scheduler/algorithm/priorities/util:go_default_library", "//pkg/scheduler/algorithm/priorities/util:go_default_library",
"//pkg/scheduler/metrics:go_default_library", "//pkg/scheduler/metrics:go_default_library",
......
...@@ -39,7 +39,6 @@ import ( ...@@ -39,7 +39,6 @@ import (
ktypes "k8s.io/apimachinery/pkg/types" ktypes "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates" "k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
priorityutil "k8s.io/kubernetes/pkg/scheduler/algorithm/priorities/util" priorityutil "k8s.io/kubernetes/pkg/scheduler/algorithm/priorities/util"
"k8s.io/kubernetes/pkg/scheduler/metrics" "k8s.io/kubernetes/pkg/scheduler/metrics"
...@@ -353,11 +352,6 @@ func (p *PriorityQueue) AddIfNotPresent(pod *v1.Pod) error { ...@@ -353,11 +352,6 @@ func (p *PriorityQueue) AddIfNotPresent(pod *v1.Pod) error {
return err return err
} }
func isPodUnschedulable(pod *v1.Pod) bool {
_, cond := podutil.GetPodCondition(&pod.Status, v1.PodScheduled)
return cond != nil && cond.Status == v1.ConditionFalse && cond.Reason == v1.PodReasonUnschedulable
}
// nsNameForPod returns a namespacedname for a pod // nsNameForPod returns a namespacedname for a pod
func nsNameForPod(pod *v1.Pod) ktypes.NamespacedName { func nsNameForPod(pod *v1.Pod) ktypes.NamespacedName {
return ktypes.NamespacedName{ return ktypes.NamespacedName{
......
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- piosz
- brancz
reviewers:
- sig-instrumentation-pr-reviews
labels:
- sig/instrumentation
...@@ -113,18 +113,6 @@ func TestDoCleanupMountPoint(t *testing.T) { ...@@ -113,18 +113,6 @@ func TestDoCleanupMountPoint(t *testing.T) {
} }
} }
func validateDirEmpty(dir string) error {
files, err := ioutil.ReadDir(dir)
if err != nil {
return err
}
if len(files) != 0 {
return fmt.Errorf("Directory %q is not empty", dir)
}
return nil
}
func validateDirExists(dir string) error { func validateDirExists(dir string) error {
_, err := ioutil.ReadDir(dir) _, err := ioutil.ReadDir(dir)
if err != nil { if err != nil {
...@@ -143,10 +131,3 @@ func validateDirNotExists(dir string) error { ...@@ -143,10 +131,3 @@ func validateDirNotExists(dir string) error {
} }
return fmt.Errorf("dir %q still exists", dir) return fmt.Errorf("dir %q still exists", dir)
} }
func validateFileExists(file string) error {
if _, err := os.Stat(file); err != nil {
return err
}
return nil
}
...@@ -205,13 +205,6 @@ type detachCall struct { ...@@ -205,13 +205,6 @@ type detachCall struct {
ret error ret error
} }
type diskIsAttachedCall struct {
diskName aws.KubernetesVolumeID
nodeName types.NodeName
isAttached bool
ret error
}
func (testcase *testcase) AttachDisk(diskName aws.KubernetesVolumeID, nodeName types.NodeName) (string, error) { func (testcase *testcase) AttachDisk(diskName aws.KubernetesVolumeID, nodeName types.NodeName) (string, error) {
expected := &testcase.attach expected := &testcase.attach
......
...@@ -454,27 +454,6 @@ func makeGlobalPDPath(host volume.VolumeHost, volumeID aws.KubernetesVolumeID) s ...@@ -454,27 +454,6 @@ func makeGlobalPDPath(host volume.VolumeHost, volumeID aws.KubernetesVolumeID) s
return filepath.Join(host.GetPluginDir(awsElasticBlockStorePluginName), mount.MountsInGlobalPDPath, name) return filepath.Join(host.GetPluginDir(awsElasticBlockStorePluginName), mount.MountsInGlobalPDPath, name)
} }
// Reverses the mapping done in makeGlobalPDPath
func getVolumeIDFromGlobalMount(host volume.VolumeHost, globalPath string) (string, error) {
basePath := filepath.Join(host.GetPluginDir(awsElasticBlockStorePluginName), mount.MountsInGlobalPDPath)
rel, err := filepath.Rel(basePath, globalPath)
if err != nil {
klog.Errorf("Failed to get volume id from global mount %s - %v", globalPath, err)
return "", err
}
if strings.Contains(rel, "../") {
klog.Errorf("Unexpected mount path: %s", globalPath)
return "", fmt.Errorf("unexpected mount path: " + globalPath)
}
// Reverse the :// replacement done in makeGlobalPDPath
volumeID := rel
if strings.HasPrefix(volumeID, "aws/") {
volumeID = strings.Replace(volumeID, "aws/", "aws://", 1)
}
klog.V(2).Info("Mapping mount dir ", globalPath, " to volumeID ", volumeID)
return volumeID, nil
}
func (ebs *awsElasticBlockStore) GetPath() string { func (ebs *awsElasticBlockStore) GetPath() string {
return getPath(ebs.podUID, ebs.volName, ebs.plugin.host) return getPath(ebs.podUID, ebs.volName, ebs.plugin.host)
} }
......
...@@ -201,20 +201,6 @@ func verifyDevicePath(devicePaths []string) (string, error) { ...@@ -201,20 +201,6 @@ func verifyDevicePath(devicePaths []string) (string, error) {
return "", nil return "", nil
} }
// Returns the first path that exists, or empty string if none exist.
func verifyAllPathsRemoved(devicePaths []string) (bool, error) {
allPathsRemoved := true
for _, path := range devicePaths {
exists, err := mount.PathExists(path)
if err != nil {
return false, fmt.Errorf("Error checking if path exists: %v", err)
}
allPathsRemoved = allPathsRemoved && !exists
}
return allPathsRemoved, nil
}
// Returns list of all paths for given EBS mount // Returns list of all paths for given EBS mount
// This is more interesting on GCE (where we are able to identify volumes under /dev/disk-by-id) // This is more interesting on GCE (where we are able to identify volumes under /dev/disk-by-id)
// Here it is mostly about applying the partition path // Here it is mostly about applying the partition path
......
...@@ -904,12 +904,3 @@ func isV0Version(version string) bool { ...@@ -904,12 +904,3 @@ func isV0Version(version string) bool {
return parsedVersion.Major() == 0 return parsedVersion.Major() == 0
} }
func isV1Version(version string) bool {
parsedVersion, err := utilversion.ParseGeneric(version)
if err != nil {
return false
}
return parsedVersion.Major() == 1
}
...@@ -20,7 +20,6 @@ import ( ...@@ -20,7 +20,6 @@ import (
"encoding/json" "encoding/json"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume"
volumetesting "k8s.io/kubernetes/pkg/volume/testing" volumetesting "k8s.io/kubernetes/pkg/volume/testing"
"k8s.io/kubernetes/test/utils/harness" "k8s.io/kubernetes/test/utils/harness"
...@@ -108,23 +107,6 @@ func fakeVolumeSpec() *volume.Spec { ...@@ -108,23 +107,6 @@ func fakeVolumeSpec() *volume.Spec {
return volume.NewSpecFromVolume(vol) return volume.NewSpecFromVolume(vol)
} }
func fakePersistentVolumeSpec() *volume.Spec {
vol := &v1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Name: "vol1",
},
Spec: v1.PersistentVolumeSpec{
PersistentVolumeSource: v1.PersistentVolumeSource{
FlexVolume: &v1.FlexPersistentVolumeSource{
Driver: "kubernetes.io/fakeAttacher",
ReadOnly: false,
},
},
},
}
return volume.NewSpecFromPersistentVolume(vol, false)
}
func specJSON(plugin *flexVolumeAttachablePlugin, spec *volume.Spec, extraOptions map[string]string) string { func specJSON(plugin *flexVolumeAttachablePlugin, spec *volume.Spec, extraOptions map[string]string) string {
o, err := NewOptionsForDriver(spec, plugin.host, extraOptions) o, err := NewOptionsForDriver(spec, plugin.host, extraOptions)
if err != nil { if err != nil {
......
...@@ -302,62 +302,3 @@ func TestIsReadOnly(t *testing.T) { ...@@ -302,62 +302,3 @@ func TestIsReadOnly(t *testing.T) {
b := &flockerVolumeMounter{readOnly: true} b := &flockerVolumeMounter{readOnly: true}
assert.True(t, b.GetAttributes().ReadOnly) assert.True(t, b.GetAttributes().ReadOnly)
} }
type mockFlockerClient struct {
datasetID, primaryUUID, path string
datasetState *flockerapi.DatasetState
}
func newMockFlockerClient(mockDatasetID, mockPrimaryUUID, mockPath string) *mockFlockerClient {
return &mockFlockerClient{
datasetID: mockDatasetID,
primaryUUID: mockPrimaryUUID,
path: mockPath,
datasetState: &flockerapi.DatasetState{
Path: mockPath,
DatasetID: mockDatasetID,
Primary: mockPrimaryUUID,
},
}
}
func (m mockFlockerClient) CreateDataset(metaName string) (*flockerapi.DatasetState, error) {
return m.datasetState, nil
}
func (m mockFlockerClient) GetDatasetState(datasetID string) (*flockerapi.DatasetState, error) {
return m.datasetState, nil
}
func (m mockFlockerClient) GetDatasetID(metaName string) (string, error) {
return m.datasetID, nil
}
func (m mockFlockerClient) GetPrimaryUUID() (string, error) {
return m.primaryUUID, nil
}
func (m mockFlockerClient) UpdatePrimaryForDataset(primaryUUID, datasetID string) (*flockerapi.DatasetState, error) {
return m.datasetState, nil
}
/*
TODO: re-enable after refactor
func TestSetUpAtInternal(t *testing.T) {
const dir = "dir"
mockPath := "expected-to-be-set-properly" // package var
expectedPath := mockPath
assert := assert.New(t)
plugMgr, rootDir := newInitializedVolumePlugMgr(t)
if rootDir != "" {
defer os.RemoveAll(rootDir)
}
plug, err := plugMgr.FindPluginByName(flockerPluginName)
assert.NoError(err)
pod := &v1.Pod{ObjectMeta: metav1.ObjectMeta{UID: types.UID("poduid")}}
b := flockerVolumeMounter{flockerVolume: &flockerVolume{pod: pod, plugin: plug.(*flockerPlugin)}}
b.client = newMockFlockerClient("dataset-id", "primary-uid", mockPath)
assert.NoError(b.SetUpAt(dir, nil))
assert.Equal(expectedPath, b.flocker.path)
}
*/
...@@ -594,15 +594,6 @@ func createSecretMap(spec *volume.Spec, plugin *iscsiPlugin, namespace string) ( ...@@ -594,15 +594,6 @@ func createSecretMap(spec *volume.Spec, plugin *iscsiPlugin, namespace string) (
return secret, err return secret, err
} }
func createVolumeFromISCSIVolumeSource(volumeName string, iscsi v1.ISCSIVolumeSource) *v1.Volume {
return &v1.Volume{
Name: volumeName,
VolumeSource: v1.VolumeSource{
ISCSI: &iscsi,
},
}
}
func createPersistentVolumeFromISCSIPVSource(volumeName string, iscsi v1.ISCSIPersistentVolumeSource) *v1.PersistentVolume { func createPersistentVolumeFromISCSIPVSource(volumeName string, iscsi v1.ISCSIPersistentVolumeSource) *v1.PersistentVolume {
block := v1.PersistentVolumeBlock block := v1.PersistentVolumeBlock
return &v1.PersistentVolume{ return &v1.PersistentVolume{
......
...@@ -1193,20 +1193,6 @@ func makeSecret(namespace, name string) v1.Secret { ...@@ -1193,20 +1193,6 @@ func makeSecret(namespace, name string) v1.Secret {
} }
} }
func configMap(namespace, name string) v1.ConfigMap {
return v1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
Name: name,
},
Data: map[string]string{
"data-1": "value-1",
"data-2": "value-2",
"data-3": "value-3",
},
}
}
func makeProjection(name string, defaultMode int32, kind string) *v1.ProjectedVolumeSource { func makeProjection(name string, defaultMode int32, kind string) *v1.ProjectedVolumeSource {
var item v1.VolumeProjection var item v1.VolumeProjection
......
...@@ -1081,15 +1081,6 @@ func getVolumeAccessModes(spec *volume.Spec) ([]v1.PersistentVolumeAccessMode, e ...@@ -1081,15 +1081,6 @@ func getVolumeAccessModes(spec *volume.Spec) ([]v1.PersistentVolumeAccessMode, e
return nil, nil return nil, nil
} }
func parsePodSecret(pod *v1.Pod, secretName string, kubeClient clientset.Interface) (string, error) {
secret, err := volutil.GetSecretForPod(pod, secretName, kubeClient)
if err != nil {
klog.Errorf("failed to get secret from [%q/%q]: %+v", pod.Namespace, secretName, err)
return "", fmt.Errorf("failed to get secret from [%q/%q]: %+v", pod.Namespace, secretName, err)
}
return parseSecretMap(secret)
}
func parsePVSecret(namespace, secretName string, kubeClient clientset.Interface) (string, error) { func parsePVSecret(namespace, secretName string, kubeClient clientset.Interface) (string, error) {
secret, err := volutil.GetSecretForPV(namespace, secretName, rbdPluginName, kubeClient) secret, err := volutil.GetSecretForPV(namespace, secretName, rbdPluginName, kubeClient)
if err != nil { if err != nil {
......
...@@ -27,14 +27,6 @@ import ( ...@@ -27,14 +27,6 @@ import (
siotypes "github.com/codedellemc/goscaleio/types/v1" siotypes "github.com/codedellemc/goscaleio/types/v1"
) )
type storageInterface interface {
CreateVolume(string, int64) (*siotypes.Volume, error)
AttachVolume(string, bool) (string, error)
IsAttached(string) (bool, error)
DetachVolume(string) error
DeleteVolume(string) error
}
type sioMgr struct { type sioMgr struct {
client sioInterface client sioInterface
configData map[string]string configData map[string]string
......
...@@ -62,10 +62,6 @@ func TestCanSupport(t *testing.T) { ...@@ -62,10 +62,6 @@ func TestCanSupport(t *testing.T) {
type fakePDManager struct { type fakePDManager struct {
} }
func getFakeDeviceName(host volume.VolumeHost, volPath string) string {
return path.Join(host.GetPluginDir(vsphereVolumePluginName), "device", volPath)
}
func (fake *fakePDManager) CreateVolume(v *vsphereVolumeProvisioner, selectedZone []string) (volSpec *VolumeSpec, err error) { func (fake *fakePDManager) CreateVolume(v *vsphereVolumeProvisioner, selectedZone []string) (volSpec *VolumeSpec, err error) {
volSpec = &VolumeSpec{ volSpec = &VolumeSpec{
Path: "[local] test-volume-name.vmdk", Path: "[local] test-volume-name.vmdk",
......
...@@ -80,13 +80,3 @@ func SetDefaults_ServiceReference(obj *ServiceReference) { ...@@ -80,13 +80,3 @@ func SetDefaults_ServiceReference(obj *ServiceReference) {
obj.Port = utilpointer.Int32Ptr(443) obj.Port = utilpointer.Int32Ptr(443)
} }
} }
// hasPerVersionColumns returns true if a CRD uses per-version columns.
func hasPerVersionColumns(versions []CustomResourceDefinitionVersion) bool {
for _, v := range versions {
if len(v.AdditionalPrinterColumns) > 0 {
return true
}
}
return false
}
...@@ -54,10 +54,6 @@ func jsonTag(field reflect.StructField) (string, bool) { ...@@ -54,10 +54,6 @@ func jsonTag(field reflect.StructField) (string, bool) {
return tag, omitempty return tag, omitempty
} }
func formatValue(value interface{}) string {
return fmt.Sprintf("%v", value)
}
func isPointerKind(kind reflect.Kind) bool { func isPointerKind(kind reflect.Kind) bool {
return kind == reflect.Ptr return kind == reflect.Ptr
} }
......
...@@ -211,10 +211,6 @@ func ResourceFinderForResult(result resource.Visitor) ResourceFinder { ...@@ -211,10 +211,6 @@ func ResourceFinderForResult(result resource.Visitor) ResourceFinder {
}) })
} }
func strPtr(val string) *string {
return &val
}
func boolPtr(val bool) *bool { func boolPtr(val bool) *bool {
return &val return &val
} }
...@@ -30,10 +30,6 @@ import ( ...@@ -30,10 +30,6 @@ import (
var scaleConverter = NewScaleConverter() var scaleConverter = NewScaleConverter()
var codecs = serializer.NewCodecFactory(scaleConverter.Scheme()) var codecs = serializer.NewCodecFactory(scaleConverter.Scheme())
// restInterfaceProvider turns a restclient.Config into a restclient.Interface.
// It's overridable for the purposes of testing.
type restInterfaceProvider func(*restclient.Config) (restclient.Interface, error)
// scaleClient is an implementation of ScalesGetter // scaleClient is an implementation of ScalesGetter
// which makes use of a RESTMapper and a generic REST // which makes use of a RESTMapper and a generic REST
// client to support an discoverable resource. // client to support an discoverable resource.
......
...@@ -25,7 +25,6 @@ import ( ...@@ -25,7 +25,6 @@ import (
"net" "net"
"net/url" "net/url"
"reflect" "reflect"
"strings"
"sync" "sync"
"syscall" "syscall"
"time" "time"
...@@ -113,11 +112,6 @@ func NewNamedReflector(name string, lw ListerWatcher, expectedType interface{}, ...@@ -113,11 +112,6 @@ func NewNamedReflector(name string, lw ListerWatcher, expectedType interface{},
return r return r
} }
func makeValidPrometheusMetricLabel(in string) string {
// this isn't perfect, but it removes our common characters
return strings.NewReplacer("/", "_", ".", "_", "-", "_", ":", "_").Replace(in)
}
// internalPackages are packages that ignored when creating a default reflector name. These packages are in the common // internalPackages are packages that ignored when creating a default reflector name. These packages are in the common
// call chains to NewReflector, so they'd be low entropy names for reflectors // call chains to NewReflector, so they'd be low entropy names for reflectors
var internalPackages = []string{"client-go/tools/cache/"} var internalPackages = []string{"client-go/tools/cache/"}
......
...@@ -94,23 +94,6 @@ var metricsFactory = struct { ...@@ -94,23 +94,6 @@ var metricsFactory = struct {
metricsProvider: noopMetricsProvider{}, metricsProvider: noopMetricsProvider{},
} }
func newReflectorMetrics(name string) *reflectorMetrics {
var ret *reflectorMetrics
if len(name) == 0 {
return ret
}
return &reflectorMetrics{
numberOfLists: metricsFactory.metricsProvider.NewListsMetric(name),
listDuration: metricsFactory.metricsProvider.NewListDurationMetric(name),
numberOfItemsInList: metricsFactory.metricsProvider.NewItemsInListMetric(name),
numberOfWatches: metricsFactory.metricsProvider.NewWatchesMetric(name),
numberOfShortWatches: metricsFactory.metricsProvider.NewShortWatchesMetric(name),
watchDuration: metricsFactory.metricsProvider.NewWatchDurationMetric(name),
numberOfItemsInWatch: metricsFactory.metricsProvider.NewItemsInWatchMetric(name),
lastResourceVersion: metricsFactory.metricsProvider.NewLastResourceVersionMetric(name),
}
}
// SetReflectorMetricsProvider sets the metrics provider // SetReflectorMetricsProvider sets the metrics provider
func SetReflectorMetricsProvider(metricsProvider MetricsProvider) { func SetReflectorMetricsProvider(metricsProvider MetricsProvider) {
metricsFactory.setProviders.Do(func() { metricsFactory.setProviders.Do(func() {
......
...@@ -296,16 +296,6 @@ func makeUserIdentificationConfig(info clientauth.Info) *restclient.Config { ...@@ -296,16 +296,6 @@ func makeUserIdentificationConfig(info clientauth.Info) *restclient.Config {
return config return config
} }
// makeUserIdentificationFieldsConfig returns a client.Config capable of being merged using mergo for only server identification information
func makeServerIdentificationConfig(info clientauth.Info) restclient.Config {
config := restclient.Config{}
config.CAFile = info.CAFile
if info.Insecure != nil {
config.Insecure = *info.Insecure
}
return config
}
func canIdentifyUser(config restclient.Config) bool { func canIdentifyUser(config restclient.Config) bool {
return len(config.Username) > 0 || return len(config.Username) > 0 ||
(len(config.CertFile) > 0 || len(config.CertData) > 0) || (len(config.CertFile) > 0 || len(config.CertData) > 0) ||
......
...@@ -23,7 +23,6 @@ import ( ...@@ -23,7 +23,6 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"time" "time"
"k8s.io/klog" "k8s.io/klog"
...@@ -289,12 +288,6 @@ func (s *fileStore) filename(qualifier string) string { ...@@ -289,12 +288,6 @@ func (s *fileStore) filename(qualifier string) string {
return s.pairNamePrefix + "-" + qualifier + pemExtension return s.pairNamePrefix + "-" + qualifier + pemExtension
} }
// withoutExt returns the given filename after removing the extension. The
// extension to remove will be the result of filepath.Ext().
func withoutExt(filename string) string {
return strings.TrimSuffix(filename, filepath.Ext(filename))
}
func loadX509KeyPair(certFile, keyFile string) (*tls.Certificate, error) { func loadX509KeyPair(certFile, keyFile string) (*tls.Certificate, error) {
cert, err := tls.LoadX509KeyPair(certFile, keyFile) cert, err := tls.LoadX509KeyPair(certFile, keyFile)
if err != nil { if err != nil {
......
...@@ -14,7 +14,6 @@ go_library( ...@@ -14,7 +14,6 @@ go_library(
"groupinterface.go", "groupinterface.go",
"informer.go", "informer.go",
"packages.go", "packages.go",
"tags.go",
"types.go", "types.go",
"versioninterface.go", "versioninterface.go",
], ],
......
/*
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 generators
import (
"k8s.io/gengo/types"
"k8s.io/klog"
)
// extractBoolTagOrDie gets the comment-tags for the key and asserts that, if
// it exists, the value is boolean. If the tag did not exist, it returns
// false.
func extractBoolTagOrDie(key string, lines []string) bool {
val, err := types.ExtractSingleBoolCommentTag("+", key, false, lines)
if err != nil {
klog.Fatal(err)
}
return val
}
...@@ -10,7 +10,6 @@ go_library( ...@@ -10,7 +10,6 @@ go_library(
srcs = [ srcs = [
"expansion.go", "expansion.go",
"lister.go", "lister.go",
"tags.go",
], ],
importmap = "k8s.io/kubernetes/vendor/k8s.io/code-generator/cmd/lister-gen/generators", importmap = "k8s.io/kubernetes/vendor/k8s.io/code-generator/cmd/lister-gen/generators",
importpath = "k8s.io/code-generator/cmd/lister-gen/generators", importpath = "k8s.io/code-generator/cmd/lister-gen/generators",
......
/*
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 generators
import (
"k8s.io/gengo/types"
"k8s.io/klog"
)
// extractBoolTagOrDie gets the comment-tags for the key and asserts that, if
// it exists, the value is boolean. If the tag did not exist, it returns
// false.
func extractBoolTagOrDie(key string, lines []string) bool {
val, err := types.ExtractSingleBoolCommentTag("+", key, false, lines)
if err != nil {
klog.Fatal(err)
}
return val
}
...@@ -300,18 +300,6 @@ func (v *visitor) Visit(node ast.Node) (w ast.Visitor) { ...@@ -300,18 +300,6 @@ func (v *visitor) Visit(node ast.Node) (w ast.Visitor) {
return v return v
} }
func scandir(dir string) {
v := newVisitor()
pkg, err := parser.ParseDir(v.FileSet, dir, nil, parser.ParseComments)
if err != nil {
panic(err)
}
for _, p := range pkg {
ast.Walk(v, p)
}
}
func scanfile(path string, src interface{}) []conformanceData { func scanfile(path string, src interface{}) []conformanceData {
v := newVisitor() v := newVisitor()
file, err := parser.ParseFile(v.FileSet, path, src, parser.ParseComments) file, err := parser.ParseFile(v.FileSet, path, src, parser.ParseComments)
......
...@@ -36,27 +36,6 @@ import ( ...@@ -36,27 +36,6 @@ import (
imageutils "k8s.io/kubernetes/test/utils/image" imageutils "k8s.io/kubernetes/test/utils/image"
) )
func stagingClientPod(name, value string) v1.Pod {
return v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: map[string]string{
"name": "foo",
"time": value,
},
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "nginx",
Image: imageutils.GetE2EImage(imageutils.Nginx),
Ports: []v1.ContainerPort{{ContainerPort: 80}},
},
},
},
}
}
func testingPod(name, value string) v1.Pod { func testingPod(name, value string) v1.Pod {
return v1.Pod{ return v1.Pod{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
...@@ -98,34 +77,6 @@ func observeCreation(w watch.Interface) { ...@@ -98,34 +77,6 @@ func observeCreation(w watch.Interface) {
} }
} }
func observeObjectDeletion(w watch.Interface) (obj runtime.Object) {
// output to give us a duration to failure. Maybe we aren't getting the
// full timeout for some reason. My guess would be watch failure
framework.Logf("Starting to observe pod deletion")
deleted := false
timeout := false
timer := time.After(framework.DefaultPodDeletionTimeout)
for !deleted && !timeout {
select {
case event, normal := <-w.ResultChan():
if !normal {
framework.Failf("The channel was closed unexpectedly")
return
}
if event.Type == watch.Deleted {
obj = event.Object
deleted = true
}
case <-timer:
timeout = true
}
}
if !deleted {
framework.Failf("Failed to observe pod deletion")
}
return
}
func observerUpdate(w watch.Interface, expectedUpdate func(runtime.Object) bool) { func observerUpdate(w watch.Interface, expectedUpdate func(runtime.Object) bool) {
timer := time.After(30 * time.Second) timer := time.After(30 * time.Second)
updated := false updated := false
......
...@@ -27,7 +27,6 @@ import ( ...@@ -27,7 +27,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
imageutils "k8s.io/kubernetes/test/utils/image" imageutils "k8s.io/kubernetes/test/utils/image"
...@@ -82,23 +81,6 @@ func extinguish(f *framework.Framework, totalNS int, maxAllowedAfterDel int, max ...@@ -82,23 +81,6 @@ func extinguish(f *framework.Framework, totalNS int, maxAllowedAfterDel int, max
})) }))
} }
func waitForPodInNamespace(c clientset.Interface, ns, podName string) *v1.Pod {
var pod *v1.Pod
var err error
err = wait.PollImmediate(2*time.Second, 15*time.Second, func() (bool, error) {
pod, err = c.CoreV1().Pods(ns).Get(podName, metav1.GetOptions{})
if errors.IsNotFound(err) {
return false, nil
}
if err != nil {
return false, err
}
return true, nil
})
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "failed to get pod %s in namespace: %s", podName, ns)
return pod
}
func ensurePodsAreRemovedWhenNamespaceIsDeleted(f *framework.Framework) { func ensurePodsAreRemovedWhenNamespaceIsDeleted(f *framework.Framework) {
ginkgo.By("Creating a test namespace") ginkgo.By("Creating a test namespace")
namespaceName := "nsdeletetest" namespaceName := "nsdeletetest"
......
...@@ -1362,17 +1362,6 @@ func newTestResourceQuotaWithScopeForPriorityClass(name string, hard v1.Resource ...@@ -1362,17 +1362,6 @@ func newTestResourceQuotaWithScopeForPriorityClass(name string, hard v1.Resource
} }
} }
// newTestResourceQuotaForEphemeralStorage returns a quota that enforces default constraints for testing feature LocalStorageCapacityIsolation
func newTestResourceQuotaForEphemeralStorage(name string) *v1.ResourceQuota {
hard := v1.ResourceList{}
hard[v1.ResourceEphemeralStorage] = resource.MustParse("500Mi")
hard[v1.ResourceQuotas] = resource.MustParse("1")
return &v1.ResourceQuota{
ObjectMeta: metav1.ObjectMeta{Name: name},
Spec: v1.ResourceQuotaSpec{Hard: hard},
}
}
// newTestResourceQuota returns a quota that enforces default constraints for testing // newTestResourceQuota returns a quota that enforces default constraints for testing
func newTestResourceQuota(name string) *v1.ResourceQuota { func newTestResourceQuota(name string) *v1.ResourceQuota {
hard := v1.ResourceList{} hard := v1.ResourceList{}
......
...@@ -17,7 +17,6 @@ limitations under the License. ...@@ -17,7 +17,6 @@ limitations under the License.
package autoscaling package autoscaling
import ( import (
"bytes"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math" "math"
...@@ -1187,30 +1186,6 @@ func disableAutoscaler(nodePool string, minCount, maxCount int) error { ...@@ -1187,30 +1186,6 @@ func disableAutoscaler(nodePool string, minCount, maxCount int) error {
return fmt.Errorf("autoscaler still enabled, last error: %v", finalErr) return fmt.Errorf("autoscaler still enabled, last error: %v", finalErr)
} }
func executeHTTPRequest(method string, url string, body string) (string, error) {
client := &http.Client{}
req, err := http.NewRequest(method, url, strings.NewReader(body))
if err != nil {
By(fmt.Sprintf("Can't create request: %s", err.Error()))
return "", err
}
resp, err := client.Do(req)
if err != nil {
return "", err
}
defer resp.Body.Close()
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("error: %s %s", resp.Status, string(respBody))
}
return string(respBody), nil
}
func addNodePool(name string, machineType string, numNodes int) { func addNodePool(name string, machineType string, numNodes int) {
args := []string{"container", "node-pools", "create", name, "--quiet", args := []string{"container", "node-pools", "create", name, "--quiet",
"--machine-type=" + machineType, "--machine-type=" + machineType,
...@@ -1297,26 +1272,6 @@ func getPoolSize(f *framework.Framework, poolName string) int { ...@@ -1297,26 +1272,6 @@ func getPoolSize(f *framework.Framework, poolName string) int {
return size return size
} }
func doPut(url, content string) (string, error) {
req, err := http.NewRequest("PUT", url, bytes.NewBuffer([]byte(content)))
if err != nil {
return "", err
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return "", err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
strBody := string(body)
return strBody, nil
}
func reserveMemory(f *framework.Framework, id string, replicas, megabytes int, expectRunning bool, timeout time.Duration, selector map[string]string, tolerations []v1.Toleration, priorityClassName string) func() error { func reserveMemory(f *framework.Framework, id string, replicas, megabytes int, expectRunning bool, timeout time.Duration, selector map[string]string, tolerations []v1.Toleration, priorityClassName string) func() error {
By(fmt.Sprintf("Running RC which reserves %v MB of memory", megabytes)) By(fmt.Sprintf("Running RC which reserves %v MB of memory", megabytes))
request := int64(1024 * 1024 * megabytes / replicas) request := int64(1024 * 1024 * megabytes / replicas)
...@@ -1750,14 +1705,6 @@ func runReplicatedPodOnEachNode(f *framework.Framework, nodes []v1.Node, namespa ...@@ -1750,14 +1705,6 @@ func runReplicatedPodOnEachNode(f *framework.Framework, nodes []v1.Node, namespa
return nil return nil
} }
// wrap runReplicatedPodOnEachNode to return cleanup
func runReplicatedPodOnEachNodeWithCleanup(f *framework.Framework, nodes []v1.Node, namespace string, podsPerNode int, id string, labels map[string]string, memRequest int64) (func(), error) {
err := runReplicatedPodOnEachNode(f, nodes, namespace, podsPerNode, id, labels, memRequest)
return func() {
framework.DeleteRCAndWaitForGC(f.ClientSet, namespace, id)
}, err
}
// Increase cluster size by newNodesForScaledownTests to create some unused nodes // Increase cluster size by newNodesForScaledownTests to create some unused nodes
// that can be later removed by cluster autoscaler. // that can be later removed by cluster autoscaler.
func manuallyIncreaseClusterSize(f *framework.Framework, originalSizes map[string]int) int { func manuallyIncreaseClusterSize(f *framework.Framework, originalSizes map[string]int) int {
......
...@@ -39,14 +39,6 @@ func nodeNames(nodes []v1.Node) []string { ...@@ -39,14 +39,6 @@ func nodeNames(nodes []v1.Node) []string {
return result return result
} }
func podNames(pods []v1.Pod) []string {
result := make([]string, 0, len(pods))
for i := range pods {
result = append(result, pods[i].Name)
}
return result
}
var _ = Describe("Recreate [Feature:Recreate]", func() { var _ = Describe("Recreate [Feature:Recreate]", func() {
f := framework.NewDefaultFramework("recreate") f := framework.NewDefaultFramework("recreate")
var originalNodes []v1.Node var originalNodes []v1.Node
......
...@@ -860,29 +860,6 @@ func executeBacksideBacksideHTTPSTest(f *framework.Framework, jig *ingress.TestJ ...@@ -860,29 +860,6 @@ func executeBacksideBacksideHTTPSTest(f *framework.Framework, jig *ingress.TestJ
Expect(err).NotTo(HaveOccurred(), "Failed to verify backside re-encryption ingress") Expect(err).NotTo(HaveOccurred(), "Failed to verify backside re-encryption ingress")
} }
func detectHTTPVersionAndSchemeTest(f *framework.Framework, jig *ingress.TestJig, address, version, scheme string) {
timeoutClient := &http.Client{Timeout: ingress.IngressReqTimeout}
resp := ""
err := wait.PollImmediate(framework.LoadBalancerPollInterval, framework.LoadBalancerPollTimeout, func() (bool, error) {
var err error
resp, err = framework.SimpleGET(timeoutClient, fmt.Sprintf("http://%s", address), "")
if err != nil {
framework.Logf("SimpleGET failed: %v", err)
return false, nil
}
if !strings.Contains(resp, version) {
framework.Logf("Waiting for transition to HTTP/2")
return false, nil
}
if !strings.Contains(resp, scheme) {
return false, nil
}
framework.Logf("Poll succeeded, request was served by HTTP2")
return true, nil
})
Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("Failed to get %s or %s, response body: %s", version, scheme, resp))
}
func detectNegAnnotation(f *framework.Framework, jig *ingress.TestJig, gceController *gce.IngressController, ns, name string, negs int) { func detectNegAnnotation(f *framework.Framework, jig *ingress.TestJig, gceController *gce.IngressController, ns, name string, negs int) {
if err := wait.Poll(5*time.Second, negUpdateTimeout, func() (bool, error) { if err := wait.Poll(5*time.Second, negUpdateTimeout, func() (bool, error) {
svc, err := f.ClientSet.CoreV1().Services(ns).Get(name, metav1.GetOptions{}) svc, err := f.ClientSet.CoreV1().Services(ns).Get(name, metav1.GetOptions{})
......
...@@ -287,18 +287,6 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() { ...@@ -287,18 +287,6 @@ var _ = SIGDescribe("[Feature:PodPreset] PodPreset", func() {
}) })
}) })
func getPodPreset(c clientset.Interface, ns, name string) (*settings.PodPreset, error) {
return c.SettingsV1alpha1().PodPresets(ns).Get(name, metav1.GetOptions{})
}
func createPodPreset(c clientset.Interface, ns string, job *settings.PodPreset) (*settings.PodPreset, error) { func createPodPreset(c clientset.Interface, ns string, job *settings.PodPreset) (*settings.PodPreset, error) {
return c.SettingsV1alpha1().PodPresets(ns).Create(job) return c.SettingsV1alpha1().PodPresets(ns).Create(job)
} }
func updatePodPreset(c clientset.Interface, ns string, job *settings.PodPreset) (*settings.PodPreset, error) {
return c.SettingsV1alpha1().PodPresets(ns).Update(job)
}
func deletePodPreset(c clientset.Interface, ns, name string) error {
return c.SettingsV1alpha1().PodPresets(ns).Delete(name, nil)
}
...@@ -57,9 +57,7 @@ go_library( ...@@ -57,9 +57,7 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/strategicpatch:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/strategicpatch:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/version:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/version:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/authentication/serviceaccount:go_default_library", "//staging/src/k8s.io/apiserver/pkg/authentication/serviceaccount:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes:go_default_library", "//staging/src/k8s.io/client-go/kubernetes:go_default_library",
......
...@@ -47,17 +47,6 @@ var ( ...@@ -47,17 +47,6 @@ var (
} }
) )
func csiContainerImage(image string) string {
var fullName string
fullName += *csiImageRegistry + "/" + image + ":"
if *csiImageVersion != "" {
fullName += *csiImageVersion
} else {
fullName += csiImageVersions[image]
}
return fullName
}
func shredFile(filePath string) { func shredFile(filePath string) {
if _, err := os.Stat(filePath); os.IsNotExist(err) { if _, err := os.Stat(filePath); os.IsNotExist(err) {
framework.Logf("File %v was not found, skipping shredding", filePath) framework.Logf("File %v was not found, skipping shredding", filePath)
......
...@@ -27,9 +27,6 @@ import ( ...@@ -27,9 +27,6 @@ import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors" apierrs "k8s.io/apimachinery/pkg/api/errors"
versionutil "k8s.io/apimachinery/pkg/util/version"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/version"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework/testfiles" "k8s.io/kubernetes/test/e2e/framework/testfiles"
...@@ -144,24 +141,6 @@ func sshAndLog(cmd, host string, failOnError bool) { ...@@ -144,24 +141,6 @@ func sshAndLog(cmd, host string, failOnError bool) {
} }
} }
func getMasterVersion(c clientset.Interface) (*versionutil.Version, error) {
var err error
var v *version.Info
waitErr := wait.PollImmediate(5*time.Second, 2*time.Minute, func() (bool, error) {
v, err = c.Discovery().ServerVersion()
return err == nil, nil
})
if waitErr != nil {
return nil, fmt.Errorf("Could not get the master version: %v", waitErr)
}
return versionutil.MustParseSemantic(v.GitVersion), nil
}
func getNodeVersion(node *v1.Node) *versionutil.Version {
return versionutil.MustParseSemantic(node.Status.NodeInfo.KubeletVersion)
}
func getHostFromHostPort(hostPort string) string { func getHostFromHostPort(hostPort string) string {
// try to split host and port // try to split host and port
var host string var host string
......
...@@ -542,30 +542,6 @@ func getTwoRandomZones(c clientset.Interface) []string { ...@@ -542,30 +542,6 @@ func getTwoRandomZones(c clientset.Interface) []string {
return []string{zone1, zone2} return []string{zone1, zone2}
} }
// Waits for at least 1 replica of a StatefulSet to become not ready or until timeout occurs, whichever comes first.
func waitForStatefulSetReplicasNotReady(statefulSetName, ns string, c clientset.Interface) error {
const poll = 3 * time.Second
const timeout = statefulSetReadyTimeout
framework.Logf("Waiting up to %v for StatefulSet %s to have at least 1 replica to become not ready", timeout, statefulSetName)
for start := time.Now(); time.Since(start) < timeout; time.Sleep(poll) {
sts, err := c.AppsV1().StatefulSets(ns).Get(statefulSetName, metav1.GetOptions{})
if err != nil {
framework.Logf("Get StatefulSet %s failed, ignoring for %v: %v", statefulSetName, poll, err)
continue
} else {
if sts.Status.ReadyReplicas < *sts.Spec.Replicas {
framework.Logf("%d replicas are ready out of a total of %d replicas in StatefulSet %s. (%v)",
sts.Status.ReadyReplicas, *sts.Spec.Replicas, statefulSetName, time.Since(start))
return nil
} else {
framework.Logf("StatefulSet %s found but there are %d ready replicas and %d total replicas.", statefulSetName, sts.Status.ReadyReplicas, *sts.Spec.Replicas)
}
}
}
return fmt.Errorf("All replicas in StatefulSet %s are still ready within %v", statefulSetName, timeout)
}
// If match is true, check if zones in PV exactly match zones given. // If match is true, check if zones in PV exactly match zones given.
// Otherwise, check whether zones in PV is superset of zones given. // Otherwise, check whether zones in PV is superset of zones given.
func verifyZonesInPV(volume *v1.PersistentVolume, zones sets.String, match bool) error { func verifyZonesInPV(volume *v1.PersistentVolume, zones sets.String, match bool) error {
......
...@@ -641,14 +641,6 @@ func volumeFormatPod(f *framework.Framework, volumeSource *v1.VolumeSource) *v1. ...@@ -641,14 +641,6 @@ func volumeFormatPod(f *framework.Framework, volumeSource *v1.VolumeSource) *v1.
} }
} }
func clearSubpathPodCommands(pod *v1.Pod) {
pod.Spec.InitContainers[0].Command = nil
pod.Spec.InitContainers[1].Args = nil
pod.Spec.InitContainers[2].Args = nil
pod.Spec.Containers[0].Args = nil
pod.Spec.Containers[1].Args = nil
}
func setInitCommand(pod *v1.Pod, command string) { func setInitCommand(pod *v1.Pod, command string) {
pod.Spec.InitContainers[0].Command = []string{"/bin/sh", "-ec", command} pod.Spec.InitContainers[0].Command = []string{"/bin/sh", "-ec", command}
} }
......
...@@ -53,16 +53,6 @@ func isSharedPIDNamespaceSupported() (bool, error) { ...@@ -53,16 +53,6 @@ func isSharedPIDNamespaceSupported() (bool, error) {
return version.GTE(semver.MustParse("1.26.0")), nil return version.GTE(semver.MustParse("1.26.0")), nil
} }
// isDockerNoNewPrivilegesSupported returns true if Docker version is 1.11+
// (API version 1.23+), and false otherwise.
func isDockerNoNewPrivilegesSupported() (bool, error) {
version, err := getDockerAPIVersion()
if err != nil {
return false, err
}
return version.GTE(semver.MustParse("1.23.0")), nil
}
// isDockerLiveRestoreSupported returns true if live-restore is supported in // isDockerLiveRestoreSupported returns true if live-restore is supported in
// the current Docker version. // the current Docker version.
func isDockerLiveRestoreSupported() (bool, error) { func isDockerLiveRestoreSupported() (bool, error) {
......
...@@ -85,23 +85,6 @@ func (n *NodeE2ERemote) SetupTestPackage(tardir, systemSpecName string) error { ...@@ -85,23 +85,6 @@ func (n *NodeE2ERemote) SetupTestPackage(tardir, systemSpecName string) error {
return nil return nil
} }
// dest is relative to the root of the tar
func tarAddFile(tar, source, dest string) error {
dir := filepath.Dir(dest)
tardir := filepath.Join(tar, dir)
tardest := filepath.Join(tar, dest)
out, err := exec.Command("mkdir", "-p", tardir).CombinedOutput()
if err != nil {
return fmt.Errorf("failed to create archive bin subdir %q, was dest for file %q. Err: %v. Output:\n%s", tardir, source, err, out)
}
out, err = exec.Command("cp", source, tardest).CombinedOutput()
if err != nil {
return fmt.Errorf("failed to copy file %q to the archive bin subdir %q. Err: %v. Output:\n%s", source, tardir, err, out)
}
return nil
}
// prependCOSMounterFlag prepends the flag for setting the GCI mounter path to // prependCOSMounterFlag prepends the flag for setting the GCI mounter path to
// args and returns the result. // args and returns the result.
func prependCOSMounterFlag(args, host, workspace string) (string, error) { func prependCOSMounterFlag(args, host, workspace string) (string, error) {
......
...@@ -17,7 +17,7 @@ include ../../hack/make-rules/Makefile.manifest ...@@ -17,7 +17,7 @@ include ../../hack/make-rules/Makefile.manifest
REGISTRY ?= gcr.io/kubernetes-e2e-test-images REGISTRY ?= gcr.io/kubernetes-e2e-test-images
GOARM=7 GOARM=7
QEMUVERSION=v2.9.1 QEMUVERSION=v2.9.1
GOLANG_VERSION=1.12.1 GOLANG_VERSION=1.12.4
export export
ifndef WHAT ifndef WHAT
......
...@@ -33,11 +33,6 @@ import ( ...@@ -33,11 +33,6 @@ import (
type runnerMap map[string]common.Runner type runnerMap map[string]common.Runner
type runRequestJSON struct {
runner string
options interface{}
}
var ( var (
// flags for the command line. See usage args below for // flags for the command line. See usage args below for
// descriptions. // descriptions.
...@@ -157,6 +152,3 @@ func handleRunRequest(w http.ResponseWriter, r *http.Request) { ...@@ -157,6 +152,3 @@ func handleRunRequest(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "ok\noutput:\n\n"+output.b.String()) fmt.Fprintf(w, "ok\noutput:\n\n"+output.b.String())
} }
func setupLogger() {
}
...@@ -62,11 +62,6 @@ func (a *atomicBool) get() bool { ...@@ -62,11 +62,6 @@ func (a *atomicBool) get() bool {
return atomic.LoadInt32(&a.v) == 1 return atomic.LoadInt32(&a.v) == 1
} }
type output struct {
responses []string
errors []string
}
func init() { func init() {
flag.IntVar(&httpPort, "http-port", 8080, "HTTP Listen Port") flag.IntVar(&httpPort, "http-port", 8080, "HTTP Listen Port")
flag.IntVar(&udpPort, "udp-port", 8081, "UDP Listen Port") flag.IntVar(&udpPort, "udp-port", 8081, "UDP Listen Port")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment