Skip to content

Commit

Permalink
Merge pull request #385 from Cray-HPE/CASMCMS-9162-release-2.10
Browse files Browse the repository at this point in the history
CASMCMS-9162: Add cfs_read_timeout option
  • Loading branch information
jsollom-hpe authored Oct 16, 2024
2 parents 53c9b6d + 908b5b4 commit cfb5c41
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ All notable changes to this project will be documented in this file.
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.10.28] - 2024-10-16
### Added
#### BOS option
- cfs_read_timeout: Allow the amount of time BOS waits for a response from CFS before
timing out to be configurable

### Fixed
- Fix per-bootset CFS setting

Expand Down
7 changes: 7 additions & 0 deletions api/openapi.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,13 @@ components:
Options for the Boot Orchestration Service.
type: object
properties:
cfs_read_timeout:
type: integer
description: |
The amount of time (in seconds) to wait for a response before timing out a request to CFS
example: 20
minimum: 10
maximum: 86400
cleanup_completed_session_ttl:
type: string
description: |
Expand Down
4 changes: 4 additions & 0 deletions src/bos/operators/utils/clients/bos/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def get_option(self, key, value_type, default):
else:
raise KeyError('Option {} not found and no default exists'.format(key))

@property
def cfs_read_timeout(self):
return self.get_option('cfs_read_timeout', int, 10)

@property
def logging_level(self):
return self.get_option('logging_level', str, 'INFO')
Expand Down
11 changes: 6 additions & 5 deletions src/bos/operators/utils/clients/cfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
#
from collections import defaultdict
import logging
from requests.exceptions import HTTPError, ConnectionError
from bos.operators.utils.clients.bos.options import options
from requests.exceptions import HTTPError

from bos.common.utils import compact_response_text, exc_type_msg, requests_retry_session, PROTOCOL

Expand All @@ -45,7 +46,7 @@ def get_components(session=None, **params):
Returns the list of CFS components
"""
if not session:
session = requests_retry_session()
session = requests_retry_session(read_timeout=options.cfs_read_timeout) # pylint: disable=redundant-keyword-arg
component_list = []
while params is not None:
LOGGER.debug("GET %s with params=%s", COMPONENTS_ENDPOINT, params)
Expand All @@ -71,7 +72,7 @@ def patch_components(data, session=None):
LOGGER.warning("patch_components called without data; returning without action.")
return
if not session:
session = requests_retry_session()
session = requests_retry_session(read_timeout=options.cfs_read_timeout) # pylint: disable=redundant-keyword-arg
LOGGER.debug("PATCH %s with body=%s", COMPONENTS_ENDPOINT, data)
response = session.patch(COMPONENTS_ENDPOINT, json=data)
LOGGER.debug("Response status code=%d, reason=%s, body=%s", response.status_code,
Expand All @@ -88,7 +89,7 @@ def get_components_from_id_list(id_list):
LOGGER.warning("get_components_from_id_list called without IDs; returning without action.")
return []
LOGGER.debug("get_components_from_id_list called with %d IDs", len(id_list))
session = requests_retry_session()
session = requests_retry_session(read_timeout=options.cfs_read_timeout) # pylint: disable=redundant-keyword-arg
component_list = []
while id_list:
next_batch = id_list[:GET_BATCH_SIZE]
Expand All @@ -106,7 +107,7 @@ def patch_desired_config(node_ids, desired_config, enabled=False, tags=None, cle
return
LOGGER.debug("patch_desired_config called on %d IDs with desired_config=%s enabled=%s tags=%s"
" clear_state=%s", len(node_ids), desired_config, enabled, tags, clear_state)
session = requests_retry_session()
session = requests_retry_session(read_timeout=options.cfs_read_timeout) # pylint: disable=redundant-keyword-arg
node_patch = {
'enabled': enabled,
'desired_config': desired_config,
Expand Down
1 change: 1 addition & 0 deletions src/bos/server/controllers/v2/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# options simpler
OPTIONS_KEY = 'options'
DEFAULTS = {
'cfs_read_timeout': 10,
'cleanup_completed_session_ttl': "7d",
'clear_stage': False,
'component_actual_state_ttl': "4h",
Expand Down

0 comments on commit cfb5c41

Please sign in to comment.