Skip to content

Commit ddb2e4c

Browse files
himani2411Himani Anil Deshpande
andauthored
[Scaling] Improving share_compute_fleet_dna.py (#2884)
* adding Logs which would be visible in chef-client.log Co-authored-by: Himani Anil Deshpande <[email protected]>
1 parent 45431e6 commit ddb2e4c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

cookbooks/aws-parallelcluster-environment/files/cfn_hup_configuration/share_compute_fleet_dna.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def get_compute_launch_template_ids(lt_config_file_name):
7171
"""
7272
lt_config = None
7373
try:
74+
logger.info("Getting LaunchTemplate ID and versions from %s", lt_config_file_name)
7475
with open(lt_config_file_name, "r", encoding="utf-8") as file:
7576
lt_config = json.loads(file.read())
7677
except Exception as err:
@@ -117,6 +118,7 @@ def get_user_data(lt_id, lt_version, region_name):
117118
proxy_config = parse_proxy_config()
118119

119120
ec2_client = boto3.client("ec2", region_name=region_name, config=proxy_config)
121+
logger.info("Running EC2 DescribeLaunchTemplateVersions API for %s version %s", lt_id, lt_version)
120122
response = ec2_client.describe_launch_template_versions(
121123
LaunchTemplateId=lt_id,
122124
Versions=[
@@ -139,6 +141,7 @@ def get_write_directives_section(user_data):
139141
write_directives_section = None
140142
try:
141143
data = message_from_string(user_data)
144+
logger.info("Parsing UserData to get write_files section")
142145
for cloud_config_section in data.walk():
143146
if cloud_config_section.get_content_type() == "text/cloud-config":
144147
write_directives_section = yaml.safe_load(cloud_config_section._payload).get("write_files")
@@ -160,6 +163,7 @@ def write_dna_files(write_files_section, shared_storage_loc):
160163
for data in write_files_section:
161164
if data["path"] in ["/tmp/dna.json"]: # nosec B108
162165
with open(file_path, "w", encoding="utf-8") as file:
166+
logger.info("Writing %s", file_path)
163167
file.write(json.dumps(json.loads(data["content"]), indent=4))
164168
except Exception as err:
165169
if hasattr(err, "message"):
@@ -190,6 +194,7 @@ def cleanup(directory_loc):
190194
f_path = os.path.join(directory_loc, f)
191195
try:
192196
if os.path.isfile(f_path):
197+
logger.info("Cleaning up %s", f_path)
193198
os.remove(f_path)
194199
except Exception as err:
195200
logger.warning("Unable to delete %s due to %s", f_path, err)
@@ -238,6 +243,8 @@ def main():
238243
)
239244
raise SystemExit(0)
240245

246+
logger.info("All dna.json files have been shared!")
247+
241248

242249
if __name__ == "__main__":
243250
main()

cookbooks/aws-parallelcluster-environment/resources/cfn_hup_configuration.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@
5959
group 'root'
6060
mode '0400'
6161
variables(
62+
# Common variable
63+
launch_template_resource_id: node['cluster']['launch_template_id'],
64+
# HeadNode and LoginNode specific variables
6265
stack_id: node['cluster']['stack_arn'],
6366
region: node['cluster']['region'],
6467
cloudformation_url: cloudformation_url,
6568
cfn_init_role: instance_role_name,
66-
launch_template_resource_id: node['cluster']['launch_template_id'],
69+
# ComputeFleet specific variables
6770
update_hook_script_dir: node['cluster']['scripts_dir'],
6871
node_bootstrap_timeout: node['cluster']['compute_node_bootstrap_timeout'] || node['cluster']['Timeout']
6972
)

0 commit comments

Comments
 (0)