-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support debug and ctop commands in CLI (#387)
* Abandon vendor and refresh go.sum Signed-off-by: Aylei <[email protected]> * Format .gitignore Signed-off-by: Aylei <[email protected]> * CLI skeleton, update kuberetes dependecies to 1.12.5 Signed-off-by: Aylei <[email protected]> * Add use command for tkc Signed-off-by: Aylei <[email protected]> * Support info command, support list command Signed-off-by: Aylei <[email protected]> * Remoave un-intentionally added files Signed-off-by: Aylei <[email protected]> * Support get command in tkc Signed-off-by: Aylei <[email protected]> * Lint formats Signed-off-by: Aylei <[email protected]> * Support debug and ctop commands in CLI Signed-off-by: Aylei <[email protected]> * Bump golang to 1.12 in tidb-debug image Signed-off-by: Aylei <[email protected]> * Change checksum accordingly Signed-off-by: Aylei <[email protected]>
- Loading branch information
Showing
28 changed files
with
1,499 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
def call(BUILD_BRANCH, RELEASE_TAG) { | ||
|
||
env.GOPATH = "/go" | ||
env.GOROOT = "/usr/local/go" | ||
env.PATH = "${env.GOROOT}/bin:${env.GOPATH}/bin:/bin:${env.PATH}:/home/jenkins/bin" | ||
|
||
def GITHASH | ||
def TKC_CLI_PACKAGE = "tkc-${GOOS}-${GOARCH}-${RELEASE_TAG}" | ||
|
||
catchError { | ||
node('k8s_centos7_build') { | ||
def WORKSPACE = pwd() | ||
|
||
dir("${WORKSPACE}/operator"){ | ||
stage('Build and release CLI to qiniu'){ | ||
checkout([$class: 'GitSCM', branches: [[name: "${BUILD_BRANCH}"]], userRemoteConfigs:[[url: "${BUILD_URL}", credentialsId: "${CREDENTIALS_ID}"]]]) | ||
GITHASH = sh(returnStdout: true, script: "git rev-parse HEAD").trim() | ||
def GOARCH = "amd64" | ||
["linux", "darwin", "windows"].each { | ||
sh """ | ||
GOOS=${it} GOARCH=${GOARCH} make cli | ||
tar -zcf ${TKC_CLI_PACKAGE}.tgz tkc | ||
sha256sum ${TKC_CLI_PACKAGE}.tgz > ${TKC_CLI_PACKAGE}.sha256 | ||
upload.py ${TKC_CLI_PACKAGE}.tgz ${TKC_CLI_PACKAGE}.tgz | ||
upload.py ${TKC_CLI_PACKAGE}.sha256 ${TKC_CLI_PACKAGE}.sha256 | ||
""" | ||
} | ||
} | ||
|
||
stage('Build and push debug images'){ | ||
withDockerServer([uri: "${env.DOCKER_HOST}"]) { | ||
DOCKER_REGISTRY="" make debug-docker-push | ||
DOCKER_REGISTRY="uhub.service.ucloud.cn" make debug-docker-push | ||
} | ||
} | ||
} | ||
} | ||
currentBuild.result = "SUCCESS" | ||
} | ||
stage('Summary') { | ||
echo("echo summary info ########") | ||
def DURATION = ((System.currentTimeMillis() - currentBuild.startTimeInMillis) / 1000 / 60).setScale(2, BigDecimal.ROUND_HALF_UP) | ||
def slackmsg = "[${env.JOB_NAME.replaceAll('%2F','/')}-${env.BUILD_NUMBER}] `${currentBuild.result}`" + "\n" + | ||
"Elapsed Time: `${DURATION}` Mins" + "\n" + | ||
"tidb-operator Branch: `${BUILD_BRANCH}`, Githash: `${GITHASH.take(7)}`" + "\n" + | ||
"Display URL:" + "\n" + | ||
"${env.RUN_DISPLAY_URL}" | ||
|
||
if(currentBuild.result != "SUCCESS"){ | ||
slackSend channel: '#cloud_jenkins', color: 'danger', teamDomain: 'pingcap', tokenCredentialId: 'slack-pingcap-token', message: "${slackmsg}" | ||
} else { | ||
slackmsg = "${slackmsg}" + "\n" + | ||
"tkc cli tool build and debug image build failed for BRANCH:${BUILD_BRANCH} and TAG:${RELEASE_TAG}`" | ||
slackSend channel: '#cloud_jenkins', color: 'good', teamDomain: 'pingcap', tokenCredentialId: 'slack-pingcap-token', message: "${slackmsg}" | ||
} | ||
} | ||
} | ||
|
||
return this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2019. 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. | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/pingcap/tidb-operator/pkg/tkctl/debug" | ||
"log" | ||
"os" | ||
) | ||
|
||
func main() { | ||
|
||
iostreams := debug.IOStreams{ | ||
In: os.Stdin, | ||
Out: os.Stdout, | ||
ErrOut: os.Stderr, | ||
} | ||
cmd := debug.NewLauncherCmd(iostreams) | ||
if err := cmd.Execute(); err != nil { | ||
log.Fatal(err) | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM bash | ||
ENV TERM=linux | ||
|
||
ADD bin/debug-launcher /debug-launcher | ||
ADD entry-point.sh /entry-point.sh | ||
ENTRYPOINT ["/entry-point.sh"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
# launch container under bash to get proper tty | ||
/debug-launcher $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM bash:4.3.48 | ||
RUN wget -q http://download.pingcap.org/tidb-latest-linux-amd64.tar.gz \ | ||
&& tar xzf tidb-latest-linux-amd64.tar.gz \ | ||
&& mv tidb-latest-linux-amd64/bin/pd-ctl \ | ||
tidb-latest-linux-amd64/bin/tidb-ctl \ | ||
/usr/local/bin/ \ | ||
&& rm -rf tidb-latest-linux-amd64.tar.gz tidb-latest-linux-amd64 | ||
|
||
ADD banner /etc/banner | ||
ADD profile /etc/profile | ||
|
||
CMD ["/usr/local/bin/bash", "-l"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Tidb Cluster Control Image | ||
|
||
`tidb-control` is a docker image containing the main control tools for tidb cluster: `pd-ctl` and `tidb-ctl`. | ||
|
||
# Usage | ||
|
||
```shell | ||
$ docker run -it --rm pingcap/tidb-control:latest | ||
|
||
# enter docker shell | ||
→ / tidb-ctl | ||
Usage: | ||
tidb-ctl [flags] | ||
tidb-ctl [command] | ||
|
||
Available Commands: | ||
base64decode decode base64 value | ||
decoder decode key | ||
etcd control the info about etcd by grpc_gateway | ||
help Help about any command | ||
mvcc MVCC Information | ||
region Region information | ||
schema Schema Information | ||
table Table information | ||
|
||
Flags: | ||
-h, --help help for tidb-ctl | ||
--host ip TiDB server host (default 127.0.0.1) | ||
--pdhost ip PD server host (default 127.0.0.1) | ||
--pdport uint16 PD server port (default 2379) | ||
--port uint16 TiDB server port (default 10080) | ||
|
||
Use "tidb-ctl [command] --help" for more information about a command. | ||
→ / pd-ctl --help | ||
Usage of pd-ctl: | ||
--cacert string path of file that contains list of trusted SSL CAs. | ||
--cert string path of file that contains X509 certificate in PEM format. | ||
-d, --detach Run pdctl without readline | ||
--key string path of file that contains X509 key in PEM format. | ||
-u, --pd string The pd address (default "http://127.0.0.1:2379") | ||
-V, --version print version information and exit | ||
pflag: help requested | ||
|
||
# mount CA certificate files if necessary | ||
$ docker run -v $(pwd)/ca.pem:$(pwd)/ca.pem -v $(pwd)/client.pem:$(pwd)/client.pem -it --rm pingcap/tidb-control:latest | ||
``` | ||
|
||
PS: `library/bash` is a `busybox` based image, so some dynamic linked binaries like `tikv-ctl` cannot work in this minimal image. If you are looking for `tikv-ctl` or more tools, take a look at [tidb-debug](../tidb-debug/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
████████╗██╗██████╗ ██████╗ ██████╗████████╗██╗ | ||
╚══██╔══╝╚═╝██╔══██╗██╔══██╗ ██╔════╝╚══██╔══╝██║ | ||
██║ ██╗██║ ██║██████╔╝ ██║ ██║ ██║ | ||
██║ ██║██║ ██║██╔══██╗ ██║ ██║ ██║ | ||
██║ ██║██████╔╝██████╔╝ ╚██████╗ ██║ ███████╗ | ||
╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝ | ||
|
||
Welcome to tidb cluster control! (https://github.com/pingcap/tidb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cat /etc/banner | ||
|
||
export CLICOLOR=1 | ||
export LSCOLORS=GxFxCxDxBxegedabagaced | ||
export LS_OPTIONS='--color=auto' | ||
|
||
# aliases | ||
alias ls='ls $LS_OPTIONS' | ||
|
||
function prompt { | ||
local GREENBOLD="\[\033[1;32m\]" | ||
local RESETCOLOR="\[\e[00m\]" | ||
|
||
export PS1="$GREENBOLD→ \w $RESETCOLOR" | ||
export PS2=" | → $RESETCOLOR " | ||
} | ||
|
||
prompt |
Oops, something went wrong.