Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASMCMS-8944: Reduce superfluous S3 calls during BOSv2 session creation #260

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading