Skip to content

Commit

Permalink
Merge pull request #97 from efajardo/el8compat
Browse files Browse the repository at this point in the history
More fixes for EL8 compatibility (SOFTWARE-4196)
  • Loading branch information
efajardo authored Aug 4, 2020
2 parents 65ed85f + d07440f commit 38d7bfc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
13 changes: 11 additions & 2 deletions rpm/xcache.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: xcache
Summary: XCache scripts and configurations
Version: 1.5.0
Version: 1.5.1
Release: 1%{?dist}
License: Apache 2.0
Group: Grid
Expand All @@ -20,8 +20,14 @@ BuildRequires: systemd
%{?systemd_requires}

# Necessary for daemon to report back to the OSG Collector.
%if 0%{?rhel} >= 8
Requires: python3-condor
Requires: python3-xrootd
%else
Requires: condor-python
Requires: python-xrootd
%endif

Requires: voms-clients-cpp

# We utilize a configuration directive (`continue`) introduced in XRootD 4.9.
Expand All @@ -39,7 +45,7 @@ Provides: stashcache-daemon = %{name}-%{version}
Obsoletes: stashcache-daemon < 1.0.0

%if 0%{?rhel} >= 8
%define __python /usr/bin/python2
%define __python /usr/bin/python3
%endif

%description
Expand Down Expand Up @@ -285,6 +291,9 @@ mkdir -p %{buildroot}%{_sysconfdir}/grid-security/xrd
%config %{_sysconfdir}/xrootd/config.d/03-redir-tuning.cfg

%changelog
* Fri Jul 30 2020 Edgar Fajardo <[email protected]> - 1.5.1-1
- Fixing some bugs for el8 suppport (SOFTWARE-4158)

* Mon Jul 27 2020 Edgar Fajardo <[email protected]> - 1.5.0-1
- Adding support for el8 installation (SOFTWARE-4158)
- Added SciTokens support (SOFTWARE-3562)
Expand Down
24 changes: 13 additions & 11 deletions src/xrootd_cache_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
import time
import errno
import struct
import urlparse
import collections

import six
from six.moves import urllib

import classad
import XRootD.client

Expand Down Expand Up @@ -62,11 +64,11 @@ def scan_cache_dirs(rootdir):
vo_name = os.path.join('/', *path_components)
try:
results[vo_name] = scan_vo_dir(os.path.join(dirpath, name))
except (OSError, IOError), ex:
except (OSError, IOError) as ex:
results[vo_name] = {'scan_vo_dir_error': str(ex) }
dirnames.remove(name)
return results
except (OSError, IOError), ex:
except (OSError, IOError) as ex:
return { 'scan_cache_dirs_error' : { 'message' : str(ex) } } # error message?


Expand All @@ -87,20 +89,20 @@ def scan_vo_dir(vodir):
for f, cinfo in ((f, f + '.cinfo') for f in fnames if f + '.cinfo' in fnames):
try:
st = os.stat(os.path.join(root, f))
except OSError, ex:
except OSError as ex:
if ex.errno == errno.ENOENT:
# must have just been deleted
continue
else: raise
try:
access_info = read_cinfo(os.path.join(root, cinfo), now)
except OSError, ex:
except OSError as ex:
if ex.errno == errno.ENOENT:
continue
else:
bad_cinfo_files += 1
access_info = { "naccesses" : 0, "last_access": 0, "by_hour" : {} }
except ReadCInfoError, ex:
except ReadCInfoError as ex:
bad_cinfo_files += 1
access_info = ex.access_info

Expand Down Expand Up @@ -231,7 +233,7 @@ def read_cinfo(cinfo_file, now):
for interval in intervals:
result["by_hour"][interval] += 1
result["bytes_hr"][interval] += bytes_disk + bytes_ram
except struct.error, ex:
except struct.error as ex:
# return what we've got
raise ReadCInfoError("%s unable to decode access time data: %s" % (cinfo_file, str(ex)), result)

Expand Down Expand Up @@ -261,7 +263,7 @@ def test_xrootd_server(url):

return result

except Exception, ex: # more specific exception would be better
except Exception as ex: # more specific exception would be better
return {"ping_response_status" : "failed", "ping_response_code" : -1,
"ping_response_message" : str(ex), "ping_elapsed_time" : 0.0}

Expand All @@ -280,15 +282,15 @@ def get_cache_info(rootdir, cache_max_fs_fraction):
result['free_cache_fraction'] = 1 - float(stat.f_blocks-stat.f_bfree)/int(stat.f_blocks*cache_max_fs_fraction)

return result
except (OSError, IOError), ex:
except (OSError, IOError) as ex:
return {}


def collect_cache_stats(url, rootdir, cache_max_fs_fraction=1.0):
""" Collect stats on the cache server """
start_time = time.time()

parsed_url = urlparse.urlparse(url)
parsed_url = urllib.parse.urlparse(url)

# Python 2.6's urlparse returns a ParseResult object whereas
# Python 2.4's urlparse returns a tuple that doesn't handle
Expand Down Expand Up @@ -340,4 +342,4 @@ def collect_cache_stats(url, rootdir, cache_max_fs_fraction=1.0):
args[2] = float(args[2])
elif len(args) == 2:
args.append(0.99) # max cache fraction
print collect_cache_stats(*args)
print(collect_cache_stats(*args))

0 comments on commit 38d7bfc

Please sign in to comment.