Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Makefile: fix issues with repeated evaluations, other minor improvements #813

Merged

Conversation

joelanford
Copy link
Member

Description

I was experiencing extreme delays in running make for any target so finally decided to run it through strace to see what I could find. It turns out make was evaluating almost all of our variables many many times due to the use of = and ?= instead of :=.

See https://www.gnu.org/software/make/manual/html_node/Flavors.html#Flavors for docs about the various flavors of variables.

While I was at it, I also cleaned up and improved a few other things:

  • Auto-detect docker, fallback to podman, fail if neither are present
  • Remove GO_BUILD_TAGS. The original intention was to have a way to inject extra or different code in other distributions of operator-controller. We've seen Red Hat's OCP distribution use carry patches in a fork instead.
  • Remove unused or minimally useful variables. e.g. GOBIN, TESTDATA_DIR

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@joelanford joelanford requested a review from a team as a code owner May 2, 2024 04:41
Copy link

netlify bot commented May 2, 2024

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 75570c2
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/6633e57d7081080008f6b586
😎 Deploy Preview https://deploy-preview-813--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.64%. Comparing base (79d64e8) to head (75570c2).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #813      +/-   ##
==========================================
- Coverage   67.21%   64.64%   -2.57%     
==========================================
  Files          23       16       -7     
  Lines        1467     1321     -146     
==========================================
- Hits          986      854     -132     
+ Misses        415      404      -11     
+ Partials       66       63       -3     
Flag Coverage Δ
e2e 41.86% <ø> (-3.68%) ⬇️
unit 57.56% <ø> (-3.79%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Makefile Show resolved Hide resolved
@bentito
Copy link
Contributor

bentito commented May 2, 2024

/lgtm

Just had the one comment about removing a comment.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 2, 2024

# Define dependency versions (use go.mod if we also use Go code from dependency)
export CERT_MGR_VERSION := v1.9.0
export CATALOGD_VERSION := $(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/catalogd)
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this new variable assignment impact doing something like:

make run CATALOGD_VERSION=vX.Y.Z

IIUC using the ?= variable assignment would only expand the variables if they were not already defined via something like the above example. Is overriding the values still possible with this new variable assignment?

Copy link
Member Author

Choose a reason for hiding this comment

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

If we want the variables to be overridable, they would need this sort of construction:

ifeq (,$(VAR))
VAR := $(shell echo "Hello")
endif

Does the catalogd version need to be configurable like that? If so, I can change it. Let me know if there are other variables in the same boat that you see with the non-overridable assignment.

Makefile Outdated
export WAIT_TIMEOUT ?= 60s
IMG?=$(IMAGE_REPO):$(IMAGE_TAG)
TESTDATA_DIR := testdata
ifeq (, $(IMAGE_REPO))
Copy link
Contributor

Choose a reason for hiding this comment

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

These questions are all for the changes to former ?= statements.

The gnu recommendation is to have ifeq(test, expected), e.g.

ifeq ($(IMAGE_REPO),)

but AFAIK this should be fine. It should be noted that this will trigger even if the test var is empty, which in this case would overwrite with the default value for the arg. I can think of no case where we would want the variable to be defined-but-empty, so it's probably fine.

Any reason that this is superior to the conditional variable example:

 ifeq ($(origin IMAGE_REPO), undefined)
  IMAGE_REPO = blah
endif

?

Finally, this is supposed to be the semantic equivalent of ?= and it seems reasonable to expect no performance benefit from this particular change. If that's not the case, how big a performance impact are we seeing?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not great

ifeq ($(origin IMAGE_REPO), undefined)
  IMAGE_REPO = $(shell long-running.sh)
endif

This is better

ifeq ($(origin IMAGE_REPO), undefined)
  IMAGE_REPO := $(shell long-running.sh)
endif

In the first case (which is equivalent to ?=), long-running-sh runs every time $(IMAGE_REPO) is referenced.
In the second case, long-running.sh only runs once.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll switch to this style though. I just saw that in the docs as well

ifeq ($(origin IMAGE_REPO), undefined)
  IMAGE_REPO := $(shell long-running.sh)
endif

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label May 2, 2024
Copy link

openshift-ci bot commented May 2, 2024

New changes are detected. LGTM label has been removed.

Comment on lines +123 to +125
E2E_REGISTRY_NAME := docker-registry
E2E_REGISTRY_NAMESPACE := operator-controller-e2e
export REG_PKG_NAME := registry-operator
Copy link
Member

Choose a reason for hiding this comment

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

@joelanford I found a misalignment here ;)

I would prefer if we could avoid formatting like this as it is hard to maintain this style. This also leads to larger diffs: for example, here I wanted to only remove one line but I had to change another for it to not look weird.

Copy link
Member

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants