Skip to content

Commit

Permalink
Add startup flag, --incompatible_enable_execution_transition, which w…
Browse files Browse the repository at this point in the history
…ill enable incremental migration of host attributes to exec attributes.

This has to be a startup flag because it will influence rule creation. Changing this flag will completely restart the Blaze server.

Part of work on execution transitions, bazelbuild#7935.

RELNOTES: Adds --incompatible_enable_execution_transition, which enables incremental migration of host attributes to exec attributes.
PiperOrigin-RevId: 256990772
  • Loading branch information
katre authored and irengrig committed Jul 15, 2019
1 parent de14e6b commit 59db663
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/main/cpp/bazel_startup_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,9 @@ void BazelStartupOptions::MaybeLogStartupOptionWarnings() const {
}
}

void BazelStartupOptions::AddExtraOptions(
std::vector<std::string> *result) const {
StartupOptions::AddExtraOptions(result);
}

} // namespace blaze
2 changes: 2 additions & 0 deletions src/main/cpp/bazel_startup_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class BazelStartupOptions : public StartupOptions {
public:
explicit BazelStartupOptions(const WorkspaceLayout *workspace_layout);

void AddExtraOptions(std::vector<std::string> *result) const override;

blaze_exit_code::ExitCode ProcessArgExtra(
const char *arg, const char *next_arg, const std::string &rcfile,
const char **value, bool *is_processed, std::string *error) override;
Expand Down
20 changes: 18 additions & 2 deletions src/main/cpp/startup_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ StartupOptions::StartupOptions(const string &product_name,
#if defined(__APPLE__)
macos_qos_class(QOS_CLASS_DEFAULT),
#endif
unlimit_coredumps(false) {
unlimit_coredumps(false),
incompatible_enable_execution_transition(false) {
if (blaze::IsRunningWithinTest()) {
output_root = blaze_util::MakeAbsolute(blaze::GetPathEnv("TEST_TMPDIR"));
max_idle_secs = 15;
Expand Down Expand Up @@ -140,6 +141,7 @@ StartupOptions::StartupOptions(const string &product_name,
RegisterNullaryStartupFlag("fatal_event_bus_exceptions");
RegisterNullaryStartupFlag("host_jvm_debug");
RegisterNullaryStartupFlag("idle_server_tasks");
RegisterNullaryStartupFlag("incompatible_enable_execution_transition");
RegisterNullaryStartupFlag("shutdown_on_low_sys_mem");
RegisterNullaryStartupFlag("ignore_all_rc_files");
RegisterNullaryStartupFlag("unlimit_coredumps");
Expand Down Expand Up @@ -188,7 +190,13 @@ bool StartupOptions::IsUnary(const string& arg) const {
return false;
}

void StartupOptions::AddExtraOptions(vector<string> *result) const {}
void StartupOptions::AddExtraOptions(vector<string> *result) const {
if (incompatible_enable_execution_transition) {
result->push_back("--incompatible_enable_execution_transition");
} else {
result->push_back("--noincompatible_enable_execution_transition");
}
}

blaze_exit_code::ExitCode StartupOptions::ProcessArg(
const string &argstr, const string &next_argstr, const string &rcfile,
Expand Down Expand Up @@ -423,6 +431,14 @@ blaze_exit_code::ExitCode StartupOptions::ProcessArg(
} else if (GetNullaryOption(arg, "--nounlimit_coredumps")) {
unlimit_coredumps = false;
option_sources["unlimit_coredumps"] = rcfile;
} else if (GetNullaryOption(arg,
"--incompatible_enable_execution_transition")) {
incompatible_enable_execution_transition = true;
option_sources["incompatible_enable_execution_transition"] = rcfile;
} else if (GetNullaryOption(arg,
"--noincompatible_enable_execution_transition")) {
incompatible_enable_execution_transition = false;
option_sources["incompatible_enable_execution_transition"] = rcfile;
} else {
bool extra_argument_processed;
blaze_exit_code::ExitCode process_extra_arg_exit_code = ProcessArgExtra(
Expand Down
5 changes: 5 additions & 0 deletions src/main/cpp/startup_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ class StartupOptions {
// Whether to raise the soft coredump limit to the hard one or not.
bool unlimit_coredumps;

// Whether the execution transition is enabled, or behaves like a host
// transition. This must be set before rule classes are constructed.
// See https://github.com/bazelbuild/bazel/issues/7935
bool incompatible_enable_execution_transition;

protected:
// Constructor for subclasses only so that site-specific extensions of this
// class can override the product name. The product_name must be the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,16 @@ public String getTypeDescription() {
+ "can be shared among them without changes. Possible values are: user-interactive, "
+ "user-initiated, default, utility, and background.")
public String macosQosClass;

@Option(
name = "incompatible_enable_execution_transition",
defaultValue = "false", // Only for documentation; value is set by the client.
documentationCategory = OptionDocumentationCategory.TOOLCHAIN,
effectTags = {OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help = "If false, the execution transition behaves like the host transition.")
public boolean enableExecutionTransition;
}
7 changes: 4 additions & 3 deletions src/test/cpp/bazel_startup_options_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ TEST_F(BazelStartupOptionsTest, ValidStartupFlags) {
ExpectIsNullaryOption(options, "fatal_event_bus_exceptions");
ExpectIsNullaryOption(options, "home_rc");
ExpectIsNullaryOption(options, "host_jvm_debug");
ExpectIsNullaryOption(options, "shutdown_on_low_sys_mem");
ExpectIsNullaryOption(options, "ignore_all_rc_files");
ExpectIsNullaryOption(options, "incompatible_enable_execution_transition");
ExpectIsNullaryOption(options, "master_bazelrc");
ExpectIsNullaryOption(options, "shutdown_on_low_sys_mem");
ExpectIsNullaryOption(options, "system_rc");
ExpectIsNullaryOption(options, "watchfs");
ExpectIsNullaryOption(options, "workspace_rc");
Expand All @@ -99,16 +100,16 @@ TEST_F(BazelStartupOptionsTest, ValidStartupFlags) {
ExpectIsUnaryOption(options, "connect_timeout_secs");
ExpectIsUnaryOption(options, "digest_function");
ExpectIsUnaryOption(options, "experimental_oom_more_eagerly_threshold");
ExpectIsUnaryOption(options, "server_javabase");
ExpectIsUnaryOption(options, "host_jvm_args");
ExpectIsUnaryOption(options, "host_jvm_profile");
ExpectIsUnaryOption(options, "install_base");
ExpectIsUnaryOption(options, "invocation_policy");
ExpectIsUnaryOption(options, "io_nice_level");
ExpectIsUnaryOption(options, "install_base");
ExpectIsUnaryOption(options, "macos_qos_class");
ExpectIsUnaryOption(options, "max_idle_secs");
ExpectIsUnaryOption(options, "output_base");
ExpectIsUnaryOption(options, "output_user_root");
ExpectIsUnaryOption(options, "server_javabase");
}

TEST_F(BazelStartupOptionsTest, BlazercFlagsAreNotAccepted) {
Expand Down

0 comments on commit 59db663

Please sign in to comment.