diff --git a/commands/preupgrade/__init__.py b/commands/preupgrade/__init__.py index 5a89069f6a..4a6a6ccdf8 100644 --- a/commands/preupgrade/__init__.py +++ b/commands/preupgrade/__init__.py @@ -1,4 +1,5 @@ import os +import resource import sys import uuid @@ -59,6 +60,22 @@ def preupgrade(args, breadcrumbs): except LeappError as exc: raise CommandError(exc.message) + soft_nofile, _ = resource.getrlimit(resource.RLIMIT_NOFILE) + soft_fsize, _ = resource.getrlimit(resource.RLIMIT_FSIZE) + nofile_limit = 1024*16 + + if soft_nofile < nofile_limit: + try: + resource.setrlimit(resource.RLIMIT_NOFILE, (nofile_limit, nofile_limit)) + except OSError as err: + raise CommandError('Failed to set limit for maximum number of open file descriptors: {}'.format(err)) + + if soft_fsize != resource.RLIM_INFINITY: + try: + resource.setrlimit(resource.RLIMIT_FSIZE, (resource.RLIM_INFINITY, resource.RLIM_INFINITY)) + except OSError as err: + raise CommandError('Failed to set limit for maximum writeable file size: {}'.format(err)) + workflow = repositories.lookup_workflow('IPUWorkflow')() util.warn_if_unsupported(configuration) util.process_whitelist_experimental(repositories, workflow, configuration, logger) diff --git a/commands/upgrade/__init__.py b/commands/upgrade/__init__.py index 1e15b59c45..5275629194 100644 --- a/commands/upgrade/__init__.py +++ b/commands/upgrade/__init__.py @@ -1,4 +1,5 @@ import os +import resource import sys import uuid @@ -89,6 +90,23 @@ def upgrade(args, breadcrumbs): repositories = util.load_repositories() except LeappError as exc: raise CommandError(exc.message) + + soft_nofile, _ = resource.getrlimit(resource.RLIMIT_NOFILE) + soft_fsize, _ = resource.getrlimit(resource.RLIMIT_FSIZE) + nofile_limit = 1024*16 + + if soft_nofile < nofile_limit: + try: + resource.setrlimit(resource.RLIMIT_NOFILE, (nofile_limit, nofile_limit)) + except OSError as err: + raise CommandError('Failed to set limit for maximum number of open file descriptors: {}'.format(err)) + + if soft_fsize != resource.RLIM_INFINITY: + try: + resource.setrlimit(resource.RLIMIT_FSIZE, (resource.RLIM_INFINITY, resource.RLIM_INFINITY)) + except OSError as err: + raise CommandError('Failed to set limit for maximum writeable file size: {}'.format(err)) + workflow = repositories.lookup_workflow('IPUWorkflow')(auto_reboot=args.reboot) util.process_whitelist_experimental(repositories, workflow, configuration, logger) util.warn_if_unsupported(configuration)