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

Emit events when invocation policy overrides options #17042

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

illicitonion
Copy link
Contributor

Prior to this commit, messages were only logged to the server log indicating that user input was being ignored. This is a place users don't tend to look (or even know about) when debugging issues.

With this commit, we still log there, but additionally emit events to the console, which users are much more likely to notice.

Example output:

% bazel --invocation_policy='flag_policies { flag_name: "test_env" set_value { flag_value: "SET_FROM_FLAG=by-policy" behavior: FINAL_VALUE_IGNORE_OVERRIDES } }' test :test --test_env=SET_FROM_FLAG=from-flag
WARNING: Setting value for option '--test_env' from invocation policy to 'SET_FROM_FLAG=by-policy', overriding value '[SET_FROM_FLAG=from-bazelrc, SET_FROM_FLAG=from-flag]' from '/path/to/.bazelrc, command line options'
INFO: Invocation ID: bdfa6f27-a7d8-4b2b-9b45-f2f4b1f905fc
...

@illicitonion
Copy link
Contributor Author

/cc @michajlo

@sgowroji sgowroji added team-Core Skyframe, bazel query, BEP, options parsing, bazelrc awaiting-user-response Awaiting a response from the author labels Dec 17, 2022
Prior to this commit, messages were only logged to the server log
indicating that user input was being ignored. This is a place users
don't tend to look (or even know about) when debugging issues.

With this commit, we still log there, but additionally emit events to
the console, which users are much more likely to notice.

Example output:
```console
% bazel --invocation_policy='flag_policies { flag_name: "test_env" set_value { flag_value: "SET_FROM_FLAG=by-policy" behavior: FINAL_VALUE_IGNORE_OVERRIDES } }' test :test --test_env=SET_FROM_FLAG=from-flag
WARNING: Setting value for option '--test_env' from invocation policy to 'SET_FROM_FLAG=by-policy', overriding value '[SET_FROM_FLAG=from-bazelrc, SET_FROM_FLAG=from-flag]' from '/path/to/.bazelrc, command line options'
INFO: Invocation ID: bdfa6f27-a7d8-4b2b-9b45-f2f4b1f905fc
...
```
@michajlo
Copy link
Contributor

We're probably going to need to make the console logging optional. While I agree it's useful, the incumbent is silence, and I strongly suspect that some % of users will see the new logging as spam.

That said, I think we should come up with an end-to-end story on #16997 before submitting things, this way if we change our mind or find something we overlooked our hands aren't tied.

@illicitonion
Copy link
Contributor Author

We're probably going to need to make the console logging optional. While I agree it's useful, the incumbent is silence, and I strongly suspect that some % of users will see the new logging as spam.

I added a flag to hide this, but I defaulted it to show - I do think it's important that if Bazel is going to ignore explicit input you give it, by default it should verbosely tell you at least that it's doing so, and ideally also why.

That said, I think we should come up with an end-to-end story on #16997 before submitting things, this way if we change our mind or find something we overlooked our hands aren't tied.

I'm not sure I agree about that - I think that this is a useful standalone feature, whether or not it's used for default-setting - the use-cases are orthogonal. Telling a user that you're ignoring their input is an important feature, and I'd consider it a pretty serious UX bug of --invocation_policy not to currently be doing so by default.

@sgowroji sgowroji added awaiting-review PR is awaiting review from an assigned reviewer and removed awaiting-user-response Awaiting a response from the author labels Dec 22, 2022
@michajlo
Copy link
Contributor

michajlo commented Feb 7, 2023

I generally agree with the UX concerns, and have lobbied for the same in the past. However, I've also come to recognize that the system(s) using invocation policy internally can't start throwing warnings at users without some prior cleanup work. We can flag it off internally, but that will take some effort for myself or whoever does the import, which is part of the reason I'd like to have an end-to-end story, allowing us to batch this and whatever internal adjustments we must make. On the other hand, if this effort to extend invocation policy fizzles out, I'd prefer to not have lingering ~unused flags and wasted effort.

@illicitonion
Copy link
Contributor Author

Something that occurred to me - maybe we could add this to the proto rather than as a flag? That way we don't add to the flag proliferation, and we let the policy definer choose how important it is that someone knows what's happening?

Either we could add a new top-level field on InvocationPolicy of type:

enum OverrideBehaviour {
  UNDEFINED = 0;
  QUIET = 1;
  WARN = 2;
  ERROR = 3;
}

Or we could add some new Behavior variants:

FINAL_VALUE_IGNORE_AND_WARN_ON_OVERRIDES = 4;
FINAL_VALUE_IGNORE_AND_ERROR_ON_OVERRIDES = 5;

which act the same as FINAL_VALUE_IGNORE_OVERRIDES but with extra logging changes.

Would either of those approaches help to make this change more palatable @michajlo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review PR is awaiting review from an assigned reviewer team-Core Skyframe, bazel query, BEP, options parsing, bazelrc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants