Skip to content

Commit

Permalink
Removed reading of preview config parameter `min-preview-publish-inst…
Browse files Browse the repository at this point in the history
…ances`
  • Loading branch information
mbloch1986 committed Aug 16, 2023
1 parent 1c9a748 commit aee5dc4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Removed
- Removed preview config parameter `min-preview-publish-instances`, as if we want to proceed with offline-snapshot even if no preview instance is found.

## 2.0.0 - 2023-07-28

Expand Down
22 changes: 4 additions & 18 deletions lambda/aem_offline_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def manage_lock_for_environment(table_name, lock, action):


def stack_health_check(
stack_prefix, min_publish_instances, min_preview_publish_instance
stack_prefix, min_publish_instances
):
"""
Simple AEM stack health check based on the number of author-primary,
Expand All @@ -351,10 +351,6 @@ def stack_health_check(
if isinstance(min_publish_instances, str):
min_publish_instances = int(min_publish_instances)

# make sure min_preview_publish_instance is integer
if isinstance(min_preview_publish_instance, str):
min_preview_publish_instance = int(min_preview_publish_instance)

logger.info("[%s] Start checking Stack health ...", stack_prefix)

if publish_count >= min_publish_instances:
Expand Down Expand Up @@ -397,23 +393,16 @@ def stack_health_check(
return None

if (
min_preview_publish_instance > 0
and preview_publish_count >= min_preview_publish_instance
preview_publish_count >= 1
):
preview_publish_instance_id = preview_publish_instances[0]
paired_preview_publish_dispatcher_id = retrieve_tag_value(
preview_publish_instance_id, "PreviewPairInstanceId"
)
elif min_preview_publish_instance == 0:
else:
preview_publish_instance_id = "False"
paired_preview_publish_dispatcher_id = "False"
else:
logger.error(
"Found %s preview-publish instances. Unhealthy stack.",
preview_publish_count,
)

return None
logger.info("[%s] Finished checking Stack health successfully.", stack_prefix)

return {
Expand Down Expand Up @@ -746,11 +735,8 @@ def sns_message_processor(event, context):
min_publish_instance = int(
offline_snapshot_config["min-publish-instances"]
)
min_preview_publish_instance = int(
offline_snapshot_config["min-preview-publish-instances"]
)
instances = stack_health_check(
stack_prefix, min_publish_instance, min_preview_publish_instance
stack_prefix, min_publish_instance
)
if instances is None:
raise RuntimeError("Unhealthy Stack")
Expand Down
6 changes: 0 additions & 6 deletions lambda/test_aws_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def create_sm_config(
sm_service_iam_role_arn,
ddb_table_name,
ssm_document_name,
min_preview_instances,
):
config = {
"ec2_run_command": {
Expand Down Expand Up @@ -218,7 +217,6 @@ def create_sm_config(
},
"offline_snapshot": {
"min-publish-instances": "1",
"min-preview-publish-instances": min_preview_instances,
"sns-topic-arn": sns_topic_arn,
},
"cw_stream_s3": {
Expand All @@ -237,7 +235,6 @@ def upload_sm_config(
sm_service_iam_role_arn,
ddb_table_name,
ssm_document_name,
min_preview_instances,
):
sm_config = self.create_sm_config(
s3_bucket_name,
Expand All @@ -246,7 +243,6 @@ def upload_sm_config(
sm_service_iam_role_arn,
ddb_table_name,
ssm_document_name,
min_preview_instances,
)

response = self.s3_client().put_object(
Expand Down Expand Up @@ -280,7 +276,6 @@ def setup_stack_manager_infrastructure(self):
sm_service_iam_role_arn,
ddb_table_name,
ssm_document_name,
0,
)

def setup_stack_manager_preview_infrastructure(self):
Expand All @@ -304,7 +299,6 @@ def setup_stack_manager_preview_infrastructure(self):
sm_service_iam_role_arn,
ddb_table_name,
ssm_document_name,
1,
)

def setup_standard_infrastructure(self):
Expand Down

0 comments on commit aee5dc4

Please sign in to comment.