-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
✨ (go/v4): add race flag for go test command at the makefile #4526
base: master
Are you sure you want to change the base?
Conversation
In order to detect data races early it would make sense to use the race flag for the most common generated go commands
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: PG2000 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @PG2000. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/ok-to-test IMHO, this is a great thought! However, please note that whenever we update the scaffold, we need to run make generate to regenerate all samples under testdata and in the docs/book. Additionally, I hope you don’t mind, but I updated the title of this PR to include an emoji so it aligns with our standards and helps us create the Release Notes. Please refer to the CONTRIBUTING.md guide for more details. Could you please:
Thank you! 🙌 |
@@ -61,7 +61,7 @@ COPY internal/ internal/ | |||
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, see that the changes here broke the tests
#15 [builder 9/9] RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -race -a -o manager cmd/main.go
#15 0.430 go: -race requires cgo; enable cgo by setting CGO_ENABLED=1
#15 ERROR: process "/bin/sh -c CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -race -a -o manager cmd/main.go" did not complete successfully: exit code: 2
------
It does not seems to work.
So, can you please check out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will check this. Seems like CGO must be enabled for go build. Will try to leave this part out and start on the other problem where a data race was detected.
@PG2000: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
@@ -155,7 +155,7 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated | |||
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \ | |||
exit 1; \ | |||
} | |||
go test ./test/e2e/ -v -ginkgo.v | |||
go test ./test/e2e/ -race -v -ginkgo.v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This slow-down all process for several times and required cgo to be enabled, and on non-Darwin systems requires an installed C compiler. Not sure, it should be enabled by default.
Probably it can be an option or flag and customer should decide if it enabled or not.
For example, we are using it for long running CI processes at night, but not in regular pipelines for each PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to add some extra flexibility, we can introduce a field that will be empty by default with the ability to change it, and which we will add as arguments when calling tests and/or build.
We can add two different fields for build and tests.
But it is very dangerous to forcefully add the -race
flag by default.
In order to detect data races early it would make sense to use the race flag
for the most common generated go commands.
In grown projects built on kubebuilder i observed that with the timing and growing codebases
some data races occured in tests and then its hard to find the causing commit or code chnage.
Maybe this change can help to find them earlier.