Skip to content

Commit

Permalink
Issues/584 (#585)
Browse files Browse the repository at this point in the history
* now catching exceptions during exception logging and now unwrapping tasks as they may contain ordered dicts etc
* fixing support for 'product' in constraints (issue #584)
  • Loading branch information
eamonnfaherty committed Oct 28, 2022
1 parent 21cbb64 commit 50d0d03
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 34 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.201.1"
version = "0.202.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
27 changes: 17 additions & 10 deletions servicecatalog_puppet/waluigi/processes/topological_generations.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,23 @@ def worker_task(
logger.error(
f"executed task [failure]: {task_reference} failures: {e}"
)
logger.error(f"---- START OF ERROR----")
logger.error(f"Task {task_type}:")
for l in serialisation_utils.dump(task_details).split("\n"):
logger.error(l)
for l in traceback.format_exception(
etype=type(e), value=e, tb=e.__traceback__,
):
for sl in l.split("\n"):
logger.error(f"{sl}")
logger.error(f"---- END OF ERROR ----")
try:
logger.error(f"---- START OF ERROR----")
logger.error(f"Task {task_type}:")
for l in serialisation_utils.dump(
unwrap(task_details)
).split("\n"):
logger.error(l)
for l in traceback.format_exception(
etype=type(e), value=e, tb=e.__traceback__,
):
for sl in l.split("\n"):
logger.error(f"{sl}")
logger.error(f"---- END OF ERROR ----")
except Exception as e2:
logger.error(
f"Exception raised: {e2} whilst logging exection: {e}"
)
task.on_task_failure(e, duration)
else:
end = time.time()
Expand Down
27 changes: 17 additions & 10 deletions servicecatalog_puppet/waluigi/threads/topological_generations.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,23 @@ def worker_task(
logger.error(
f"executed task [failure]: {task_reference} failures: {e}"
)
logger.error(f"---- START OF ERROR----")
logger.error(f"Task {task_type}:")
for l in serialisation_utils.dump(task_details).split("\n"):
logger.error(l)
for l in traceback.format_exception(
etype=type(e), value=e, tb=e.__traceback__,
):
for sl in l.split("\n"):
logger.error(f"{sl}")
logger.error(f"---- END OF ERROR ----")
try:
logger.error(f"---- START OF ERROR----")
logger.error(f"Task {task_type}:")
for l in serialisation_utils.dump(
unwrap(task_details)
).split("\n"):
logger.error(l)
for l in traceback.format_exception(
etype=type(e), value=e, tb=e.__traceback__,
):
for sl in l.split("\n"):
logger.error(f"{sl}")
logger.error(f"---- END OF ERROR ----")
except Exception as e2:
logger.error(
f"Exception raised: {e2} whilst logging exection: {e}"
)
task.on_task_failure(e, duration)
else:
end = time.time()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,17 @@ def run(self):

for launch_constraint in self.launch_constraints:
products_to_constrain = list()
if isinstance(launch_constraint.get("products"), tuple):
for p in launch_constraint.get("products"):
constraint = launch_constraint.get("products") or launch_constraint.get(
"product"
)
if isinstance(constraint, tuple):
for p in constraint:
products_to_constrain.append(p)
elif isinstance(launch_constraint.get("products"), str):
products_to_constrain.append(launch_constraint.get("products"))
elif isinstance(constraint, str):
products_to_constrain.append(constraint)
else:
raise Exception(
f'Unexpected launch constraint type {type(launch_constraint.get("products"))}'
f"Unexpected launch constraint type in {type(constraint)}"
)

for role_arn in launch_constraint.get("roles"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ def run(self):

for resource_update_constraint in self.resource_update_constraints:
products_to_constrain = list()
if isinstance(resource_update_constraint.get("products"), tuple):
for p in resource_update_constraint.get("products"):
constraint = resource_update_constraint.get(
"products"
) or resource_update_constraint.get("product")
if isinstance(constraint, tuple):
for p in constraint:
products_to_constrain.append(p)
elif isinstance(resource_update_constraint.get("products"), str):
products_to_constrain.append(resource_update_constraint.get("products"))
elif isinstance(constraint, str):
products_to_constrain.append(constraint)
else:
raise Exception(
f'Unexpected launch constraint type {type(resource_update_constraint.get("products"))}'
)
raise Exception(f"Unexpected launch constraint type {type(constraint)}")

validate_tag_update = resource_update_constraint.get(
"tag_update_on_provisioned_product"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

setup_kwargs = {
'name': 'aws-service-catalog-puppet',
'version': '0.201.1',
'version': '0.202.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 50d0d03

Please sign in to comment.