diff --git a/project.ini b/project.ini index 0ba0c0e..21935b3 100644 --- a/project.ini +++ b/project.ini @@ -2,11 +2,11 @@ name = pbspro label = PBS Professional OSS type = scheduler -version = 1.2.0 +version = 1.3.0 autoupgrade = true [blobs] -Files = pbspro-execution-18.1.3-0.x86_64.rpm, pbspro-server-18.1.3-0.x86_64.rpm +Files = pbspro-execution-18.1.3-0.x86_64.rpm, pbspro-server-18.1.3-0.x86_64.rpm, autoscale-7.8.0.tar.gz [spec master] run_list = role[pbspro_master_role] diff --git a/specs/default/chef/site-cookbooks/pbspro/attributes/default.rb b/specs/default/chef/site-cookbooks/pbspro/attributes/default.rb index 48d0225..7ef722d 100644 --- a/specs/default/chef/site-cookbooks/pbspro/attributes/default.rb +++ b/specs/default/chef/site-cookbooks/pbspro/attributes/default.rb @@ -17,10 +17,9 @@ default[:pbspro][:autoscale_hook][:__comment__] = "This file was generated by serializing node[:cyclecloud][:pbspro][:autostart_hook]." -default[:pbspro][:autoscale_hook][:src_dirs] = ["#{node[:cyclecloud][:home]}/system/embedded/lib/python2.7/site-packages", - "#{node[:cyclecloud][:bootstrap]}/pbs" - ] +default[:pbspro][:autoscale_hook][:src_dirs] = ["#{node[:cyclecloud][:bootstrap]}/pbs"] # pass through to the hook config json file +default[:pbspro][:autoscale_hook][:pbs_bootstrap] = "#{node[:cyclecloud][:bootstrap]}/pbs" default[:pbspro][:autoscale_hook][:cyclecloud_home] = node[:cyclecloud][:home] default[:pbspro][:autoscale_hook][:autostart_log_level] = "DEBUG" default[:pbspro][:autoscale_hook][:autostart_log_file_level] = "DEBUG" diff --git a/specs/default/chef/site-cookbooks/pbspro/files/default/autostart.py b/specs/default/chef/site-cookbooks/pbspro/files/default/autostart.py index e4d4df6..c6a3304 100644 --- a/specs/default/chef/site-cookbooks/pbspro/files/default/autostart.py +++ b/specs/default/chef/site-cookbooks/pbspro/files/default/autostart.py @@ -10,10 +10,10 @@ import time import traceback -from cyclecloud import machine, clustersapi, autoscale_util, autoscaler as autoscalerlib -from cyclecloud.autoscale_util import Record -import cyclecloud.config -from cyclecloud.job import Job, PackingStrategy +from autoscale import machine, clustersapi, autoscale_util, autoscaler as autoscalerlib +from autoscale.autoscale_util import Record +import autoscale.config +from autoscale.job import Job, PackingStrategy import mockpbs import pbs_driver from pbscc import InvalidSizeExpressionError @@ -24,10 +24,10 @@ class PBSAutostart: ''' - 1) Converts existing pbsnodes into cyclecloud.machine.Machine instances + 1) Converts existing pbsnodes into autoscale.machine.Machine instances 2) Performs a 'true up' of the machine instances reported by the autoscale lib vs the machines discovered in step 1) using InstanceId. - 3) Converts PBS jobs into cyclecloud.job.Job instances. - 4) Uses the current state of the cluster (steps 1 and 2) to construct a cyclecloud.autoscaler.Autoscaler instance. + 3) Converts PBS jobs into autoscale.job.Job instances. + 4) Uses the current state of the cluster (steps 1 and 2) to construct a autoscale.autoscaler.Autoscaler instance. 5) Feeds in jobs from step 3) into the Autoscaler, which performs a demand calculation of exactly which new machines are needed and which are idle. 6) Does a soft shutdown of idle nodes - first it sets them offline - `pbsnodes -o` - then, on subsequent iterations, if no jobs running on the node it performs a shutdown. @@ -43,7 +43,7 @@ def __init__(self, driver, clusters_api, cc_config): def query_jobs(self): ''' - Converts PBS jobs into cyclecloud.job.Job instances. It will also compress jobs that have the exact same requirements. + Converts PBS jobs into autoscale.job.Job instances. It will also compress jobs that have the exact same requirements. ''' scheduler_config = self.driver.scheduler_config() scheduler_resources = [] + scheduler_config["resources"] @@ -232,7 +232,7 @@ def fetch_nodearray_definitions(self): A wrapper around the autoscale library function to parse Configuration.autoscale.* chef attributes and add the 'ungrouped' attribute to the machine types. - See cyclecloud.nodearrays.NodearrayDefinitions for more info. + See autoscale.nodearrays.NodearrayDefinitions for more info. ''' nodearray_definitions = machine.fetch_nodearray_definitions(self.clusters_api, self.default_placement_attrs) nodearray_definitions.placement_group_optional = True @@ -378,7 +378,7 @@ def autoscale(self): def get_existing_machines(self, nodearray_definitions): ''' - Queries pbsnodes and CycleCloud to get a sane set of cyclecloud.machine.Machine instances that represent the current state of the cluster. + Queries pbsnodes and CycleCloud to get a sane set of autoscale.machine.Machine instances that represent the current state of the cluster. ''' pbsnodes = self.driver.pbsnodes().get(None) existing_machines = [] @@ -421,7 +421,7 @@ def process_pbsnode(self, pbsnode, instance_ids_to_shutdown, nodearray_definitio If the pbsnode is offline, will handle evaluating whether the node can be shutdown. See instance_ids_to_shutdown, which is an OUT parameter here. - Otherwise convert the pbsnode into a cyclecloud.machine.Machine instance. + Otherwise convert the pbsnode into a autoscale.machine.Machine instance. ''' states = set(pbsnode["state"].split(",")) resources = pbsnode["resources_available"] @@ -537,7 +537,7 @@ def _hook(): else: pbscc.debug("No overrides exist in file %s" % pbscc.CONFIG_PATH) - cc_config = cyclecloud.config.new_provider_config(overrides=overrides) + cc_config = autoscale.config.new_provider_config(overrides=overrides) if len(sys.argv) < 3: # There are no env variables for this as far as I can tell. diff --git a/specs/default/chef/site-cookbooks/pbspro/files/default/autostart_hook.py b/specs/default/chef/site-cookbooks/pbspro/files/default/autostart_hook.py index 07d528a..352017f 100644 --- a/specs/default/chef/site-cookbooks/pbspro/files/default/autostart_hook.py +++ b/specs/default/chef/site-cookbooks/pbspro/files/default/autostart_hook.py @@ -35,17 +35,12 @@ def perform_hook(): "AUTOSTART_LOG_FILE_LEVEL": hook_config.get("autostart_log_file_level") or "DEBUG", "AUTOSTART_LOG_LEVEL": hook_config.get("autostart_log_level") or "DEBUG"} - jetpack_config = hook_config.get("jetpack_python") - if not jetpack_config: - if not hook_config.get("cyclecloud_home"): - raise RuntimeError("Please specify either jetpack_python or cyclecloud_home in the hook config.") - - hook_config["jetpack_python"] = os.path.join(hook_config["cyclecloud_home"], "system", "embedded", "bin", "python") + jetpack_python = hook_config.get("pbs_bootstrap") + "/venv/bin/python" pbs_bin_dir = os.path.join(pbs.pbs_conf["PBS_EXEC"], "bin") - cmd = [hook_config["jetpack_python"], "-m", "autostart", pbs.hook_config_filename, pbs_bin_dir] - + cmd = [jetpack_python, "-m", "autostart", pbs.hook_config_filename, pbs_bin_dir] + pbs.logmsg(pbs.LOG_DEBUG, "Running %s with environment %s" % (cmd, env_with_src_dirs)) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env_with_src_dirs) diff --git a/specs/default/chef/site-cookbooks/pbspro/files/default/autostart_test.py b/specs/default/chef/site-cookbooks/pbspro/files/default/autostart_test.py index 173b675..be95432 100644 --- a/specs/default/chef/site-cookbooks/pbspro/files/default/autostart_test.py +++ b/specs/default/chef/site-cookbooks/pbspro/files/default/autostart_test.py @@ -6,13 +6,13 @@ import unittest from autostart import PBSAutostart -from cyclecloud import machine, autoscale_util -from cyclecloud.job import Job -from cyclecloud.machine import MachineRequest -from cyclecloud.autoscale_util import Record +from autoscale import machine, autoscale_util +from autoscale.job import Job +from autoscale.machine import MachineRequest +from autoscale.autoscale_util import Record import time from itertools import chain -from cyclecloud.config import InstanceConfig +from autoscale.config import InstanceConfig import random import pbscc from pbscc import InvalidSizeExpressionError diff --git a/specs/default/chef/site-cookbooks/pbspro/recipes/autostart.rb b/specs/default/chef/site-cookbooks/pbspro/recipes/autostart.rb index 31f5a16..29212f9 100644 --- a/specs/default/chef/site-cookbooks/pbspro/recipes/autostart.rb +++ b/specs/default/chef/site-cookbooks/pbspro/recipes/autostart.rb @@ -43,6 +43,18 @@ content Chef::JSONCompat.to_json_pretty(node[:pbspro][:autoscale_hook]) end +sdist_name = "autoscale-7.8.0.tar.gz" + +jetpack_download sdist_name do + project 'pbspro' +end + +bash "create pbs virtualenv" do + code "virtualenv --system-site-packages '#{node[:cyclecloud][:bootstrap]}/pbs/venv' + source '#{node[:cyclecloud][:bootstrap]}/pbs/venv/bin/activate' + pip install '#{node[:jetpack][:downloads]}/#{sdist_name}'" +end + bash "import autoscale hook" do code <<-EOH set -e diff --git a/specs/master/cluster-init/tests/test_submit.py b/specs/master/cluster-init/tests/test_submit.py index ef9eaad..7e93915 100644 --- a/specs/master/cluster-init/tests/test_submit.py +++ b/specs/master/cluster-init/tests/test_submit.py @@ -2,11 +2,12 @@ # Licensed under the MIT License. # import unittest -from tryme import retry, Stop, Again import os -import helper +import time import logging +import helper import jetpack +from tryme import retry, Stop, Again jetpack.util.setup_logging() @@ -79,8 +80,9 @@ def setUp(self): def test_simple(self): sleep_script = write_sleep_script() - output_file = self.userhome + '/sleep.out' - err_file = self.userhome + '/sleep.err' + jobtime = str(int(time.time())) + output_file = '%s/sleep.%s.out' % (self.userhome, jobtime) + err_file = '%s/sleep.%s.err' % (self.userhome, jobtime) helper.sudo_check_output(['/opt/pbs/bin/qsub', '-o', output_file, '-e', err_file, sleep_script], CLUSTER_USER, cwd=self.userhome)