From 2ab1de180c993c240038e379571f57e5ebad8c53 Mon Sep 17 00:00:00 2001 From: Amit Srivastava Date: Sun, 8 Oct 2023 13:41:11 -0700 Subject: [PATCH] [beeswax][compute] set username for computes/hive connection The regular beeswax/hive connections set `hive.server2.proxy.user` to the current username but it was missing for the compute based connections. This commit adds a flag `is_compute` to query_server_config for compute/connector based configs. Impala based connections were already setting the correct usernames on the connection. Change-Id: I23521a5c1cf3d650da551b343d18820862feb7c5 --- apps/beeswax/src/beeswax/server/dbms.py | 1 + apps/beeswax/src/beeswax/server/hive_server2_lib.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/beeswax/src/beeswax/server/dbms.py b/apps/beeswax/src/beeswax/server/dbms.py index 10b3ff5a9b4..9df06819c6d 100644 --- a/apps/beeswax/src/beeswax/server/dbms.py +++ b/apps/beeswax/src/beeswax/server/dbms.py @@ -331,6 +331,7 @@ def get_query_server_config_via_connector(connector): impersonation_enabled = hiveserver2_impersonation_enabled() return { + 'is_compute': True, 'dialect': compute['dialect'], 'server_name': compute_name, 'server_host': server_host, diff --git a/apps/beeswax/src/beeswax/server/hive_server2_lib.py b/apps/beeswax/src/beeswax/server/hive_server2_lib.py index c95a51c91fc..08116de7e49 100644 --- a/apps/beeswax/src/beeswax/server/hive_server2_lib.py +++ b/apps/beeswax/src/beeswax/server/hive_server2_lib.py @@ -678,7 +678,8 @@ def open_session(self, user): if self.query_server.get('dialect') == 'impala': # Only when Impala accepts it kwargs['configuration'].update({'impala.doas.user': user.username}) - if self.query_server['server_name'] == 'beeswax': # All the time + if self.query_server['server_name'] == 'beeswax' or \ + (self.query_server.get('is_compute') and self.query_server.get('dialect') == 'hive'): kwargs['configuration'].update({'hive.server2.proxy.user': user.username}) xff_header = json.loads(user.userprofile.json_data).get('X-Forwarded-For', None) if xff_header and ENABLE_XFF_FOR_HIVE_IMPALA.get():