You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ya...@apache.org on 2024/07/01 11:49:49 UTC

(spark) branch master updated: [SPARK-48765][DEPLOY] Enhance default value evaluation for SPARK_IDENT_STRING

This is an automated email from the ASF dual-hosted git repository.

yangjie01 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new bc16b24c7a32 [SPARK-48765][DEPLOY] Enhance default value evaluation for SPARK_IDENT_STRING
bc16b24c7a32 is described below

commit bc16b24c7a328cf103b003b1c4a5cf16832cf2bd
Author: Cheng Pan <ch...@apache.org>
AuthorDate: Mon Jul 1 19:49:31 2024 +0800

    [SPARK-48765][DEPLOY] Enhance default value evaluation for SPARK_IDENT_STRING
    
    ### What changes were proposed in this pull request?
    
    This PR follows Hadoop[1] to enhance the `SPARK_IDENT_STRING` default value evaluation.
    
    [1] https://github.com/apache/hadoop/blob/rel/release-3.4.0/hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh#L893-L896
    
    ### Why are the changes needed?
    
    I found in some cases, `$USER` is not available, thus the auto-generated log and pid file names are strange.
    
    For example, there is no `$USER` when login to docker
    ```
    $ docker run -t -i ubuntu:latest
    root1dbeaefd6cd4:/# echo $USER
    
    root1dbeaefd6cd4:/# id -nu
    root
    root1dbeaefd6cd4:/# exit
    ```
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes, affects log/pid file names.
    
    ### How was this patch tested?
    
    Manually tested.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No
    
    Closes #47160 from pan3793/SPARK-48765.
    
    Authored-by: Cheng Pan <ch...@apache.org>
    Signed-off-by: yangjie01 <ya...@baidu.com>
---
 sbin/spark-daemon.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sbin/spark-daemon.sh b/sbin/spark-daemon.sh
index 28d205f03e0f..b7233e6e9bf3 100755
--- a/sbin/spark-daemon.sh
+++ b/sbin/spark-daemon.sh
@@ -98,6 +98,10 @@ spark_rotate_log ()
 . "${SPARK_HOME}/bin/load-spark-env.sh"
 
 if [ "$SPARK_IDENT_STRING" = "" ]; then
+  # if for some reason the shell doesn't have $USER defined
+  # (e.g., ssh'd in to execute a command)
+  # let's get the effective username and use that
+  USER=${USER:-$(id -nu)}
   export SPARK_IDENT_STRING="$USER"
 fi
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org