Repository navigation
Conversation
hive.server2.enable.doAs is accepted and HiveSessionProxy does impersonate the connecting user for metastore calls, but queries and the storage access they perform run as the service identity (SPARK-5159), so storage ACLs are checked against the wrong principal. Warn at startup rather than look like we enforce something we do not. Warn rather than refuse, because refusing breaks deployments that have been accepted for years and this is a minor release. Spark 5.0 refuses instead and adds an escape-hatch conf, which the message points at. The warning does not tell operators to just set doAs=false: that also drops metastore impersonation, so it is not a no-op. Auth types that never establish a user identity have nothing to impersonate, so NONE and NOSASL stay quiet -- which is also the stock Hive config, since Hive defaults doAs to true. Co-Authored-By: Claude Sonnet 5 <[email protected]> Co-authored-by: Holden Karau <[email protected]>
HyukjinKwon
left a comment
There was a problem hiding this comment.
0 blocking, 2 non-blocking, 0 nits.
Clean, well-tested backport with no production-behavior defects. The auth-vs-doAs guard is correctly null-safe and the new suite covers both inverting config axes. Two non-blocking points remain: uros-b's existing note that the warning hardcodes the not-yet-merged 5.0 config name, and a stale 'user-facing change' field in the PR description.
Already raised in existing discussion (1)
- The warning hardcodes the config name spark.sql.hive.thriftServer.allowIneffectiveDoAs, which does not exist on 4.x -- it is the Spark 5.0 opt-out from SPARK-58414. A maintenance-branch message that names an unmerged config can drift silently: if the 5.0 config lands under a different name, this 4.x warning keeps pointing users at a name that never shipped, and nothing here fails when that happens. Since 4.x cannot reference the (nonexistent) config constant, the more robust option is to not name the specific future config in this branch -- e.g. drop the final sentence, or point to the migration guide / SPARK-59118 -- so the 4.x text cannot go stale independently of 5.0. -- existing discussion
Design / architecture (1)
- General: The PR description's "Does this PR introduce any user-facing change?" answer reads "Explicit error unless config flag is disabled", but this 4.x change only emits a startup warning and adds no config flag -- the explicit-error/opt-out behavior is the Spark 5.0 behavior that the warning text itself points to. The answer looks copied from the master PR (SPARK-58414) and would generate an inaccurate release note. Please update it to describe the actual user-facing change: a new startup warning when hive.server2.enable.doAs is enabled under an authenticating auth type.
Verification
Independently confirmed: the auth comparison is null-safe (constant-on-left equalsIgnoreCase, so an explicitly-emptied auth conf does not NPE); NONE/NOSASL are the only exempted auth types; init is the sole production caller of the helper and is reached from startWithSparkSession; no production subclass overrides init; and the new suite exercises both inverting axes (doAs on/off, verifying vs non-verifying auth) plus untouched and unrecognized configs. All changed lines are within 100 chars and the text/contract/efficiency scanners returned no findings.
HyukjinKwon
left a comment
There was a problem hiding this comment.
One follow-up on the doAs warning for the maintenance branch (see inline).
| // Constant on the left: authType is null when explicitly set empty, and this must not NPE. | ||
| val authVerifiesUser = !unverifiedAuthTypes.exists(_.equalsIgnoreCase(authType)) | ||
| if (authVerifiesUser && hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS)) { | ||
| logWarning(log"${MDC(CONFIG, ConfVars.HIVE_SERVER2_ENABLE_DOAS.varname)} is set to true, " + |
There was a problem hiding this comment.
Warn-only is the right call for a maintenance branch -- it surfaces the SPARK-5159 impersonation gap without breaking servers that are running today, and pointing at the 5.0 escape hatch (allowIneffectiveDoAs) in the message is a nice touch. One fix: the PR description still answers the user-facing-change question with "Explicit error unless config flag is disabled" (copied from #58414), but this variant only logs a warning and never fails startup -- please update it so the 4.x behavior isn't misread as a hard failure.
|
Good point updated the PR description |
…de wording Co-authored-by: Cursor <[email protected]>
|
Thank you for making a softer version for Since this is the
Also, the warning message is quite long for a single log line. It might be better to keep it concise and move the details to the migration guide. |
|
Yup I'll update this one shortly since it seems like we've largely settled on the master/5.X version :) |
|
BTW, for |
…e silenced The warning told operators to set spark.sql.hive.thriftServer.allowIneffectiveDoAs=true, but nothing defined that conf: an unknown spark.sql.* key is accepted silently, so following the advice did nothing and the operator got no feedback either way. Worse, the name ships in a released binary, so if 5.0 lands the gate under a different name the log line points at a key that never existed. Define it here and honor it today. Setting it acknowledges the limitation and silences the warning; 5.0 is expected to refuse to start on the same configuration unless it is set, so the key an operator sets now carries forward. Versioned 4.3.0 -- it ships in 4.3.0 via RC2, not in the 4.3.1 that branch-4.3's pom currently reads between RCs. Also test that init() actually emits the warning, since deleting the call left every unit test green, and that the warning names the conf that silences it -- which is what would have caught the missing conf. Operation logging is off in that test: init() boots Hive's service graph, and OperationManager.init attaches an appender to the root logger that nothing ever removes. Co-authored-by: Holden Karau <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
I'm going back and forth on if the config flag is worth it since it would just gate a warning but it does let people proactively see how to opt out of enforcement. |
|
Moved to draft while I update it based on the master approved one |
…JVM logging state CI runs the hive-thriftserver module in a single forked JVM (SERIAL_SBT_TESTS=1 disables the dedicated-JVM test grouping), so SparkExecuteStatementOperationSuite's init test ran in the same JVM as HiveThriftServer2DoAsSuite. The init test attached an appender to the HiveThriftServer2 logger by name; log4j2's addLoggerAppender permanently registers an exact-name LoggerConfig for it, copying the root config's additivity (false). Cleanup removes the appender but not the LoggerConfig, so every later event from that logger was swallowed - never reaching the console or any root-attached appender - and the doAs suite's log-capture assertions failed. Two changes: - Split warnIfIneffectiveDoAs into ineffectiveDoAsWarning, which returns the warning as an Option[LogEntry], and a one-line wrapper that logs it. The doAs suite now asserts on the returned entry instead of capturing log output, mirroring how the master version asserts on the thrown exception. - The init test attaches its appender to the root logger instead of the named logger, so it no longer leaves the non-additive LoggerConfig behind. It still covers end-to-end emission through init(). Co-authored-by: Cursor <[email protected]> Co-Authored-By: Holden Karau <[email protected]>
|
the master pr is merged, is this one ready to go? |
Co-authored-by: Isaac <[email protected]>
This change missed 4.3.0: neither 4.3.0-rc2 nor 4.3.0-rc3 includes it, and branch-4.x is the 4.4.0 line. Version spark.sql.hive.thriftServer.allowIneffectiveDoAs 4.4.0 and move the migration note to the 4.3 to 4.4 section, matching the master guide's "Spark 4.4 logs a warning for the same configuration". Co-authored-by: Isaac <[email protected]>
|
@holdenk I pushed two commits to retarget this at 4.4. It missed 4.3.0: neither 4.3.0-rc2 nor 4.3.0-rc3 includes it, and branch-4.x is now the 4.4.0 line.
No code or test changes; the PR still touches the same 5 files. I also fixed the user-facing-change line in the PR description, which said the warning is silenced by disabling a flag; it is silenced by setting After this merges, master needs a one-line follow-up to change the same conf's |
|
Yeah 4.4.0 makes sense |
|
tests actually passed, thanks, merging to 4.x! |
### What changes were proposed in this pull request? This is a softer follow on of #58414 for 4.X branch which warns when doAs is enabled but not enforced. We should log rather than fail a previously running job. ### Why are the changes needed? People might expect doAs to run as a different user, which is not supported. ### Does this PR introduce _any_ user-facing change? The Spark Thrift Server logs a startup warning when `hive.server2.enable.doAs` is enabled with an authenticating auth type, unless the new static conf `spark.sql.hive.thriftServer.allowIneffectiveDoAs` is set to `true`. ### How was this patch tested? New unit test. ### Was this patch authored or co-authored using generative AI tooling? Yes, claude Closes #58438 from holdenk/SPARK-59118-doAs-warn-4.x-r2. Lead-authored-by: Holden Karau <[email protected]> Co-authored-by: Holden Karau <[email protected]> Co-authored-by: Wenchen Fan <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
|
Merge Summary:
Posted by |
….4 migration note with branch-4.x ### What changes were proposed in this pull request? A follow-up to #58414, now that its `branch-4.x` backport #58438 has shipped `spark.sql.hive.thriftServer.allowIneffectiveDoAs` in 4.4.0 (as a warn-only gate): - Change the conf's `.version("5.0.0")` to `.version("4.4.0")`, since 4.4.0 is the first release with this key. - Add the backport's 4.4 migration note to the "Upgrading from Spark SQL 4.3 to 4.4" section, at the same position as on `branch-4.x`. That section is otherwise identical between `master` and `branch-4.x`, and the 5.0 note added by #58414 already says "Spark 4.4 logs a warning for the same configuration." ### Why are the changes needed? A conf's version should record the first release that has it, and master's 4.3 to 4.4 migration section should match `branch-4.x`'s. ### Does this PR introduce _any_ user-facing change? No. Behavior is unchanged; the generated conf docs list the conf as available since 4.4.0 instead of 5.0.0. ### How was this patch tested? No new tests: the change is a version string and one documentation line. Checked that master's "Upgrading from Spark SQL 4.3 to 4.4" section is now identical to `branch-4.x`'s. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Isaac (Claude Opus 5.5) This pull request and its description were written by Isaac. Closes #59831 from cloud-fan/wenchen/spark-59118-doas-version-4.4. Authored-by: Wenchen Fan <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
What changes were proposed in this pull request?
This is a softer follow on of #58414 for 4.X branch which warns when doAs is enabled but not enforced. We should log rather than fail a previously running job.
Why are the changes needed?
People might expect doAs to run as a different user, which is not supported.
Does this PR introduce any user-facing change?
The Spark Thrift Server logs a startup warning when
hive.server2.enable.doAsis enabled with an authenticating auth type, unless the new static confspark.sql.hive.thriftServer.allowIneffectiveDoAsis set totrue.How was this patch tested?
New unit test.
Was this patch authored or co-authored using generative AI tooling?
Yes, claude