From 3ee8289281694524b8944193262acc0b23903e17 Mon Sep 17 00:00:00 2001 From: Farhan Angullia Date: Sat, 21 Oct 2023 22:25:08 +0800 Subject: [PATCH 1/3] fix: use isinstance() in favor of type checks --- azchaosaws/ec2/actions.py | 6 ++---- azchaosaws/utils.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/azchaosaws/ec2/actions.py b/azchaosaws/ec2/actions.py index f52ec81..4429459 100644 --- a/azchaosaws/ec2/actions.py +++ b/azchaosaws/ec2/actions.py @@ -477,7 +477,6 @@ def get_instance_lifecycle_by_ids( def stop_instances_any_lifecycle( client: boto3.client, instance_lifecycles: dict = None, force: bool = False ) -> List[Dict[str, Any]]: - results = [] if "normal" in instance_lifecycles: logger.warning( @@ -841,7 +840,6 @@ def network_failure( def instance_state(client: boto3.client, state: str, instance_ids: List[str]) -> bool: - instances = client.describe_instances(InstanceIds=instance_ids) logger.debug("[EC2] instances ({})".format(str(instances))) @@ -888,7 +886,7 @@ def instance_failure( for instance_response in stop_instances_response: instance_state = {} - if type(instance_response) == str: + if isinstance(instance_response, str): if instance_response in dry_run_keys: for id in stop_instances_response[instance_response]: instance_state = { @@ -897,7 +895,7 @@ def instance_failure( "After": {"State": str()}, } results.append(instance_state) - elif type(instance_response) == dict: + elif isinstance(instance_response, dict): for k in instance_response.keys(): if k in non_dry_run_keys: for instance in instance_response[k]: diff --git a/azchaosaws/utils.py b/azchaosaws/utils.py index e8da276..a928994 100644 --- a/azchaosaws/utils.py +++ b/azchaosaws/utils.py @@ -4,7 +4,7 @@ def args_fmt(fn): @functools.wraps(fn) def wrapper(**kwargs): - if type(kwargs["dry_run"]) == str: + if isinstance(kwargs["dry_run"], str): kwargs["dry_run"] = ( kwargs["dry_run"].lower() == "true" if ( From ccbcd74fd6063d5e294cd8b30ec30c4a1ea45291 Mon Sep 17 00:00:00 2001 From: Farhan Angullia Date: Sat, 21 Oct 2023 22:25:35 +0800 Subject: [PATCH 2/3] chore: fmt --- azchaosaws/elbv2/actions.py | 1 - azchaosaws/mq/actions.py | 1 - 2 files changed, 2 deletions(-) diff --git a/azchaosaws/elbv2/actions.py b/azchaosaws/elbv2/actions.py index 82faba7..30bb86e 100644 --- a/azchaosaws/elbv2/actions.py +++ b/azchaosaws/elbv2/actions.py @@ -224,7 +224,6 @@ def set_subnets( subnet_ids: List[str], dry_run: bool = False, ) -> None: - load_balancers = get_load_balancer_arns(elbv2_client, load_balancer_names) if load_balancers.get("network", []): diff --git a/azchaosaws/mq/actions.py b/azchaosaws/mq/actions.py index 8f5fd03..63f992c 100644 --- a/azchaosaws/mq/actions.py +++ b/azchaosaws/mq/actions.py @@ -180,7 +180,6 @@ def get_brokers_by_tags_and_az( if all( response["Tags"].get(k, None) == v for t in tags for k, v in t.items() ): - broker_subnet_ids = mq_client.describe_broker(BrokerId=b["BrokerId"])[ "SubnetIds" ] From ba618a13380fb83a53ed25e017252570824121d8 Mon Sep 17 00:00:00 2001 From: Farhan Angullia Date: Sat, 21 Oct 2023 22:25:51 +0800 Subject: [PATCH 3/3] chore: bump to v0.1.10 --- CHANGELOG.md | 4 ++++ azchaosaws/__init__.py | 6 ++---- setup.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0978600..484d99b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,12 @@ ## [Unreleased] +## [0.1.10][] - 2023-10-21 +[0.1.10]: https://github.com/awslabs/aws-az-failure-chaostoolkit/tree/v0.1.10 + ### Changed - Added support for AWS Profile +- Minor type compare changes ## [0.1.9][] - 2023-04-03 [0.1.9]: https://github.com/awslabs/aws-az-failure-chaostoolkit/tree/v0.1.9 diff --git a/azchaosaws/__init__.py b/azchaosaws/__init__.py index 8145bf9..e19f525 100644 --- a/azchaosaws/__init__.py +++ b/azchaosaws/__init__.py @@ -12,7 +12,7 @@ from logzero import logger __all__ = ["discover", "__version__", "client"] -__version__ = "0.1.9" +__version__ = "0.1.10" def discover(discover_system: bool = True) -> Discovery: @@ -50,9 +50,7 @@ def client(resource_name: str, configuration: Configuration = None): if boto3.DEFAULT_SESSION is None: boto3.setup_default_session(profile_name=aws_profile_name, **params) logger.debug( - "Client will be using profile '{}'".format( - aws_profile_name or "default" - ) + "Client will be using profile '{}'".format(aws_profile_name or "default") ) return boto3.client(resource_name, **params) diff --git a/setup.py b/setup.py index 99ee450..ffc0986 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,7 @@ setup_params = dict( name=name, - version="0.1.9", + version="0.1.10", description=desc, long_description=long_desc, long_description_content_type="text/markdown",