mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	build: move some of hack/lib/ into a new cluster/lib/
Some functionality in hack/lib is currently depended on by
cluster/common.sh so kube-up from the full release tar (which
does not include hack/) is currently broken. With this PR we
create cluster/lib/ and move the necessary bits from hack/
over to get kube-up working again.
Fixes: 96d1b8d1b2
Signed-off-by: Mike Danese <mikedanese@google.com>
			
			
This commit is contained in:
		@@ -24,8 +24,8 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
DEFAULT_KUBECONFIG="${HOME}/.kube/config"
 | 
					DEFAULT_KUBECONFIG="${HOME}/.kube/config"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
source "${KUBE_ROOT}/hack/lib/util.sh"
 | 
					source "${KUBE_ROOT}/cluster/lib/util.sh"
 | 
				
			||||||
source "${KUBE_ROOT}/hack/lib/logging.sh"
 | 
					source "${KUBE_ROOT}/cluster/lib/logging.sh"
 | 
				
			||||||
# KUBE_RELEASE_VERSION_REGEX matches things like "v1.2.3" or "v1.2.3-alpha.4"
 | 
					# KUBE_RELEASE_VERSION_REGEX matches things like "v1.2.3" or "v1.2.3-alpha.4"
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# NOTE This must match the version_regex in build/common.sh
 | 
					# NOTE This must match the version_regex in build/common.sh
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,7 @@
 | 
				
			|||||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
 | 
					KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
 | 
				
			||||||
source "${KUBE_ROOT}/cluster/gce/${KUBE_CONFIG_FILE-"config-default.sh"}"
 | 
					source "${KUBE_ROOT}/cluster/gce/${KUBE_CONFIG_FILE-"config-default.sh"}"
 | 
				
			||||||
source "${KUBE_ROOT}/cluster/common.sh"
 | 
					source "${KUBE_ROOT}/cluster/common.sh"
 | 
				
			||||||
 | 
					source "${KUBE_ROOT}/cluster/lib/util.sh"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [[ "${OS_DISTRIBUTION}" == "debian" || "${OS_DISTRIBUTION}" == "coreos" || "${OS_DISTRIBUTION}" == "trusty" ]]; then
 | 
					if [[ "${OS_DISTRIBUTION}" == "debian" || "${OS_DISTRIBUTION}" == "coreos" || "${OS_DISTRIBUTION}" == "trusty" ]]; then
 | 
				
			||||||
  source "${KUBE_ROOT}/cluster/gce/${OS_DISTRIBUTION}/helper.sh"
 | 
					  source "${KUBE_ROOT}/cluster/gce/${OS_DISTRIBUTION}/helper.sh"
 | 
				
			||||||
@@ -301,21 +302,6 @@ function detect-master () {
 | 
				
			|||||||
  echo "Using master: $KUBE_MASTER (external IP: $KUBE_MASTER_IP)"
 | 
					  echo "Using master: $KUBE_MASTER (external IP: $KUBE_MASTER_IP)"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Wait for background jobs to finish. Exit with
 | 
					 | 
				
			||||||
# an error status if any of the jobs failed.
 | 
					 | 
				
			||||||
function wait-for-jobs {
 | 
					 | 
				
			||||||
  local fail=0
 | 
					 | 
				
			||||||
  local job
 | 
					 | 
				
			||||||
  for job in $(jobs -p); do
 | 
					 | 
				
			||||||
    wait "${job}" || fail=$((fail + 1))
 | 
					 | 
				
			||||||
  done
 | 
					 | 
				
			||||||
  if (( fail != 0 )); then
 | 
					 | 
				
			||||||
    echo -e "${color_red}${fail} commands failed.  Exiting.${color_norm}" >&2
 | 
					 | 
				
			||||||
    # Ignore failures for now.
 | 
					 | 
				
			||||||
    # exit 2
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Robustly try to create a static ip.
 | 
					# Robustly try to create a static ip.
 | 
				
			||||||
# $1: The name of the ip to create
 | 
					# $1: The name of the ip to create
 | 
				
			||||||
# $2: The name of the region to create the ip in.
 | 
					# $2: The name of the region to create the ip in.
 | 
				
			||||||
@@ -687,7 +673,9 @@ function kube-up {
 | 
				
			|||||||
  fi
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # Wait for last batch of jobs
 | 
					  # Wait for last batch of jobs
 | 
				
			||||||
  wait-for-jobs
 | 
					  kube::util::wait-for-jobs || {
 | 
				
			||||||
 | 
					    echo -e "${color_red}${fail} commands failed.${color_norm}" >&2
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  echo "Creating minions."
 | 
					  echo "Creating minions."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1192,7 +1180,10 @@ function kube-push {
 | 
				
			|||||||
  for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
 | 
					  for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
 | 
				
			||||||
    push-node "${NODE_NAMES[$i]}" &
 | 
					    push-node "${NODE_NAMES[$i]}" &
 | 
				
			||||||
  done
 | 
					  done
 | 
				
			||||||
  wait-for-jobs
 | 
					
 | 
				
			||||||
 | 
					  kube::util::wait-for-jobs || {
 | 
				
			||||||
 | 
					    echo -e "${color_red}${fail} commands failed.${color_norm}" >&2
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # TODO(zmerlynn): Re-create instance-template with the new
 | 
					  # TODO(zmerlynn): Re-create instance-template with the new
 | 
				
			||||||
  # node-kube-env. This isn't important until the node-ip-range issue
 | 
					  # node-kube-env. This isn't important until the node-ip-range issue
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										27
									
								
								cluster/lib/util.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								cluster/lib/util.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Copyright 2015 The Kubernetes Authors All rights reserved.
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# 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.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Wait for background jobs to finish. Return with
 | 
				
			||||||
 | 
					# an error status if any of the jobs failed.
 | 
				
			||||||
 | 
					kube::util::wait-for-jobs() {
 | 
				
			||||||
 | 
					  local fail=0
 | 
				
			||||||
 | 
					  local job
 | 
				
			||||||
 | 
					  for job in $(jobs -p); do
 | 
				
			||||||
 | 
					    wait "${job}" || fail=$((fail + 1))
 | 
				
			||||||
 | 
					  done
 | 
				
			||||||
 | 
					  return ${fail}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -31,7 +31,8 @@ KUBE_OUTPUT="${KUBE_ROOT}/${KUBE_OUTPUT_SUBPATH}"
 | 
				
			|||||||
KUBE_OUTPUT_BINPATH="${KUBE_OUTPUT}/bin"
 | 
					KUBE_OUTPUT_BINPATH="${KUBE_OUTPUT}/bin"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
source "${KUBE_ROOT}/hack/lib/util.sh"
 | 
					source "${KUBE_ROOT}/hack/lib/util.sh"
 | 
				
			||||||
source "${KUBE_ROOT}/hack/lib/logging.sh"
 | 
					source "${KUBE_ROOT}/cluster/lib/util.sh"
 | 
				
			||||||
 | 
					source "${KUBE_ROOT}/cluster/lib/logging.sh"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
kube::log::install_errexit
 | 
					kube::log::install_errexit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -176,17 +176,6 @@ kube::util::find-binary() {
 | 
				
			|||||||
  echo -n "${bin}"
 | 
					  echo -n "${bin}"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Wait for background jobs to finish. Return with
 | 
					 | 
				
			||||||
# an error status if any of the jobs failed.
 | 
					 | 
				
			||||||
kube::util::wait-for-jobs() {
 | 
					 | 
				
			||||||
  local fail=0
 | 
					 | 
				
			||||||
  local job
 | 
					 | 
				
			||||||
  for job in $(jobs -p); do
 | 
					 | 
				
			||||||
    wait "${job}" || fail=$((fail + 1))
 | 
					 | 
				
			||||||
  done
 | 
					 | 
				
			||||||
  return ${fail}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Run all known doc generators (today gendocs, genman, and genbashcomp for kubectl)
 | 
					# Run all known doc generators (today gendocs, genman, and genbashcomp for kubectl)
 | 
				
			||||||
# $1 is the directory to put those generated documents
 | 
					# $1 is the directory to put those generated documents
 | 
				
			||||||
kube::util::gen-docs() {
 | 
					kube::util::gen-docs() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -84,8 +84,8 @@ hack/jenkins/update-jobs.sh:    docker cp jenkins_jobs.ini job-builder:/etc/jenk
 | 
				
			|||||||
hack/jenkins/update-jobs.sh:    echo "jenkins_jobs.ini not found in workspace" >&2
 | 
					hack/jenkins/update-jobs.sh:    echo "jenkins_jobs.ini not found in workspace" >&2
 | 
				
			||||||
hack/jenkins/update-jobs.sh:  # jenkins_jobs.ini contains administrative credentials for Jenkins.
 | 
					hack/jenkins/update-jobs.sh:  # jenkins_jobs.ini contains administrative credentials for Jenkins.
 | 
				
			||||||
hack/jenkins/update-jobs.sh:  if [[ -e jenkins_jobs.ini ]]; then
 | 
					hack/jenkins/update-jobs.sh:  if [[ -e jenkins_jobs.ini ]]; then
 | 
				
			||||||
hack/lib/logging.sh:      local source_file=${BASH_SOURCE[$frame_no]}
 | 
					cluster/lib/logging.sh:      local source_file=${BASH_SOURCE[$frame_no]}
 | 
				
			||||||
hack/lib/logging.sh:  local source_file=${BASH_SOURCE[$stack_skip]}
 | 
					cluster/lib/logging.sh:  local source_file=${BASH_SOURCE[$stack_skip]}
 | 
				
			||||||
hack/local-up-cluster.sh:      runtime_config="--runtime-config=${RUNTIME_CONFIG}"
 | 
					hack/local-up-cluster.sh:      runtime_config="--runtime-config=${RUNTIME_CONFIG}"
 | 
				
			||||||
hack/local-up-cluster.sh:    runtime_config=""
 | 
					hack/local-up-cluster.sh:    runtime_config=""
 | 
				
			||||||
hack/test-cmd.sh:  --runtime_config="extensions/v1beta1/deployments=true" \
 | 
					hack/test-cmd.sh:  --runtime_config="extensions/v1beta1/deployments=true" \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,7 +20,7 @@ set -o pipefail
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
pushd "../../../.."
 | 
					pushd "../../../.."
 | 
				
			||||||
source "./hack/lib/util.sh"
 | 
					source "./hack/lib/util.sh"
 | 
				
			||||||
source "./hack/lib/logging.sh"
 | 
					source "./cluster/lib/logging.sh"
 | 
				
			||||||
source "./hack/lib/etcd.sh"
 | 
					source "./hack/lib/etcd.sh"
 | 
				
			||||||
popd
 | 
					popd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user