VMware vSphere Integrated Containers provider (#206)
* Add Virtual Kubelet provider for VIC Initial virtual kubelet provider for VMware VIC. This provider currently handles creating and starting of a pod VM via the VIC portlayer and persona server. Image store handling via the VIC persona server. This provider currently requires the feature/wolfpack branch of VIC. * Added pod stop and delete. Also added node capacity. Added the ability to stop and delete pod VMs via VIC. Also retrieve node capacity information from the VCH. * Cleanup and readme file Some file clean up and added a Readme.md markdown file for the VIC provider. * Cleaned up errors, added function comments, moved operation code 1. Cleaned up error handling. Set standard for creating errors. 2. Added method prototype comments for all interface functions. 3. Moved PodCreator, PodStarter, PodStopper, and PodDeleter to a new folder. * Add mocking code and unit tests for podcache, podcreator, and podstarter Used the unit test framework used in VIC to handle assertions in the provider's unit test. Mocking code generated using OSS project mockery, which is compatible with the testify assertion framework. * Vendored packages for the VIC provider Requires feature/wolfpack branch of VIC and a few specific commit sha of projects used within VIC. * Implementation of POD Stopper and Deleter unit tests (#4) * Updated files for initial PR
This commit is contained in:
90
vendor/github.com/vmware/vic/infra/dlv/README.md
generated
vendored
Normal file
90
vendor/github.com/vmware/vic/infra/dlv/README.md
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
# DLV Debugging of VCH servers
|
||||
|
||||
## Overview
|
||||
|
||||
This notes describes how to set up dlv remote debugging of VCH servers
|
||||
|
||||
## Building debug enabled binaries (non stripped)
|
||||
|
||||
Set the following environment variable
|
||||
``` shell
|
||||
export VIC_DEBUG_BUILD=true
|
||||
```
|
||||
this tells the makefile to build non stripped binaries
|
||||
|
||||
## Preparing the VCH for debugging
|
||||
|
||||
Ssh must be enabled on the VCH. To enabled it run the following command:
|
||||
``` shell
|
||||
vic-machine-linux debug --target <TARGET> --thumbprint <THUMBPRINT> --name <vch-name> --enable-ssh --key <PATH-TO-AUTHORIZED-KEYS-FILE>
|
||||
```
|
||||
|
||||
Both scripts: **dlv-setup.sh** and **dlv-ctl.sh** rely on ssh public-key authentication as specified by the command above (authorized_keys file).
|
||||
|
||||
The script **dlv-setup.sh**
|
||||
must be used to set up the VCH to run dlv. It performs several tasks:
|
||||
* opens the necessary ports in the iptables,
|
||||
* copies the GO environment necessary to run dlv (from $GOROOT and $GOPATH),
|
||||
* creates the attach and detach scripts that reside in /usr/local/bin in the VCH
|
||||
|
||||
|
||||
The command requires the address (or FQDN) of the VCH. The environment variables:
|
||||
``` shell
|
||||
DLV_TARGET_HOST
|
||||
```
|
||||
can be used to pass that information to **dlv-setup.sh**. Alternatively the option __-h__ can be used on the command line.
|
||||
For instance:
|
||||
``` shell
|
||||
dlv-setup.sh -h <target IP address/FQDN>
|
||||
```
|
||||
|
||||
## Launching dlv on the target host
|
||||
|
||||
To launch dlv and attach it to one of the VCH server run the command **dlv-ctl.sh**. The following target servers are supported:
|
||||
* vic-init
|
||||
* vic-admin
|
||||
* port-layer
|
||||
* docker-engine
|
||||
* vic-machine
|
||||
|
||||
The scripts needs the IP address (or the FQDN) of the target VCH host. The same environment variable
|
||||
and command line options as **dlv-setup.sh** are accepted. The script takes two arguments:
|
||||
* action: this can be either attach or detach
|
||||
* target: this can be one of the VCH services listed above
|
||||
For example:
|
||||
``` shell
|
||||
dlv-ctl.sh -h <target IP address/FQDN> attach vic-admin
|
||||
```
|
||||
launches dlv in headless mode and attaches it to vic-admin and prints out the port number on which dlv listens.
|
||||
To detach you can use:
|
||||
``` shell
|
||||
dlv-ctl.sh -h <target IP address/FQDN> detach vic-admin
|
||||
```
|
||||
The script allows specifying the action through with a couple of additional options __-a__ (for attach) and __-d__ for detach.
|
||||
For example:
|
||||
``` shell
|
||||
dlv-ctl.sh -h <target IP address/FQDN> -a vic-admin
|
||||
```
|
||||
Performs an attach. While
|
||||
``` shell
|
||||
dlv-ctl.sh -h <target IP address/FQDN> -d vic-admin
|
||||
```
|
||||
performs a detach
|
||||
|
||||
## Using Goland to perform remote debugging
|
||||
After dlv is attached to the appropriate server, you can configure Goland to start debugging that process.
|
||||
On the drop down list with the debugger configurations select: __Edit Configurations__. In the configuration tab
|
||||
click on the __+__ button to add a new configuration. Select __Go Remote__. Type in the the VCH IP address (or FQDN) and
|
||||
the port number returned by the **dlv-ctl** attach command. The debugger should be able to connect to the server.
|
||||
|
||||
## Timeout issues while debugging
|
||||
Consider for example the case in which a request is sent to the **port-layer** from **docker-engine**. When the request
|
||||
is received by the **port-layer** a breakpoint is hit. The developer next steps through the code in the **port-layer**
|
||||
while the **docker-engine** is waiting for a response. This may cause the **docker-engine** to timeout and abort
|
||||
or retry the request. Ideally when debugging is enabled all the timeouts should be increased to allow slower
|
||||
response times. This has not yet been implemented. The current idea is to connect the extension of timeout duration
|
||||
with the debug level specified at the time of VCH creation.
|
||||
|
||||
## Debugging vic-machine
|
||||
The target __vic-machine__ has been added to debug the vic-machine remotely, in this case everything above applies with
|
||||
the exception that the __vic-machine__ does not usually run on a VCH host.
|
||||
117
vendor/github.com/vmware/vic/infra/dlv/dlv-ctl.sh
generated
vendored
Executable file
117
vendor/github.com/vmware/vic/infra/dlv/dlv-ctl.sh
generated
vendored
Executable file
@@ -0,0 +1,117 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2016-2018 VMware, Inc. 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.!/bin/bash
|
||||
|
||||
SSH="ssh -o StrictHostKeyChecking=no"
|
||||
SCP="scp -o StrictHostKeyChecking=no"
|
||||
|
||||
REMOTE_DLV_ATTACH=/usr/local/bin/dlv-attach-headless.sh
|
||||
REMOTE_DLV_DETACH=/usr/local/bin/dlv-detach-headless.sh
|
||||
|
||||
function usage() {
|
||||
echo "Usage: $0 -h vch-address [-a/-d] [attach/detach] target" >&2
|
||||
echo "Valid targets are: "
|
||||
echo " vic-init"
|
||||
echo " vic-admin"
|
||||
echo " docker-engine"
|
||||
echo " port-layer"
|
||||
echo " vic-machine"
|
||||
echo " virtual-kubelet"
|
||||
exit 1
|
||||
}
|
||||
|
||||
while getopts "h:ad" flag
|
||||
do
|
||||
case $flag in
|
||||
|
||||
h)
|
||||
# Optional
|
||||
export DLV_TARGET_HOST="$OPTARG"
|
||||
;;
|
||||
|
||||
a)
|
||||
export COMMAND="attach"
|
||||
;;
|
||||
|
||||
d)
|
||||
export COMMAND="detach"
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
|
||||
if [[ -z "${COMMAND}" && $# != 2 ]]; then
|
||||
usage
|
||||
elif [[ -n "${COMMAND}" && $# != 1 ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ -z "${COMMAND}" ]; then
|
||||
COMMAND=$1
|
||||
TARGET=$2
|
||||
else
|
||||
TARGET=$1
|
||||
fi
|
||||
|
||||
case ${TARGET} in
|
||||
|
||||
vic-init)
|
||||
PORT=2345
|
||||
;;
|
||||
|
||||
vic-admin)
|
||||
# Change target to vicadmin
|
||||
TARGET=vicadmin
|
||||
PORT=2346
|
||||
;;
|
||||
|
||||
docker-engine)
|
||||
PORT=2347
|
||||
;;
|
||||
|
||||
port-layer)
|
||||
PORT=2348
|
||||
;;
|
||||
|
||||
vic-machine)
|
||||
PORT=2349
|
||||
;;
|
||||
|
||||
virtual-kubelet)
|
||||
PORT=2350
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "${DLV_TARGET_HOST}" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ ${COMMAND} == "attach" ]; then
|
||||
${SSH} root@${DLV_TARGET_HOST} "nohup /usr/local/bin/dlv-attach-headless.sh $TARGET $PORT > /var/tmp/${TARGET}.log 2>&1 &"
|
||||
elif [ ${COMMAND} == "detach" ]; then
|
||||
${SSH} root@${DLV_TARGET_HOST} "/usr/local/bin/dlv-detach-headless.sh $PORT"
|
||||
else
|
||||
usage
|
||||
fi
|
||||
|
||||
echo $DLV_TARGET_HOST:$PORT
|
||||
136
vendor/github.com/vmware/vic/infra/dlv/dlv-setup.sh
generated
vendored
Executable file
136
vendor/github.com/vmware/vic/infra/dlv/dlv-setup.sh
generated
vendored
Executable file
@@ -0,0 +1,136 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2016-2018 VMware, Inc. 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.!/bin/bash
|
||||
|
||||
SSH="ssh -o StrictHostKeyChecking=no"
|
||||
SCP="scp -q -o StrictHostKeyChecking=no"
|
||||
|
||||
function usage() {
|
||||
echo "Usage: $0 -h vch-address" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
while getopts "h" flag
|
||||
do
|
||||
case $flag in
|
||||
|
||||
h)
|
||||
# Optional
|
||||
export DLV_TARGET_HOST="$OPTARG"
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
|
||||
if [ -z "${DLV_TARGET_HOST}" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
DLV_BIN="$GOPATH/bin/dlv"
|
||||
|
||||
if [ -z "${GOPATH}" -o -z "${GOROOT}" ]; then
|
||||
echo GOROOT and GOPATH should be set to point to the current GOLANG enironment
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# copy dlv binary
|
||||
echo -n copying dlv binary..
|
||||
if [ -f ${DLV_BIN} ]; then
|
||||
${SCP} ${DLV_BIN} root@${DLV_TARGET_HOST}:/usr/local/bin
|
||||
else
|
||||
echo $DLV_BIN does not exist. Run \"go get github.com/derekparker/delve/cmd/dlv\"
|
||||
exit 1
|
||||
fi
|
||||
echo done
|
||||
|
||||
# copy GOROOT env
|
||||
echo -n copying GOROOT environment..
|
||||
${SSH} root@${DLV_TARGET_HOST} "mkdir -p /usr/local/go"
|
||||
${SCP} -r ${GOROOT}/bin root@${DLV_TARGET_HOST}:/usr/local/go
|
||||
${SCP} -r ${GOROOT}/api root@${DLV_TARGET_HOST}:/usr/local/go
|
||||
${SCP} ${GOROOT}/VERSION root@${DLV_TARGET_HOST}:/usr/local/go
|
||||
${SSH} root@${DLV_TARGET_HOST} "ln -f -s /usr/local/go/bin/go /usr/local/bin/go"
|
||||
echo done
|
||||
|
||||
# open IPTABLES
|
||||
echo -n fixing ipatables..
|
||||
${SSH} root@${DLV_TARGET_HOST} "iptables -I INPUT -p tcp -m tcp --dport 2345:2350 -j ACCEPT"
|
||||
echo done
|
||||
echo "Iptables changed: run \"iptables -D INPUT 1\" when finished debugging"
|
||||
|
||||
# write remote dlv attach script
|
||||
TEMPFILE=$(mktemp)
|
||||
cat > ${TEMPFILE} <<EOF
|
||||
#/bin/bash
|
||||
if [ \$# != 2 ]; then
|
||||
echo "\$0 vic-init|vicadmin|docker-engine|port-layer|vic-machine|virtual-kubelet port"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NAME=\$1
|
||||
PORT=\$2
|
||||
|
||||
if [ -z "\${NAME}" -o -z "\${PORT}" ]; then
|
||||
echo "\$0 vic-init|vicadmin|docker-engine|port-layer|vic-machine|virtual-kubelet port"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PID=\$(ps -e | grep \${NAME} | grep -v grep | tr -s ' ' | cut -d " " -f 2)
|
||||
|
||||
if [ -z "\${PID}" ]; then
|
||||
echo "\$0: cannot find process \${NAME}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dlv attach \${PID} --api-version 2 --headless --listen=:\${PORT}
|
||||
EOF
|
||||
|
||||
${SCP} ${TEMPFILE} root@${DLV_TARGET_HOST}:/usr/local/bin/dlv-attach-headless.sh
|
||||
|
||||
# write dlv detach script
|
||||
cat > ${TEMPFILE} <<EOF
|
||||
#/bin/bash
|
||||
if [ \$# != 1 ]; then
|
||||
echo "\$0 port-number"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PORT=\$1
|
||||
|
||||
if [ -z "\${PORT}" ]; then
|
||||
echo "\$0 port-number"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find appropriate dlv instance
|
||||
PID=\$(ps -ef | grep "dlv" | grep "api-version" | grep \${PORT} | grep -v grep | tr -s ' ' | cut -d " " -f 2)
|
||||
|
||||
if [ -z "\${PID}" ]; then
|
||||
echo "\$0: cannot find dlv listening on \${PORT}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
kill \${PID}
|
||||
EOF
|
||||
|
||||
${SCP} ${TEMPFILE} root@${DLV_TARGET_HOST}:/usr/local/bin/dlv-detach-headless.sh
|
||||
|
||||
${SSH} root@${DLV_TARGET_HOST} 'chmod +x /usr/local/bin/*'
|
||||
|
||||
rm ${TEMPFILE}
|
||||
Reference in New Issue
Block a user