Skip to content

build: add Info.BinaryName#113113

Open
srosenberg wants to merge 1 commit intocockroachdb:masterfrom
srosenberg:sr/add_build_binary_name
Open

build: add Info.BinaryName#113113
srosenberg wants to merge 1 commit intocockroachdb:masterfrom
srosenberg:sr/add_build_binary_name

Conversation

@srosenberg
Copy link
Copy Markdown
Member

We now link the name attribute of the go_binary, as it appears in the corresponding BUILD.bazel. The primary motivation for this change is to exclude non-cockroach binaries (i.e., roachtest and roachprod) from the initialization of the metamorphic constants.

Note, to fully support interop between a roachtest runner, (executing the roachtest binary), and a node, executing the cockroach binary compiled with assertions (i.e., crdb_test), the roachtest binary must also be compiled with assertions to establish the same serialization on the wire. E.g., KVNemesisSeq is used on the wire only under crdb_test builds. The corresponding (sequence) Container type is conditional on the binary being compiled under crdb_test. (See pkg/kv/kvpb/api.proto) Thus, a request serialized from the roachtest runner is compatible with the cockroach binary iff both binaries are built under crdb_test.

Epic: none

Release note: None

@srosenberg srosenberg requested review from a team as code owners October 26, 2023 02:41
@srosenberg srosenberg requested review from DarrylWong and herkolategan and removed request for a team October 26, 2023 02:41
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Oct 26, 2023

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@srosenberg srosenberg requested review from rickystewart and removed request for a team October 26, 2023 02:42
@srosenberg srosenberg added backport-23.2.x PAST MAINTENANCE SUPPORT: 23.2 patch releases via ER request only backport-23.1.x PAST MAINTENANCE SUPPORT: 23.1 patch releases via ER request only labels Oct 26, 2023
We now link the name attribute of the go_binary, as it
appears in the corresponding BUILD.bazel. The primary
motivation for this change is to exclude non-cockroach
binaries (i.e., roachtest and roachprod) from the initialization
of the metamorphic constants.

Note, to fully support interop between a roachtest runner,
(executing the roachtest binary), and a node, executing the cockroach
binary compiled with assertions (i.e., crdb_test), the roachtest binary
must also be compiled with assertions to establish the same serialization
on the wire. E.g., KVNemesisSeq is used on the wire only under crdb_test
builds. The corresponding (sequence) Container type is conditional on
the binary being compiled under crdb_test. (See pkg/kv/kvpb/api.proto)
Thus, a request serialized from the roachtest runner is compatible with
the cockroach binary iff both binaries are built under crdb_test.

Epic: none

Release note: None
@srosenberg srosenberg force-pushed the sr/add_build_binary_name branch from c8fdb8b to 50520d9 Compare October 26, 2023 03:58
Copy link
Copy Markdown
Member

@rail rail left a comment

Choose a reason for hiding this comment

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

I wonder if we can explicitly mark these binaries as eligible instead of guessing it from the name. 🤔 Something similar to EnabledAssertions maybe?

optional string env_channel = 11 [(gogoproto.nullable) = false];
// enabled_assertions returns the value of 'CrdbTestBuild' (true iff compiled with 'crdb_test' tag)
optional bool enabled_assertions = 12 [(gogoproto.nullable) = false];
// binary_anme returns the name of the binary, e.g., cockroach, roachtest, roachprod.
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.

Suggested change
// binary_anme returns the name of the binary, e.g., cockroach, roachtest, roachprod.
// binary_name returns the name of the binary, e.g., cockroach, roachtest, roachprod.

Copy link
Copy Markdown

@renatolabs renatolabs left a comment

Choose a reason for hiding this comment

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

I think it would be helpful to mention an example of a test that breaks without this change.

I'm also curious about how the test runner script will change in light of this. Are we always going to start building roachtest with crdb_test?

return false
}
// Bail out if we are running a non-test binary which also happens to be non-cockroach, e.g., roachprod, roachtest.
if !bazel.InBazelTest() && !strings.Contains(build.GetInfo().BinaryName, "cockroach") {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can you elaborate a bit on this predicate? Why do we need the !bazel.InBazelTest() part?

@DarrylWong
Copy link
Copy Markdown
Contributor

DarrylWong commented Oct 26, 2023

Are we always going to start building roachtest with crdb_test

Yes, that's the idea. For the nightlies, I don't think there'd be a way to selectively use crdb_test roachtest binary iff the test being run has assertions enabled, since one roachtest call is in charge of running all the tests.

Copy link
Copy Markdown
Contributor

@DarrylWong DarrylWong left a comment

Choose a reason for hiding this comment

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

Rebased it off my current changes and it looks like it works 👍

LGTM pending the other's comments

fmt.Fprintf(tw, "C Compiler: %s\n", b.CgoCompiler)
fmt.Fprintf(tw, "Build Commit ID: %s\n", b.Revision)
fmt.Fprintf(tw, "Build Type: %s\n", b.Type)
fmt.Fprintf(tw, "Binary Name: %s\n", b.BinaryName)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

extremely small nit:

Use spaces instead of tab so it's in line with the others?

Suggested change
fmt.Fprintf(tw, "Binary Name: %s\n", b.BinaryName)
fmt.Fprintf(tw, "Binary Name: %s\n", b.BinaryName)

Copy link
Copy Markdown
Collaborator

@rickystewart rickystewart left a comment

Choose a reason for hiding this comment

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

This looks fine, consider that something like the following would also work and will be simpler:

In pkg/build/info.go, add:

var IsCockroachBinary = false

Then, in pkg/cmd/cockroach{,-oss,-short}/main.go, add:

func init() { build.IsCockroachBinary = true }

This is assuming that determining whether a binary is a cockroach binary is the ultimate purpose as the PR description says.

srosenberg added a commit to srosenberg/cockroach that referenced this pull request Oct 28, 2023
In [1], new cluster settings have been added, e.g.,
`kv.replica_gc_queue.enabled`, `kv.raft_log_queue.enabled`,
to selectively disable work queues per store, at runtime.

The new unit tests use a dummy `BoolSetting` which aliases
slot 0 of the global cluster setting `registry`. Thus, its
value corresponds to whichever cluster setting is registered
first during `init()`. Before the change in [2], the first
registered cluster setting is `bulkio.backup.merge_file_buffer_size`,
one with a non-zero value in slot 0.
After the change, it is `keyvisualizer.enabled`, one with a
zero value in slot 0. Subsequently, a number of the unit tests
failed because `baseQueue.mu.disabled` is now true instead
of previously, false.

The change in this PR fixes the bug by registering a fresh dummy
`BoolSetting`. We also rename `disabledConfig` to match the polarity
used in conjunction with `bq.SetDisabled`.

[1] cockroachdb#104170
[2] cockroachdb#113113

Epic: none

Release note: None
srosenberg added a commit to srosenberg/cockroach that referenced this pull request Nov 16, 2023
In [1], new cluster settings have been added, e.g.,
`kv.replica_gc_queue.enabled`, `kv.raft_log_queue.enabled`,
to selectively disable work queues per store, at runtime.

The new unit tests use a dummy `BoolSetting` which aliases
slot 0 of the global cluster setting `registry`. Thus, its
value corresponds to whichever cluster setting is registered
first during `init()`. Before the change in [2], the first
registered cluster setting is `bulkio.backup.merge_file_buffer_size`,
one with a non-zero value in slot 0.
After the change, it is `keyvisualizer.enabled`, one with a
zero value in slot 0. Subsequently, a number of the unit tests
failed because `baseQueue.mu.disabled` is now true instead
of previously, false.

The change in this PR fixes the bug by registering a fresh dummy
`BoolSetting`. We also rename `disabledConfig` to match the polarity
used in conjunction with `bq.SetDisabled`.

[1] cockroachdb#104170
[2] cockroachdb#113113

Epic: none

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

Labels

backport-23.1.x PAST MAINTENANCE SUPPORT: 23.1 patch releases via ER request only backport-23.2.x PAST MAINTENANCE SUPPORT: 23.2 patch releases via ER request only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants