Skip to content

Commit b3cf926

Browse files
committed
move functions + poll for gcr images + build feast-ci on PRs
Signed-off-by: Jacob Klegar <jacob@tecton.ai>
1 parent f535709 commit b3cf926

4 files changed

Lines changed: 110 additions & 103 deletions

File tree

‎.github/workflows/complete.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: [self-hosted]
88
strategy:
99
matrix:
10-
component: [core, serving, jobservice, jupyter]
10+
component: [core, serving, jobservice, jupyter, ci]
1111
env:
1212
GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha }}
1313
REGISTRY: gcr.io/kf-feast

‎infra/docker/ci/Dockerfile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,6 @@ RUN apt-get install -y kubectl
8383
RUN curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 && \
8484
chmod 700 get_helm.sh && \
8585
./get_helm.sh
86+
87+
# Install jq
88+
RUN apt-get install -y jq

‎infra/scripts/azure-runner.sh‎

Lines changed: 2 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -6,114 +6,14 @@ STEP_BREADCRUMB='~~~~~~~~'
66
SECONDS=0
77
TIMEFORMAT="${STEP_BREADCRUMB} took %R seconds"
88

9-
function k8s_cleanup {
10-
local RELEASE=$1
11-
local NAMESPACE=$2
12-
13-
# Create namespace if it doesn't exist.
14-
kubectl create namespace "$NAMESPACE" || true
15-
16-
# Uninstall previous feast release if there is any.
17-
helm uninstall "$RELEASE" -n "$NAMESPACE" || true
18-
19-
# `helm uninstall` doesn't remove PVCs, delete them manually.
20-
time kubectl delete pvc --all -n "$NAMESPACE" || true
21-
22-
kubectl get service -n "$NAMESPACE"
23-
24-
# Set a new postgres password. Note that the postgres instance is not available outside
25-
# the k8s cluster anyway so it doesn't have to be super secure.
26-
echo "${STEP_BREADCRUMB} Setting PG password"
27-
PG_PASSWORD=$(head -c 59 /dev/urandom | md5sum | head -c 16)
28-
kubectl delete secret feast-postgresql -n "$NAMESPACE" || true
29-
kubectl create secret generic feast-postgresql --from-literal=postgresql-password="$PG_PASSWORD" -n "$NAMESPACE"
30-
}
31-
32-
function helm_install {
33-
# helm install Feast into k8s cluster and display a nice error if it fails.
34-
# Usage: helm_install $RELEASE $DOCKER_REPOSITORY $GIT_TAG ...
35-
# Args:
36-
# $RELEASE is helm release name
37-
# $DOCKER_REPOSITORY is the docker repo containing feast images tagged with $GIT_TAG
38-
# ... you can pass additional args to this function that are passed on to helm install
39-
40-
local RELEASE=$1
41-
local DOCKER_REPOSITORY=$2
42-
local GIT_TAG=$3
43-
44-
shift 3
45-
46-
# We skip statsd exporter and other metrics stuff since we're not using it anyway, and it
47-
# has some issues with unbound PVCs (that cause kubectl delete pvc to hang).
48-
echo "${STEP_BREADCRUMB} Helm installing feast"
49-
50-
if ! time helm install --wait "$RELEASE" infra/charts/feast \
51-
--timeout 15m \
52-
--set "feast-jupyter.image.repository=${DOCKER_REPOSITORY}/feast-jupyter" \
53-
--set "feast-jupyter.image.tag=${GIT_TAG}" \
54-
--set "feast-online-serving.image.repository=${DOCKER_REPOSITORY}/feast-serving" \
55-
--set "feast-online-serving.image.tag=${GIT_TAG}" \
56-
--set "feast-jobservice.image.repository=${DOCKER_REPOSITORY}/feast-jobservice" \
57-
--set "feast-jobservice.image.tag=${GIT_TAG}" \
58-
--set "feast-core.image.repository=${DOCKER_REPOSITORY}/feast-core" \
59-
--set "feast-core.image.tag=${GIT_TAG}" \
60-
--set "prometheus-statsd-exporter.enabled=false" \
61-
--set "prometheus.enabled=false" \
62-
--set "grafana.enabled=false" \
63-
--set "feast-jobservice.enabled=false" \
64-
"$@" ; then
65-
66-
echo "Error during helm install. "
67-
kubectl -n "$NAMESPACE" get pods
68-
69-
readarray -t CRASHED_PODS < <(kubectl -n "$NAMESPACE" get pods --no-headers=true | grep "$RELEASE" | awk '{if ($2 == "0/1") { print $1 } }')
70-
echo "Crashed pods: ${CRASHED_PODS[*]}"
71-
72-
for POD in "${CRASHED_PODS[@]}"; do
73-
echo "Logs from pod error $POD:"
74-
kubectl -n "$NAMESPACE" logs "$POD" --previous
75-
done
76-
77-
exit 1
78-
fi
79-
}
80-
81-
function setup_sparkop_role {
82-
# Set up permissions for the default user in sparkop namespace so that Feast SDK can manage
83-
# sparkapplication resources from the test runner pod.
84-
85-
cat <<EOF | kubectl apply -f -
86-
kind: Role
87-
apiVersion: rbac.authorization.k8s.io/v1beta1
88-
metadata:
89-
name: use-spark-operator
90-
rules:
91-
- apiGroups: ["sparkoperator.k8s.io"]
92-
resources: ["sparkapplications"]
93-
verbs: ["create", "delete", "deletecollection", "get", "list", "update", "watch", "patch"]
94-
---
95-
apiVersion: rbac.authorization.k8s.io/v1beta1
96-
kind: RoleBinding
97-
metadata:
98-
name: use-spark-operator
99-
roleRef:
100-
kind: Role
101-
name: use-spark-operator
102-
apiGroup: rbac.authorization.k8s.io
103-
subjects:
104-
- kind: ServiceAccount
105-
name: default
106-
EOF
107-
}
9+
# Note requires running in root feast directory
10+
source infra/scripts/runner-helper.sh
10811

10912
GIT_TAG=$(git rev-parse HEAD)
11013
GIT_REMOTE_URL=$(git config --get remote.origin.url)
11114

11215
echo "########## Starting e2e tests for ${GIT_REMOTE_URL} ${GIT_TAG} ###########"
11316

114-
# This seems to make builds a bit faster.
115-
export DOCKER_BUILDKIT=1
116-
11717
# Workaround for COPY command in core docker image that pulls local maven repo into the image
11818
# itself.
11919
mkdir .m2 2>/dev/null || true

‎infra/scripts/runner-helper.sh‎

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/bin/bash
2+
3+
function k8s_cleanup {
4+
local RELEASE=$1
5+
local NAMESPACE=$2
6+
7+
# Create namespace if it doesn't exist.
8+
kubectl create namespace "$NAMESPACE" || true
9+
10+
# Uninstall previous feast release if there is any.
11+
helm uninstall "$RELEASE" -n "$NAMESPACE" || true
12+
13+
# `helm uninstall` doesn't remove PVCs, delete them manually.
14+
time kubectl delete pvc --all -n "$NAMESPACE" || true
15+
16+
kubectl get service -n "$NAMESPACE"
17+
18+
# Set a new postgres password. Note that the postgres instance is not available outside
19+
# the k8s cluster anyway so it doesn't have to be super secure.
20+
echo "${STEP_BREADCRUMB} Setting PG password"
21+
PG_PASSWORD=$(head -c 59 /dev/urandom | md5sum | head -c 16)
22+
kubectl delete secret feast-postgresql -n "$NAMESPACE" || true
23+
kubectl create secret generic feast-postgresql --from-literal=postgresql-password="$PG_PASSWORD" -n "$NAMESPACE"
24+
}
25+
26+
function helm_install {
27+
# helm install Feast into k8s cluster and display a nice error if it fails.
28+
# Usage: helm_install $RELEASE $DOCKER_REPOSITORY $GIT_TAG ...
29+
# Args:
30+
# $RELEASE is helm release name
31+
# $DOCKER_REPOSITORY is the docker repo containing feast images tagged with $GIT_TAG
32+
# ... you can pass additional args to this function that are passed on to helm install
33+
34+
local RELEASE=$1
35+
local DOCKER_REPOSITORY=$2
36+
local GIT_TAG=$3
37+
38+
shift 3
39+
40+
# Wait for images to be available in the docker repository; ci is the last image built
41+
timeout 15m bash -c 'while ! gcloud container images list-tags ${DOCKER_REPOSITORY}/feast-ci --format=json | jq -e ".[] | select(.tags[] | contains (\"$GIT_TAG\"))" > /dev/null; do sleep 10s; done'
42+
43+
# We skip statsd exporter and other metrics stuff since we're not using it anyway, and it
44+
# has some issues with unbound PVCs (that cause kubectl delete pvc to hang).
45+
echo "${STEP_BREADCRUMB} Helm installing feast"
46+
47+
if ! time helm install --wait "$RELEASE" infra/charts/feast \
48+
--timeout 15m \
49+
--set "feast-jupyter.image.repository=${DOCKER_REPOSITORY}/feast-jupyter" \
50+
--set "feast-jupyter.image.tag=${GIT_TAG}" \
51+
--set "feast-online-serving.image.repository=${DOCKER_REPOSITORY}/feast-serving" \
52+
--set "feast-online-serving.image.tag=${GIT_TAG}" \
53+
--set "feast-jobservice.image.repository=${DOCKER_REPOSITORY}/feast-jobservice" \
54+
--set "feast-jobservice.image.tag=${GIT_TAG}" \
55+
--set "feast-core.image.repository=${DOCKER_REPOSITORY}/feast-core" \
56+
--set "feast-core.image.tag=${GIT_TAG}" \
57+
--set "prometheus-statsd-exporter.enabled=false" \
58+
--set "prometheus.enabled=false" \
59+
--set "grafana.enabled=false" \
60+
--set "feast-jobservice.enabled=false" \
61+
"$@" ; then
62+
63+
echo "Error during helm install. "
64+
kubectl -n "$NAMESPACE" get pods
65+
66+
readarray -t CRASHED_PODS < <(kubectl -n "$NAMESPACE" get pods --no-headers=true | grep "$RELEASE" | awk '{if ($2 == "0/1") { print $1 } }')
67+
echo "Crashed pods: ${CRASHED_PODS[*]}"
68+
69+
for POD in "${CRASHED_PODS[@]}"; do
70+
echo "Logs from pod error $POD:"
71+
kubectl -n "$NAMESPACE" logs "$POD" --previous
72+
done
73+
74+
exit 1
75+
fi
76+
}
77+
78+
function setup_sparkop_role {
79+
# Set up permissions for the default user in sparkop namespace so that Feast SDK can manage
80+
# sparkapplication resources from the test runner pod.
81+
82+
cat <<EOF | kubectl apply -f -
83+
kind: Role
84+
apiVersion: rbac.authorization.k8s.io/v1beta1
85+
metadata:
86+
name: use-spark-operator
87+
rules:
88+
- apiGroups: ["sparkoperator.k8s.io"]
89+
resources: ["sparkapplications"]
90+
verbs: ["create", "delete", "deletecollection", "get", "list", "update", "watch", "patch"]
91+
---
92+
apiVersion: rbac.authorization.k8s.io/v1beta1
93+
kind: RoleBinding
94+
metadata:
95+
name: use-spark-operator
96+
roleRef:
97+
kind: Role
98+
name: use-spark-operator
99+
apiGroup: rbac.authorization.k8s.io
100+
subjects:
101+
- kind: ServiceAccount
102+
name: default
103+
EOF
104+
}

0 commit comments

Comments
 (0)