Skip to content

Add the ability to add the -race flag to the local operator builder#2187

Closed
levigross wants to merge 3 commits intooperator-framework:masterfrom
levigross:master
Closed

Add the ability to add the -race flag to the local operator builder#2187
levigross wants to merge 3 commits intooperator-framework:masterfrom
levigross:master

Conversation

@levigross
Copy link

Description of the change:
Add a command line option to enable building the local version of the operator with the -raceflag.

Motivation for the change:
When running the operator locally, I wanted to compile it with the -race flag to enable the runtime race detection.

@openshift-ci-robot
Copy link

Hi @levigross. Thanks for your PR.

I'm waiting for a operator-framework member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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/test-infra repository.

@openshift-ci-robot openshift-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 13, 2019
@joelanford
Copy link
Member

@levigross I'm hesitant to add more go plumbing flags (see #1600 (comment) for some background).

Would it be reasonable to just always include the -race flag in operator-sdk up local?

@levigross
Copy link
Author

@joelanford Thank you for highlighting that issue and I hope that this PR doesn't exacerbate it.

I don't think we should always include -race when building the operator as there is a significant performance penalty when it is enabled.

upLocalCmd.Flags().StringVar(&operatorFlags, "operator-flags", "", "The flags that the operator needs. Example: \"--flag1 value1 --flag2=value2\"")
upLocalCmd.Flags().StringVar(&namespace, "namespace", "", "The namespace where the operator watches for changes.")
upLocalCmd.Flags().StringVar(&ldFlags, "go-ldflags", "", "Set Go linker options")
upLocalCmd.Flags().BoolVar(&enableRaceDetector, "enable-race-detector", false, "Enables the go runtime's race detector when compiling the operator")
Copy link
Contributor

Choose a reason for hiding this comment

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

WDYT about use the same nomenclature? I mean --race only?

Copy link
Author

Choose a reason for hiding this comment

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

I don’t mind changing it 🙂. I didn’t do it initially because the other options don’t exactly match the compiler e.g ‘go-ldflags’. But I like and appreciate your suggestion because I am horrible with variable names and this makes it easier.

@camilamacedo86 camilamacedo86 added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 16, 2019
Env []string
// Dir is the dir to run "go {cmd}" in; exec.Command.Dir is set to this value.
Dir string
// Race is to add the -race flag when compiling the operator
Copy link
Member

Choose a reason for hiding this comment

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

An extra flag is not needed. -race can be appended directly to GoCmdOptions.Args in the caller.

@estroz
Copy link
Member

estroz commented Nov 18, 2019

I am in agreement that we shouldn't be adding more flags to wrapped go invocations. Moreover wouldn't -race be more amenable to being used with go test instead?

@camilamacedo86
Copy link
Contributor

camilamacedo86 commented Nov 21, 2019

Hi @levigross,

Really thank you for your contribution. 🥇

Based on the following comments added by @estroz shows that we can be closing this one. However, please feel free to re-open if you think that it still required.

An extra flag is not needed. -race can be appended directly to GoCmdOptions.Args in the caller.

I am in agreement that we shouldn't be adding more flags to wrapped go invocations. Moreover wouldn't -race be more amenable to being used with go test instead?

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

Labels

kind/feature Categorizes issue or PR as related to a new feature. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants