Skip to content

Commit

Permalink
Remove waiting loops for kubernetes resources from Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
sutaakar authored and openshift-merge-robot committed Jul 25, 2023
1 parent c885e0a commit c9929bd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/actions/kind/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ runs:
EOF'
- name: Setup KinD cluster
uses: helm/kind-action@v1.5.0
uses: helm/kind-action@v1.8.0
with:
cluster_name: cluster
version: v0.17.0
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/olm_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ jobs:
# wait for a while to be sure CRDs are installed
sleep 1
kubectl create -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${OLM_VERSION}/olm.yaml
echo Wait for default CatalogSource to start
kubectl wait -n ${{ env.CATALOG_SOURCE_NAMESPACE }} catalogsource/${{ env.CATALOG_SOURCE_NAME }} --for=jsonpath='{.status.connectionState.lastObservedState}'=READY --timeout=180s
env:
CATALOG_SOURCE_NAME: "operatorhubio-catalog"
CATALOG_SOURCE_NAMESPACE: "olm"

- name: Create openshift-operator namespace and OperatorGroup
run: |
Expand All @@ -87,15 +92,18 @@ jobs:
envsubst < .github/resources-olm-upgrade/subscription.yaml > ${{ env.TEMP_DIR }}/subscription.yaml
kubectl create -f ${{ env.TEMP_DIR }}/catalogsource.yaml
make wait-for-catalog-source
echo Wait for CatalogSource ${{ env.CATALOG_SOURCE_NAME }} to start
kubectl wait -n ${{ env.CATALOG_SOURCE_NAMESPACE }} catalogsource/${{ env.CATALOG_SOURCE_NAME }} --for=jsonpath='{.status.connectionState.lastObservedState}'=READY --timeout=180s
kubectl create -f ${{ env.TEMP_DIR }}/subscription.yaml
echo Waiting for Subscription to be ready
make wait-for-subscription
kubectl wait -n ${{ env.SUBSCRIPTION_NAMESPACE }} subscription/${{ env.SUBSCRIPTION_NAME }} --for=jsonpath='{.status.state}'=AtLatestKnown --timeout=180s
echo Waiting for Deployment to be ready
make wait-for-deployment -e TIMEOUT=60 -e DEPLOYMENT_NAME="codeflare-operator-manager" -e DEPLOYMENT_NAMESPACE="openshift-operators"
timeout 60 bash -c 'until [[ $(kubectl get deployment/codeflare-operator-manager -n '${{ env.SUBSCRIPTION_NAMESPACE }}') ]]; do sleep 5 && echo "$(kubectl get deployment/codeflare-operator-manager -n '${{ env.SUBSCRIPTION_NAMESPACE }}')"; done'
kubectl wait -n ${{ env.SUBSCRIPTION_NAMESPACE }} deployment/codeflare-operator-manager --for=condition=Available=true --timeout=60s
env:
CATALOG_SOURCE_NAME: "codeflare-olm-test"
CATALOG_SOURCE_NAMESPACE: "olm"
Expand Down Expand Up @@ -138,10 +146,11 @@ jobs:
kubectl wait --timeout=120s --for=delete pod/${ORIGINAL_POD_NAME} -n openshift-operators
echo Waiting for Subscription to be ready
make wait-for-subscription
kubectl wait -n ${{ env.SUBSCRIPTION_NAMESPACE }} subscription/${{ env.SUBSCRIPTION_NAME }} --for=jsonpath='{.status.state}'=AtLatestKnown --timeout=180s
echo Waiting for Deployment to be ready
make wait-for-deployment -e TIMEOUT=60 -e DEPLOYMENT_NAME="codeflare-operator-manager" -e DEPLOYMENT_NAMESPACE="openshift-operators"
timeout 60 bash -c 'until [[ $(kubectl get deployment/codeflare-operator-manager -n '${{ env.SUBSCRIPTION_NAMESPACE }}') ]]; do sleep 5 && echo "$(kubectl get deployment/codeflare-operator-manager -n '${{ env.SUBSCRIPTION_NAMESPACE }}')"; done'
kubectl wait -n ${{ env.SUBSCRIPTION_NAMESPACE }} deployment/codeflare-operator-manager --for=condition=Available=true --timeout=60s
echo Checking that correct CSV is available
CSV_VERSION=$(kubectl get ClusterServiceVersion/codeflare-operator.${VERSION} -n openshift-operators -o json | jq -r .spec.version)
Expand Down
20 changes: 0 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -440,23 +440,3 @@ test-e2e: defaults manifests generate fmt vet ## Run e2e tests.
.PHONY: setup-e2e
setup-e2e: ## Set up e2e tests.
KUBERAY_VERSION=$(KUBERAY_VERSION) test/e2e/setup.sh

# Wait until CatalogSource is in "READY" state
.PHONY: wait-for-catalog-source
wait-for-catalog-source:
timeout 120 bash -c 'while [[ "$$(kubectl get catalogsource/'$(CATALOG_SOURCE_NAME)' -n '$(CATALOG_SOURCE_NAMESPACE)' -o json | jq -r .status.connectionState.lastObservedState)" != "READY" ]]; do sleep 5 && echo "$$(kubectl get catalogsource/'$(CATALOG_SOURCE_NAME)' -n '$(CATALOG_SOURCE_NAMESPACE)' -o json | jq -r .status.connectionState.lastObservedState)" ; done'

# Wait until Subscription is in "AtLatestKnown" state
.PHONY: wait-for-subscription
wait-for-subscription:
timeout 300 bash -c 'while [[ "$$(kubectl get subscription/'$(SUBSCRIPTION_NAME)' -n '$(SUBSCRIPTION_NAMESPACE)' -o json | jq -r .status.state)" != "AtLatestKnown" ]]; do sleep 5 && echo "$$(kubectl get subscription/'$(SUBSCRIPTION_NAME)' -n '$(SUBSCRIPTION_NAMESPACE)' -o json | jq -r .status.state)" ; done'

# Default timeout for waiting actions
TIMEOUT ?= 180

# Wait until Deployment is in "Available" state
.PHONY: wait-for-deployment
wait-for-deployment:
# Wait until Deployment exists first, then use kubectl wait
timeout $(TIMEOUT) bash -c 'until [[ $$(kubectl get deployment/'$(DEPLOYMENT_NAME)' -n '$(DEPLOYMENT_NAMESPACE)') ]]; do sleep 5 && echo "$$(kubectl get deployment/'$(DEPLOYMENT_NAME)' -n '$(DEPLOYMENT_NAMESPACE)')"; done'
kubectl wait --timeout=$(TIMEOUT)s --for=condition=Available=true deployment/$(DEPLOYMENT_NAME) -n $(DEPLOYMENT_NAMESPACE)

0 comments on commit c9929bd

Please sign in to comment.