Skip to content

Commit

Permalink
Merge pull request #20 from esseivaju/next
Browse files Browse the repository at this point in the history
fixed url and use-https=False issues
  • Loading branch information
PalNilsson authored Mar 7, 2022
2 parents 2f43636 + ccada82 commit d50678d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
12 changes: 5 additions & 7 deletions pilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
SERVER_UPDATE_NOT_DONE, PILOT_MULTIJOB_START_TIME
from pilot.util.filehandling import get_pilot_work_dir, mkdirs, establish_logging
from pilot.util.harvester import is_harvester_mode
from pilot.util.https import https_setup, send_update
from pilot.util.https import get_panda_server, https_setup, send_update
from pilot.util.timing import add_to_pilot_timing

errors = ErrorCodes()
Expand Down Expand Up @@ -452,9 +452,7 @@ def set_environment_variables():
environ['PILOT_OUTPUT_DIR'] = args.output_dir

# keep track of the server urls
_port = ":%s" % args.port
url = args.url if _port in args.url else args.url + _port
environ['PANDA_SERVER_URL'] = url
environ['PANDA_SERVER_URL'] = get_panda_server(args.url, args.port)
environ['QUEUEDATA_SERVER_URL'] = '%s' % args.queuedata_url


Expand Down Expand Up @@ -582,12 +580,12 @@ def send_worker_status(status, queue, url, port, logger):
if exit_code != 0:
sys.exit(exit_code)

# set environment variables (to be replaced with singleton implementation)
set_environment_variables()

# setup and establish standard logging
establish_logging(debug=args.debug, nopilotlog=args.nopilotlog)

# set environment variables (to be replaced with singleton implementation)
set_environment_variables()

# execute main function
trace = main()

Expand Down
35 changes: 27 additions & 8 deletions pilot/util/https.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
logger = logging.getLogger(__name__)

_ctx = namedtuple('_ctx', 'ssl_context user_agent capath cacert')
_ctx.ssl_context = None
_ctx.user_agent = None
_ctx.capath = None
_ctx.cacert = None

# anisyonk: public copy of `_ctx` to avoid logic break since ssl_context is reset inside the request() -- FIXME
# anisyonk: public instance, should be properly initialized by `https_setup()`
Expand Down Expand Up @@ -399,16 +403,31 @@ def get_panda_server(url, port):
:return: full URL (either from pilot options or from config file)
"""

if url.startswith('https://'):
url = url.replace('https://', '')

if url != '' and port != 0:
pandaserver = '%s:%s' % (url, port) if ":" not in url else url
if url != '':
parsedurl = url.split('://')
scheme = None
loc = None
if len(parsedurl) == 2:
scheme = parsedurl[0]
loc = parsedurl[1]
else:
loc = parsedurl[0]

parsedloc = loc.split(':')
loc = parsedloc[0]

# if a port is provided in the url, then override the port argument
if len(parsedloc) == 2:
port = parsedloc[1]
# default scheme to https
if not scheme:
scheme = "https"
portstr = f":{port}" if port else ""
pandaserver = f"{scheme}://{loc}{portstr}"
else:
pandaserver = config.Pilot.pandaserver

if not pandaserver.startswith('http'):
pandaserver = 'https://' + pandaserver
if not pandaserver.startswith('http'):
pandaserver = 'https://' + pandaserver

# add randomization for PanDA server
default = 'pandaserver.cern.ch'
Expand Down

0 comments on commit d50678d

Please sign in to comment.