-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MemoryError seen on expire_distros execution #240
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/bin/sh | ||
exec flock -n /var/run/beaker_expire_distros.cron.lock beaker-expire-distros | ||
exec flock -n /var/run/beaker_expire_distros.cron.lock beaker-expire-distros --arch=all |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,10 +78,12 @@ def check_url(url): | |
def check_all_trees(ignore_errors=False, | ||
dry_run=False, | ||
lab_controller='http://localhost:8000', | ||
remove_all=False): | ||
remove_all=False, | ||
filter=None): | ||
filter_on_arch = True if (filter is not None and filter and 'arch' in filter.keys()) else False | ||
proxy = xmlrpc_client.ServerProxy(lab_controller, allow_none=True) | ||
rdistro_trees = [] | ||
distro_trees = proxy.get_distro_trees() | ||
distro_trees = proxy.get_distro_trees(filter) | ||
if not remove_all: | ||
for distro_tree in distro_trees: | ||
accessible = False | ||
|
@@ -108,21 +110,29 @@ def check_all_trees(ignore_errors=False, | |
else: | ||
rdistro_trees = distro_trees | ||
|
||
print('INFO: expire_distros to remove %d entries for arch %s' % (len(rdistro_trees), | ||
filter['arch'] if (filter_on_arch) else 'unset')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can do |
||
|
||
# If all distro_trees are expired then something is wrong | ||
# Unless there is intention to remove all distro_trees | ||
if len(distro_trees) != len(rdistro_trees) or remove_all: | ||
if (len(distro_trees) != len(rdistro_trees)) or remove_all: | ||
for distro_tree in rdistro_trees: | ||
if dry_run: | ||
print('Distro marked for remove %s:%d' % (distro_tree['distro_name'], | ||
distro_tree['distro_tree_id'])) | ||
distro_tree['distro_tree_id'])) | ||
else: | ||
print('Removing distro %s:%d' % (distro_tree['distro_name'], | ||
distro_tree['distro_tree_id'])) | ||
proxy.remove_distro_trees([distro_tree['distro_tree_id']]) | ||
else: | ||
sys.stderr.write('All distros are missing! Please check your server!\n') | ||
sys.exit(1) | ||
|
||
if (len(distro_trees) == 0): | ||
if (filter is None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have changed the business logic here. In this particular case it will report that distributions are missing if the filter is not set, but if we use `all' it will simply not work and even if the controller is empty we will not report anything as we are going arch by arch. My suggestion is to remove the non-filtered way altogether and always run arch by arch and we can write business logic to take that into account. |
||
sys.stderr.write('All distros are missing! Please check your server!\n') | ||
sys.exit(1) | ||
else: | ||
sys.stderr.write('Stopped removal of all distros for arch %s!! Please check your ' | ||
'server.\nYou can manually force removal using --remove-all.\n' % | ||
(filter['arch'] if (filter_on_arch) else 'unset')) | ||
|
||
def main(): | ||
from optparse import OptionParser | ||
|
@@ -137,14 +147,49 @@ def main(): | |
'Defaults to http://localhost:8000.') | ||
parser.add_option('--remove-all', default=False, action='store_true', | ||
help='Remove all distros from lab controller.') | ||
parser.add_option('--name', default=None, | ||
help='Remove all distros with given name. Use "%" for wildcard.') | ||
parser.add_option('--family', default=None, | ||
help='Remove all distros for a given family.') | ||
parser.add_option('--arch', default=None, | ||
help='Remove all distros for a given architecture. When set to "all", ' | ||
'steps thru each available arch to reduce memory usage.') | ||
options, args = parser.parse_args() | ||
try: | ||
check_all_trees(options.ignore_errors, | ||
options.dry_run, | ||
options.lab_controller, | ||
options.remove_all) | ||
except KeyboardInterrupt: | ||
pass | ||
startmsg = str("INFO: expire_distros running with --lab-controller=" + options.lab_controller) | ||
for i in range(1,len(sys.argv)): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idea, but for sure not required:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would work for sure, but do we want to report it that way? I mean, we are not using these options from argv, but rather parsed options (L157). I would work with that instead data structure instead. |
||
startmsg += ' ' + sys.argv[i] | ||
print('%s' % (startmsg)) | ||
filter = {} | ||
if options.name: | ||
filter['name'] = options.name | ||
if options.family: | ||
filter['family'] = options.family | ||
|
||
arch_list = [] | ||
if options.arch: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean having There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have thought about this further and I think there is no point in having an alternative behavior between |
||
if options.arch == "all": | ||
arch_list = [ "x86_64", "ppc", "ppc64le", "ppc64", "i386", "s390", "s390x", "aarch64", "ia64", "arm", "armhfp" ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question - this list is quite fragile, isn't there an API that can tell us what kind of architectures we have? |
||
else: | ||
arch_list = [ options.arch ] | ||
for arch in arch_list: | ||
filter['arch'] = arch | ||
try: | ||
check_all_trees(options.ignore_errors, | ||
options.dry_run, | ||
options.lab_controller, | ||
options.remove_all, | ||
filter) | ||
except KeyboardInterrupt: | ||
pass | ||
else: | ||
try: | ||
check_all_trees(options.ignore_errors, | ||
options.dry_run, | ||
options.lab_controller, | ||
options.remove_all, | ||
filter) | ||
except KeyboardInterrupt: | ||
pass | ||
|
||
|
||
if __name__ == '__main__': | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could streamline this further by converting
filter
todict
if it is set toNone
.