Skip to content

Commit

Permalink
remove dependencies on k8s-node (#2036)
Browse files Browse the repository at this point in the history
* remove dependencies on k8s-node

* fix
  • Loading branch information
cofyc authored Mar 26, 2020
1 parent 61be897 commit 567a603
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 19 deletions.
38 changes: 19 additions & 19 deletions ci/pingcap_tidb_operator_build_kind.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -252,26 +252,26 @@ def call(BUILD_BRANCH, CREDENTIALS_ID, CODECOV_CREDENTIALS_ID) {
builds.failFast = false
parallel builds

// we requires ~/bin/config.cfg, filemgr-linux64 utilities on k8s-kind node
// TODO make it possible to run on any node
if ( !(BUILD_BRANCH ==~ /[a-z0-9]{40}/) ) {
node('k8s-kind') {
dir("${PROJECT_DIR}") {
deleteDir()
unstash 'tidb-operator'
stage('upload tidb-operator, tidb-backup-manager binary and charts'){
//upload binary and charts
sh """
cp ~/bin/config.cfg ./
tar -zcvf tidb-operator.tar.gz images/tidb-operator images/tidb-backup-manager charts
filemgr-linux64 --action mput --bucket pingcap-dev --nobar --key builds/pingcap/operator/${GITHASH}/centos7/tidb-operator.tar.gz --file tidb-operator.tar.gz
"""
//update refs
writeFile file: 'sha1', text: "${GITHASH}"
sh """
filemgr-linux64 --action mput --bucket pingcap-dev --nobar --key refs/pingcap/operator/${BUILD_BRANCH}/centos7/sha1 --file sha1
rm -f sha1 tidb-operator.tar.gz config.cfg
"""
node('build_go1130_memvolume') {
container("golang") {
def WORKSPACE = pwd()
dir("${PROJECT_DIR}") {
unstash 'tidb-operator'
stage('upload tidb-operator binaries and charts'){
withCredentials([
string(credentialsId: 'UCLOUD_PUBLIC_KEY', variable: 'UCLOUD_PUBLIC_KEY'),
string(credentialsId: 'UCLOUD_PRIVATE_KEY', variable: 'UCLOUD_PRIVATE_KEY'),
]) {
sh """
export UCLOUD_UFILE_PROXY_HOST=mainland-hk.ufileos.com
export UCLOUD_UFILE_BUCKET=pingcap-dev
export BUILD_BRANCH=${BUILD_BRANCH}
export GITHASH=${GITHASH}
./ci/upload-binaries-charts.sh
"""
}
}
}
}
}
Expand Down
78 changes: 78 additions & 0 deletions ci/upload-binaries-charts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env bash

# Copyright 2020 PingCAP, Inc.
#
# 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,
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

ROOT=$(unset CDPATH && cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd)
cd $ROOT

source "${ROOT}/hack/lib.sh"

UCLOUD_PUBLIC_KEY=${UCLOUD_PUBLIC_KEY:-}
UCLOUD_PRIVATE_KEY=${UCLOUD_PRIVATE_KEY:-}
UCLOUD_UFILE_PROXY_HOST=${UCLOUD_UFILE_PROXY_HOST:-}
UCLOUD_UFILE_API_HOST=${UCLOUD_UFILE_API_HOST:-api.spark.ucloud.cn}
UCLOUD_UFILE_BUCKET=${UCLOUD_UFILE_BUCKET:-}
GITHASH=${GITHASH:-}
BUILD_BRANCH=${BUILD_BRANCH:-}

FILEMGR_URL="http://tools.ufile.ucloud.com.cn/filemgr-linux64.tar.gz"

if [ -z "$UCLOUD_PUBLIC_KEY" -o -z "$UCLOUD_PRIVATE_KEY" -o -z "$UCLOUD_UFILE_PROXY_HOST" ]; then
echo "error: UCLOUD_PUBLIC_KEY/UCLOUD_PUBLIC_KEY/UCLOUD_UFILE_PROXY_HOST are required"
exit 1
fi

if [ -z "$UCLOUD_UFILE_BUCKET" ]; then
echo "error: UCLOUD_UFILE_BUCKET is required"
exit 1
fi

if [ -z "$GITHASH" -o -z "$BUILD_BRANCH" ]; then
echo "error: GITHASH/BUILD_BRANCH are required"
exit 1
fi

function upload() {
local dir=$(mktemp -d)
trap "test -d $dir && rm -rf $dir" RETURN

echo "info: create a temporary directory: $dir"

cat <<EOF > $dir/config.cfg
{
"public_key" : "${UCLOUD_PUBLIC_KEY}",
"private_key" : "${UCLOUD_PRIVATE_KEY}",
"proxy_host" : "${UCLOUD_UFILE_PROXY_HOST}",
"api_host" : "${UCLOUD_UFILE_API_HOST}"
}
EOF

echo "info: downloading filemgr from $FILEMGR_URL"
curl --retry 10 -L -s "$FILEMGR_URL" | tar --strip-components 2 -C $dir -xzvf - ./linux64/filemgr-linux64

echo "info: uploading charts and binaries"
tar -zcvf $dir/tidb-operator.tar.gz images/tidb-operator images/tidb-backup-manager charts
$dir/filemgr-linux64 --config $dir/config.cfg --action mput --bucket ${UCLOUD_UFILE_BUCKET} --nobar --key builds/pingcap/operator/${GITHASH}/centos7/tidb-operator.tar.gz --file $dir/tidb-operator.tar.gz

echo "info: update ref of branch '$BUILD_BRANCH'"
echo -n $GITHASH > $dir/sha1
$dir/filemgr-linux64 --config $dir/config.cfg --action mput --bucket ${UCLOUD_UFILE_BUCKET} --nobar --key refs/pingcap/operator/${BUILD_BRANCH}/centos7/sha1 --file $dir/sha1
}

# retry a few times until it succeeds, this can avoid temporary network flakes
hack::wait_for_success 120 5 "upload"

0 comments on commit 567a603

Please sign in to comment.