Skip to content

Commit

Permalink
Merge pull request #261 from Cray-HPE/casmcms-8944-1.6
Browse files Browse the repository at this point in the history
CASMCMS-8944: Reduce superfluous S3 calls during BOSv2 session creation
  • Loading branch information
mharding-hpe authored Mar 8, 2024
2 parents df76098 + 047a48c commit f775776
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.15.3] - 2024-03-08
### Changed
- Reduce superfluous S3 calls during BOSv2 session creation.

## [2.15.2] - 2024-03-07
### Fixed
- Break up large CFS component queries to avoid errors
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 @@ -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
Expand Down

0 comments on commit f775776

Please sign in to comment.