Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,25 @@ operator-local-gcp:
@$(MAKE) operator-stop-gcp || true
@./dev/operator_local.sh --operator-only --gcp || true

# start local operator and attach the delve debugger to it (in server mode)
operator-local-dbg-aws:
@$(MAKE) operator-stop || true
@./dev/operator_local_debugger.sh --aws || true
operator-local-dbg-gcp:
@$(MAKE) operator-stop || true
@./dev/operator_local_debugger.sh --gcp || true

# configure kubectl to point to the cluster specified in dev/config/cluster-[aws|gcp].yaml
kubectl-aws:
@eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml) && eksctl utils write-kubeconfig --cluster="$$CORTEX_CLUSTER_NAME" --region="$$CORTEX_REGION" | grep -v "saved kubeconfig as" | grep -v "using region" | grep -v "eksctl version" || true
kubectl-gcp:
@eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-gcp.yaml) && gcloud container clusters get-credentials "$$CORTEX_CLUSTER_NAME" --zone "$$CORTEX_ZONE" --project "$$CORTEX_PROJECT" 2>&1 | grep -v "Fetching cluster" | grep -v "kubeconfig entry generated" || true

# configure kubectl to point to the cluster specified in dev/config/cluster.yaml
.PHONY: kubectl
kubectl:
@eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster.yaml) && eksctl utils write-kubeconfig --cluster="$$CORTEX_CLUSTER_NAME" --region="$$CORTEX_REGION" | grep -v "saved kubeconfig as" | grep -v "using region" | grep -v "eksctl version" || true

cluster-up-aws:
@$(MAKE) images-all-aws
@$(MAKE) cli
Expand Down Expand Up @@ -206,6 +219,7 @@ registry-clean-local:
tools:
@go get -u -v golang.org/x/lint/golint
@go get -u -v github.com/VojtechVitek/rerun/cmd/rerun
@go get -u -v github.com/go-delve/delve/cmd/dlv
@python3 -m pip install black 'pydoc-markdown>=3.0.0,<4.0.0'
@if [[ "$$OSTYPE" == "darwin"* ]]; then brew install parallel; elif [[ "$$OSTYPE" == "linux"* ]]; then sudo apt-get install -y parallel; else echo "your operating system is not supported"; fi

Expand Down
14 changes: 14 additions & 0 deletions build/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ fi
output=$(cd "$ROOT" && find . -type f \
! -path "./vendor/*" \
! -path "**/.vscode/*" \
! -path "**/.idea/*" \
! -path "**/.history/*" \
! -path "**/__pycache__/*" \
! -path "./examples/*" \
! -path "./dev/config/*" \
Expand All @@ -97,6 +99,8 @@ if [ "$is_release_branch" = "true" ]; then
! -path "./build/lint.sh" \
! -path "./vendor/*" \
! -path "**/.vscode/*" \
! -path "**/.idea/*" \
! -path "**/.history/*" \
! -path "**/__pycache__/*" \
! -path "./docs/contributing/development.md" \
! -path "./dev/config/*" \
Expand All @@ -118,6 +122,8 @@ if [ "$is_release_branch" = "true" ]; then
! -path "./dev/*" \
! -path "./vendor/*" \
! -path "**/.vscode/*" \
! -path "**/.idea/*" \
! -path "**/.history/*" \
! -path "**/__pycache__/*" \
! -path "./dev/config/*" \
! -path "./bin/*" \
Expand Down Expand Up @@ -181,6 +187,8 @@ fi
# Check for trailing whitespace
output=$(cd "$ROOT" && find . -type f \
! -path "./vendor/*" \
! -path "**/.idea/*" \
! -path "**/.history/*" \
! -path "**/.vscode/*" \
! -path "**/__pycache__/*" \
! -path "./dev/config/*" \
Expand All @@ -198,6 +206,8 @@ fi
# Check for missing new line at end of file
output=$(cd "$ROOT" && find . -type f \
! -path "./vendor/*" \
! -path "**/.idea/*" \
! -path "**/.history/*" \
! -path "**/.vscode/*" \
! -path "**/__pycache__/*" \
! -path "./dev/config/*" \
Expand All @@ -216,6 +226,8 @@ fi
output=$(cd "$ROOT" && find . -type f \
! -path "./vendor/*" \
! -path "**/.vscode/*" \
! -path "**/.idea/*" \
! -path "**/.history/*" \
! -path "**/__pycache__/*" \
! -path "./dev/config/*" \
! -path "./bin/*" \
Expand All @@ -232,6 +244,8 @@ fi
# Check for new line(s) at beginning of file
output=$(cd "$ROOT" && find . -type f \
! -path "./vendor/*" \
! -path "**/.idea/*" \
! -path "**/.history/*" \
! -path "**/.vscode/*" \
! -path "**/__pycache__/*" \
! -path "./dev/config/*" \
Expand Down
59 changes: 59 additions & 0 deletions dev/operator_local_debugger.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# Copyright 2020 Cortex Labs, 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,
# 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.

set -euo pipefail

arg1=${1:-""}

provider=""
if [ "$arg1" = "--aws" ]; then
provider="aws"
elif [ "$arg1" = "--gcp" ]; then
provider="gcp"
else
echo "provider must be set: either pass in the --aws or the --gcp flag"
exit 1
fi

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. >/dev/null && pwd)"
DEBUG_CMD="dlv --listen=:2345 --headless=true --api-version=2 debug $ROOT/pkg/operator --output ${ROOT}/bin/__debug_bin"

kill $(pgrep -f "${DEBUG_CMD}") >/dev/null 2>&1 || true
kill $(pgrep -f __debug_bin) >/dev/null 2>&1 || true

eval $(python3 $ROOT/manager/cluster_config_env.py "$ROOT/dev/config/cluster-${provider}.yaml")

if [ "$provider" = "aws" ]; then
export CORTEX_DEV_DEFAULT_PREDICTOR_IMAGE_REGISTRY="$CORTEX_DEV_DEFAULT_PREDICTOR_IMAGE_REGISTRY_AWS"
export CLUSTER_AWS_ACCESS_KEY_ID="${CLUSTER_AWS_ACCESS_KEY_ID:-$AWS_ACCESS_KEY_ID}"
export CLUSTER_AWS_SECRET_ACCESS_KEY="${CLUSTER_AWS_SECRET_ACCESS_KEY:-$AWS_SECRET_ACCESS_KEY}"
else
export CORTEX_DEV_DEFAULT_PREDICTOR_IMAGE_REGISTRY="$CORTEX_DEV_DEFAULT_PREDICTOR_IMAGE_REGISTRY_GCP"
fi

python3 $ROOT/dev/update_cli_config.py "$HOME/.cortex/cli.yaml" "${CORTEX_CLUSTER_NAME}-${provider}" "$provider" "http://localhost:8888"

cp -r $ROOT/dev/config/cluster-${provider}.yaml ~/.cortex/cluster-dev.yaml

if grep -qiP '^telemetry:\s*false\s*$' ~/.cortex/cli.yaml; then
echo "telemetry: false" >> ~/.cortex/cluster-dev.yaml
fi

export CORTEX_OPERATOR_IN_CLUSTER=false
export CORTEX_CLUSTER_CONFIG_PATH=~/.cortex/cluster-dev.yaml

mkdir -p $ROOT/bin
echo 'starting local operator in debug mode...' && eval "${DEBUG_CMD}"