Skip to content

Commit

Permalink
[idbroker] Improve IDBroker integration performance and add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Harshg999 committed Mar 1, 2024
1 parent 96ba906 commit 1c6c54b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
5 changes: 2 additions & 3 deletions desktop/core/src/desktop/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2623,9 +2623,8 @@ def is_cm_managed():
def is_gs_enabled():
from desktop.lib.idbroker import conf as conf_idbroker # Circular dependencies desktop.conf -> idbroker.conf -> desktop.conf

return ('default' in list(GC_ACCOUNTS.keys()) and GC_ACCOUNTS['default'].JSON_CREDENTIALS.get()) or \
conf_idbroker.is_idbroker_enabled('gs') or \
is_raz_gs()
return ('default' in list(GC_ACCOUNTS.keys()) and GC_ACCOUNTS['default'].JSON_CREDENTIALS.get()) or is_raz_gs() or \
conf_idbroker.is_idbroker_enabled('gs')

def has_gs_access(user):
from desktop.auth.backend import is_admin
Expand Down
7 changes: 6 additions & 1 deletion desktop/core/src/desktop/lib/idbroker/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@ def _handle_idbroker_ha(fs=None):
try:
response = requests.get(id_broker_addr.rstrip('/') + '/dt/knoxtoken/api/v1/token', auth=HTTPKerberosAuth(), verify=False)
except Exception as e:
LOG.debug('64: printing idbroker response exception --------------->>>')
LOG.debug(str(e))

if 'Name or service not known' in str(e) or 'Failed to establish a new connection' in str(e):
LOG.warn('IDBroker %s is not available for use' % id_broker_addr)
LOG.debug('Not connecting to IDbroker check ------------>>>')

# Check response for None and if response code is successful (200) or authentication needed (401)
if (response is not None) and (response.status_code in (200, 401)):
idbrokeraddr = id_broker_addr
LOG.debug('71: Return idbroker url -------->>>' + idbrokeraddr)
break

return idbrokeraddr
Expand All @@ -94,7 +98,8 @@ def get_cab_password(fs=None):
def is_idbroker_enabled(fs=None):
from desktop.conf import RAZ # Must be imported dynamically in order to have proper value

return get_cab_address(fs) is not None and not RAZ.IS_ENABLED.get() # Skipping IDBroker for FS when RAZ is present
return (not RAZ.IS_ENABLED.get() and get_cab_address(fs) is not None) # Skipping IDBroker for FS when RAZ is present
# return get_cab_address(fs) is not None and not RAZ.IS_ENABLED.get()

def config_validator():
res = []
Expand Down
4 changes: 2 additions & 2 deletions desktop/libs/aws/src/aws/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ def get_default_get_environment_credentials():
def is_enabled():
return ('default' in list(AWS_ACCOUNTS.keys()) and AWS_ACCOUNTS['default'].get_raw() and AWS_ACCOUNTS['default'].ACCESS_KEY_ID.get()) or \
has_iam_metadata() or \
conf_idbroker.is_idbroker_enabled('s3a') or \
is_raz_s3()
is_raz_s3() or \
conf_idbroker.is_idbroker_enabled('s3a')


def is_ec2_instance():
Expand Down
6 changes: 3 additions & 3 deletions desktop/libs/azure/src/azure/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ def is_adls_enabled():
or (conf_idbroker.is_idbroker_enabled('azure') and has_azure_metadata())) and 'default' in list(ADLS_CLUSTERS.keys())

def is_abfs_enabled():
return ('default' in list(AZURE_ACCOUNTS.keys()) and AZURE_ACCOUNTS['default'].get_raw() and AZURE_ACCOUNTS['default'].CLIENT_ID.get() \
or (conf_idbroker.is_idbroker_enabled('azure') and has_azure_metadata())) and 'default' in list(ABFS_CLUSTERS.keys()) \
or is_raz_abfs()
return is_raz_abfs() or \
('default' in list(AZURE_ACCOUNTS.keys()) and AZURE_ACCOUNTS['default'].get_raw() and AZURE_ACCOUNTS['default'].CLIENT_ID.get() or \
(conf_idbroker.is_idbroker_enabled('azure') and has_azure_metadata())) and 'default' in list(ABFS_CLUSTERS.keys())

def has_adls_access(user):
from desktop.conf import RAZ # Must be imported dynamically in order to have proper value
Expand Down

0 comments on commit 1c6c54b

Please sign in to comment.