From 6c8f6f0a497f120e203887ef0f968742eaa6658c Mon Sep 17 00:00:00 2001 From: "Mitch Harding (the weird one)" Date: Fri, 8 Mar 2024 16:59:47 -0500 Subject: [PATCH 1/2] CASMCMS-8944: Reduce superfluous S3 calls during BOSv2 session creation (cherry picked from commit 3101e141b50fa8bb9c7297646af0c9dfe27f43ca) --- CHANGELOG.md | 2 ++ src/bos/operators/session_setup.py | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e38d5b1..3454eb6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] +### Changed +- Reduce superfluous S3 calls during BOSv2 session creation. ## [2.15.2] - 2024-03-07 ### Fixed diff --git a/src/bos/operators/session_setup.py b/src/bos/operators/session_setup.py index 07171922..e8fd350f 100644 --- a/src/bos/operators/session_setup.py +++ b/src/bos/operators/session_setup.py @@ -2,7 +2,7 @@ # # MIT License # -# (C) Copyright 2021-2023 Hewlett Packard Enterprise Development LP +# (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -22,6 +22,7 @@ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. # +import copy import logging from botocore.exceptions import ClientError from typing import Set @@ -118,11 +119,18 @@ def setup(self): def _setup_components(self): all_component_ids = [] data = [] + stage = self.session_data.get("stage", False) try: for _, boot_set in self.template.get('boot_sets', {}).items(): components = self._get_boot_set_component_list(boot_set) + if not components: + continue + if stage: + state = self._generate_desired_state(boot_set, staged=True) + else: + state = self._generate_desired_state(boot_set) for component_id in components: - data.append(self._operate(component_id, boot_set)) + data.append(self._operate(component_id, copy.deepcopy(state))) all_component_ids += components if not all_component_ids: raise SessionSetupException("No nodes were found to act upon.") @@ -253,14 +261,14 @@ def _log(self, logger, message): logger('Session {}: {}'.format(self.name, message)) # Operations - def _operate(self, component_id, boot_set): + def _operate(self, component_id, state): stage = self.session_data.get("stage", False) data = {"id": component_id} if stage: - data["staged_state"] = self._generate_desired_state(boot_set, staged=True) + data["staged_state"] = state data["staged_state"]["session"] = self.name else: - data["desired_state"] = self._generate_desired_state(boot_set) + data["desired_state"] = state if self.operation_type == "reboot" : data["actual_state"] = EMPTY_ACTUAL_STATE data["session"] = self.name From 047a48c565cea112669cd27147639170b93f9fc0 Mon Sep 17 00:00:00 2001 From: "Mitch Harding (the weird one)" Date: Fri, 8 Mar 2024 17:07:11 -0500 Subject: [PATCH 2/2] Release 2.15.3 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3454eb6b..53462b65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] + +## [2.15.3] - 2024-03-08 ### Changed - Reduce superfluous S3 calls during BOSv2 session creation.