Skip to content

Commit

Permalink
fixing issue where topological generations without scheduler was not …
Browse files Browse the repository at this point in the history
…checking for locked resources correctly (#639)
  • Loading branch information
eamonnfaherty committed Feb 17, 2023
1 parent 288cf1c commit 2b542a1
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[tool.poetry]
name = "aws-service-catalog-puppet"
version = "0.220.0"
version = "0.221.0"
description = "Making it easier to deploy ServiceCatalog products"
classifiers = ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Programming Language :: Python :: 3", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Natural Language :: English"]
homepage = "https://service-catalog-tools-workshop.com/"
Expand Down
71 changes: 71 additions & 0 deletions servicecatalog_puppet/waluigi/locks/external_unit_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import unittest

from servicecatalog_puppet.waluigi.constants import RESOURCES_REQUIRED


class TestExternal(unittest.TestCase):
def setUp(self) -> None:
self.maxDiff = None
from servicecatalog_puppet.waluigi.locks import external

self.sut = external

def test_are_resources_are_free_for_task_dict_with_no_locked_resources(self):
# setup
resources_in_use = dict()
task_parameters = dict()
task_parameters[RESOURCES_REQUIRED] = ["aaaa"]
expected_result = True

# exercise
actual_result, _ = self.sut.are_resources_are_free_for_task_dict(
task_parameters, resources_in_use
)

# verify
self.assertEqual(expected_result, actual_result)

def test_are_resources_are_free_for_task_dict_with_other_locked_resources(self):
# setup
resources_in_use = dict(bbbb="some-other-task")
task_parameters = dict()
task_parameters[RESOURCES_REQUIRED] = ["aaaa"]
expected_result = True

# exercise
actual_result, _ = self.sut.are_resources_are_free_for_task_dict(
task_parameters, resources_in_use
)

# verify
self.assertEqual(expected_result, actual_result)

def test_are_resources_are_free_for_task_dict_with_locked_resources(self):
# setup
resources_in_use = dict(aaaa="some-other-task")
task_parameters = dict()
task_parameters[RESOURCES_REQUIRED] = ["aaaa"]
expected_result = False

# exercise
actual_result, _ = self.sut.are_resources_are_free_for_task_dict(
task_parameters, resources_in_use
)

# verify
self.assertEqual(expected_result, actual_result)

def test_are_resources_are_free_for_task_dict_with_locked_resources_and_more(self):
# setup
resources_in_use = dict(aaaa="some-other-task", bbb="sdsnkdnsk")
task_parameters = dict()
task_parameters[RESOURCES_REQUIRED] = ["aaaa"]
expected_result = False

# exercise
actual_result, _ = self.sut.are_resources_are_free_for_task_dict(
task_parameters, resources_in_use
)

# verify
self.assertEqual(expected_result, actual_result)
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def get_next_task_to_run(tasks_to_run, resources, all_tasks):
all_tasks[task_reference_to_run] = task_to_run
task_permanently_blocked_status.append(is_permanently_blocked)
if not is_currently_blocked:
if are_resources_are_free_for_task_dict(task_to_run, resources):
are_resources_are_free, _ = are_resources_are_free_for_task_dict(
task_to_run, resources
)
if are_resources_are_free:
return task_to_run, False
return None, all(task_permanently_blocked_status)

Expand All @@ -59,11 +62,8 @@ def lock_next_task_to_run(next_task, resources, all_tasks):
task_reference = next_task["task_reference"]
next_task[QUEUE_STATUS] = IN_PROGRESS
all_tasks[task_reference] = next_task
logger.info(f"before lock: {resources}")
for r in next_task.get(RESOURCES_REQUIRED, []):
logger.info(f"locking: {r} because of: {task_reference}")
resources[r] = task_reference
logger.info(f"after lock: {resources}")


def setup_next_task_to_run(lock, tasks_to_run, resources, all_tasks):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

setup_kwargs = {
'name': 'aws-service-catalog-puppet',
'version': '0.220.0',
'version': '0.221.0',
'description': 'Making it easier to deploy ServiceCatalog products',
'long_description': '# aws-service-catalog-puppet\n\n![logo](./docs/logo.png) \n\n## Badges\n\n[![codecov](https://codecov.io/gh/awslabs/aws-service-catalog-puppet/branch/master/graph/badge.svg?token=e8M7mdsmy0)](https://codecov.io/gh/awslabs/aws-service-catalog-puppet)\n\n\n## What is it?\nThis is a python3 framework that makes it easier to share multi region AWS Service Catalog portfolios and makes it \npossible to provision products into accounts declaratively using a metadata based rules engine.\n\nWith this framework you define your accounts in a YAML file. You give each account a set of tags, a default region and \na set of enabled regions.\n\nOnce you have done this you can define portfolios should be shared with each set of accounts using the tags and you \ncan specify which regions the shares occur in.\n\nIn addition to this, you can also define products that should be provisioned into accounts using the same tag based \napproach. The framework will assume role into the target account and provision the product on your behalf.\n\n\n## Getting started\n\nYou can read the [installation how to](https://service-catalog-tools-workshop.com/30-how-tos/10-installation/30-service-catalog-puppet.html)\nor you can read through the [every day use](https://service-catalog-tools-workshop.com/30-how-tos/50-every-day-use.html)\nguides.\n\nYou can read the [documentation](https://aws-service-catalog-puppet.readthedocs.io/en/latest/) to understand the inner \nworkings. \n\n\n## Going further\n\nThe framework is one of a pair. The other is [aws-service-catalog-factory](https://github.com/awslabs/aws-service-catalog-factory).\nWith Service Catalog Factory you can create pipelines that deploy multi region portfolios very easily. \n\n## License\n\nThis library is licensed under the Apache 2.0 License. \n \n',
'author': 'Eamonn Faherty',
Expand Down

0 comments on commit 2b542a1

Please sign in to comment.