Skip to content

Commit

Permalink
CASMCMS-8944: Reduce superfluous S3 calls during BOSv2 session creation
Browse files Browse the repository at this point in the history
(cherry picked from commit 3101e14)
  • Loading branch information
mharding-hpe committed Mar 8, 2024
1 parent 7f30004 commit ac6fa60
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 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]
### Changed
- Reduce superfluous S3 calls during BOSv2 session creation.

## [2.10.6] - 2024-03-07
### Fixed
Expand Down
18 changes: 13 additions & 5 deletions src/bos/operators/session_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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
Expand Down Expand Up @@ -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.")
Expand Down Expand Up @@ -246,14 +254,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
Expand Down

0 comments on commit ac6fa60

Please sign in to comment.