Skip to content

Commit

Permalink
add option to run local operators
Browse files Browse the repository at this point in the history
Instead of using 'make deploy' for Baremetal Operator and CAPI
provider baremetal, add an option to use 'make run' and log the
output.
  • Loading branch information
maelk committed Aug 13, 2019
1 parent f508187 commit 569475a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 8 deletions.
24 changes: 22 additions & 2 deletions 03_launch_mgmt_cluster.sh
Expand Up @@ -7,6 +7,7 @@ source lib/logging.sh
source lib/common.sh

eval "$(go env)"
export GOPATH

M3PATH="${GOPATH}/src/github.com/metal3-io"
BMOPATH="${M3PATH}/baremetal-operator"
Expand All @@ -18,6 +19,9 @@ CAPBMREPO="${CAPBMREPO:-https://github.com/metal3-io/cluster-api-provider-bareme
CAPBMBRANCH="${CAPBMBRANCH:-master}"
FORCE_REPO_UPDATE="${FORCE_REPO_UPDATE:-false}"

BMO_RUN_LOCAL="${BMO_RUN_LOCAL:-false}"
CAPBM_RUN_LOCAL="${CAPBM_RUN_LOCAL:-false}"

function clone_repos() {
mkdir -p "${M3PATH}"
if [[ -d ${BMOPATH} && "${FORCE_REPO_UPDATE}" == "true" ]]; then
Expand Down Expand Up @@ -63,7 +67,15 @@ function launch_minikube() {

function launch_baremetal_operator() {
pushd "${BMOPATH}"
make deploy
if [ "${BMO_RUN_LOCAL}" = true ]; then
touch bmo.out.log
touch bmo.err.log
make deploy
kubectl scale deployment metal3-baremetal-operator -n metal3 --replicas=0
nohup make run >> bmo.out.log 2>>bmo.err.log &
else
make deploy
fi
popd
}

Expand All @@ -89,7 +101,15 @@ function apply_bm_hosts() {
#
function launch_cluster_api() {
pushd "${CAPBMPATH}"
make deploy
if [ "${CAPBM_RUN_LOCAL}" = true ]; then
touch capbm.out.log
touch capbm.err.log
make deploy
kubectl scale statefulset cluster-api-provider-baremetal-controller-manager -n metal3 --replicas=0
nohup make run >> capbm.out.log 2>> capbm.err.log &
else
make deploy
fi
popd
}

Expand Down
21 changes: 15 additions & 6 deletions 04_verify.sh
Expand Up @@ -105,9 +105,12 @@ check_k8s_entity() {
FAILS="$(process_status $? "${1} ${name} created")"

# Check the replicas
FAILS="$(equals "$(echo "${ENTITY}" | jq -r '.status.readyReplicas')" \
"$(echo "${ENTITY}" | jq -r '.status.replicas')" \
"${name} ${1} replicas correct")"
if [[ "${BMO_RUN_LOCAL}" != true ]] && [[ "${CAPBM_RUN_LOCAL}" != true ]]
then
FAILS="$(equals "$(echo "${ENTITY}" | jq -r '.status.readyReplicas')" \
"$(echo "${ENTITY}" | jq -r '.status.replicas')" \
"${name} ${1} replicas correct")"
fi
done
echo "" >&3
echo "${FAILS}"
Expand All @@ -122,9 +125,12 @@ check_k8s_rs() {
FAILS="$(differs "${ENTITY}" "null" "Replica set ${name} created")"

# Check the replicas
FAILS="$(equals "$(echo "${ENTITY}" | jq -r '.status.readyReplicas')" \
"$(echo "${ENTITY}" | jq -r '.status.replicas')" \
"${name} replicas correct")"
if [[ "${BMO_RUN_LOCAL}" != true ]] && [[ "${CAPBM_RUN_LOCAL}" != true ]]
then
FAILS="$(equals "$(echo "${ENTITY}" | jq -r '.status.readyReplicas')" \
"$(echo "${ENTITY}" | jq -r '.status.replicas')" \
"${name} replicas correct")"
fi
done
echo "" >&3
echo "${FAILS}"
Expand All @@ -143,6 +149,9 @@ EXPTD_DEPLOYMENTS="metal3-baremetal-operator"
BRIDGES="provisioning baremetal"

FAILS=0
BMO_RUN_LOCAL="${BMO_RUN_LOCAL:-false}"
CAPBM_RUN_LOCAL="${CAPBM_RUN_LOCAL:-false}"


# Verify networking
for bridge in ${BRIDGES}; do
Expand Down
13 changes: 13 additions & 0 deletions host_cleanup.sh
Expand Up @@ -19,6 +19,19 @@ if [[ "${CONTAINER_RUNTIME}" == "podman" ]]; then
fi
fi

# Kill the locally running operators
if [ "${BMO_RUN_LOCAL}" = true ]; then
kill "$(pgrep "operator-sdk")" 2> /dev/null || true
fi
if [ "${CAPBM_RUN_LOCAL}" = true ]; then
CAPBM_PARENT_PID="$(pgrep -f "go run ./cmd/manager/main.go")"
if [[ "${CAPBM_PARENT_PID}" != "" ]]; then
CAPBM_GO_PID="$(pgrep -P "${CAPBM_PARENT_PID}" )"
kill "${CAPBM_GO_PID}" 2> /dev/null || true
fi
fi


ANSIBLE_FORCE_COLOR=true ansible-playbook \
-e "working_dir=$WORKING_DIR" \
-e "num_masters=$NUM_MASTERS" \
Expand Down

0 comments on commit 569475a

Please sign in to comment.