Skip to content
This repository was archived by the owner on Mar 3, 2025. It is now read-only.

🐛 Check cluster is running for non-standalone Make targets#437

Merged
grokspawn merged 5 commits into
operator-framework:mainfrom
bentito:checking_kind_running
Nov 13, 2024
Merged

🐛 Check cluster is running for non-standalone Make targets#437
grokspawn merged 5 commits into
operator-framework:mainfrom
bentito:checking_kind_running

Conversation

@bentito

@bentito bentito commented Oct 18, 2024

Copy link
Copy Markdown
Contributor

We have several non-standlone Make targets

  • test-e2e
  • kind-load
  • install
  • only-deploy-manifest

The above targets rely on Kind to be running.

Unfortunately, currently, errors returned from the Go code are pretty cryptic. Better would be an explicit catch and error when a Kind cluster is not found when these targets are run.

Currently we have:

catalogd checking_kind_running $ make test-e2e
/Users/btofel/go/bin/ginkgo-v2.20.2  -trace -vv  test/e2e
Running Suite: E2E Suite - /Users/btofel/workspace/catalogd/test/e2e
====================================================================
Random Seed: 1729265504

Will run 1 of 1 specs
------------------------------
[BeforeSuite]
/Users/btofel/workspace/catalogd/test/e2e/e2e_suite_test.go:33
  > Enter [BeforeSuite] TOP-LEVEL - /Users/btofel/workspace/catalogd/test/e2e/e2e_suite_test.go:33 @ 10/18/24 11:31:49.369

Ginkgo ran 1 suite in 4.681573708s

Test Suite Failed
make: *** [test-e2e] Error 1

wha?

but it would be better to have:

$ make test-e2e
if ! kubectl config current-context >/dev/null 2>&1; then \
		echo "Error: Could not get current Kubernetes context. Use 'run' or 'e2e' targets first."; \
		exit 1; \
	fi
Error: Could not get current Kubernetes context. Use 'run' or 'e2e' targets first.
make: *** [check-cluster] Error 1

@bentito bentito requested a review from a team as a code owner October 18, 2024 14:39
@codecov

codecov Bot commented Oct 18, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 38.23%. Comparing base (4d6327f) to head (2f186ef).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #437   +/-   ##
=======================================
  Coverage   38.23%   38.23%           
=======================================
  Files          15       15           
  Lines        1224     1224           
=======================================
  Hits          468      468           
  Misses        706      706           
  Partials       50       50           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread Makefile Outdated
Comment thread Makefile Outdated
Comment thread Makefile Outdated
E2E_FLAGS :=
endif
test-e2e: $(GINKGO) ## Run the e2e tests
test-e2e: check-kind-cluster $(GINKGO) ## Run the e2e tests

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check might be a bit too presumptuous. For example, someone running test-e2e might want to run the tests after running kind create cluster --name=foobar and tilt up.

It may even be that someone wants to run the e2es against a non-kind cluster that already has OLM deployed.

@bentito bentito Oct 18, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to make it more generic like this:

.PHONY: check-cluster
check-cluster:
	if ! kubectl config current-context >/dev/null 2>&1; then \
		echo "Error: Could not get current Kubernetes context. Use 'run' or 'e2e' targets first."; \
		exit 1; \
	fi

wdyt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay I changed the output to simply be:

echo "Error: Could not get current Kubernetes context. Maybe use 'run' or 'e2e' targets first?";

and check-cluster is called now from test-e2e, install and kind-load all of which really need some cluster running or they produce a non-descriptive and cryptic error message.

Comment thread Makefile Outdated
@bentito bentito requested a review from joelanford October 18, 2024 16:04
@grokspawn grokspawn changed the title 🐛 Check Kind running for non-standalong Make targets 🐛 Check Kind running for non-standalone Make targets Oct 18, 2024
@bentito bentito changed the title 🐛 Check Kind running for non-standalone Make targets 🐛 Check cluster is running for non-standalone Make targets Oct 18, 2024
Comment thread Makefile
bentito and others added 5 commits November 13, 2024 09:33
Signed-off-by: Brett Tofel <btofel@redhat.com>
Co-authored-by: Jordan Keister <jordan@nimblewidget.com>
Co-authored-by: Jordan Keister <jordan@nimblewidget.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
@bentito bentito force-pushed the checking_kind_running branch from 7564eb8 to 2f186ef Compare November 13, 2024 14:34
@grokspawn grokspawn enabled auto-merge November 13, 2024 14:42
@grokspawn grokspawn added this pull request to the merge queue Nov 13, 2024
Merged via the queue into operator-framework:main with commit b30eb4a Nov 13, 2024
@camilamacedo86

camilamacedo86 commented Nov 18, 2024

Copy link
Copy Markdown
Contributor

Hi @bentito

If you see the logs https://github.com/operator-framework/catalogd/actions/runs/11819448861/job/32929383546 (ci job of this PR)you will see that this check is wrong and is always failing:

Screenshot 2024-11-18 at 08 16 07

I do not see the need for this check.
Instead, I would prefer the targets of this project to be as similar as possible to those of https://github.com/operator-framework/operator-controller so that life for us contributors is easier.

c/c @grokspawn

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants