Skip to content

Commit

Permalink
Merge pull request #255 from Cray-HPE/casmcms-8941-csm-1.5
Browse files Browse the repository at this point in the history
CASMCMS-8941: Break up large CFS component queries to avoid failures
  • Loading branch information
mharding-hpe authored Mar 8, 2024
2 parents 53e913d + 8a7974a commit 7f30004
Show file tree
Hide file tree
Showing 3 changed files with 21 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.10.6] - 2024-03-07
### Fixed
- Break up large CFS component queries to avoid errors

## [2.10.5] - 2024-03-04
### Fixed
- Corrected minor errors in a couple description fields in API spec (no functional impact)
Expand Down
8 changes: 4 additions & 4 deletions src/bos/operators/filters/filters.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 Down Expand Up @@ -31,7 +31,7 @@
from bos.common.utils import get_current_time, load_timestamp
from bos.operators.filters.base import BaseFilter, DetailsFilter, IDFilter, LocalFilter
from bos.operators.utils.clients.bos import BOSClient
from bos.operators.utils.clients.cfs import get_components as get_cfs_components
from bos.operators.utils.clients.cfs import get_components_from_id_list as get_cfs_components_from_id_list
from bos.operators.utils.clients.hsm import get_components as get_hsm_components

LOGGER = logging.getLogger('bos.operators.filters.filters')
Expand Down Expand Up @@ -198,8 +198,8 @@ def __init__(self):
super().__init__()

def _filter(self, components: List[dict]) -> List[dict]:
component_ids = ','.join([component['id'] for component in components])
cfs_components = get_cfs_components(ids=component_ids)
component_ids = [component['id'] for component in components]
cfs_components = get_cfs_components_from_id_list(id_list=component_ids)
self.cfs_components_dict = {component['id']: component for component in cfs_components}
matches = LocalFilter._filter(self, components)
# Clear this, so there are no lingering side-effects of running this method.
Expand Down
14 changes: 13 additions & 1 deletion src/bos/operators/utils/clients/cfs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,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 Down Expand Up @@ -33,6 +33,7 @@

LOGGER = logging.getLogger('bos.operators.utils.clients.cfs')

GET_BATCH_SIZE = 200
PATCH_BATCH_SIZE = 1000


Expand All @@ -59,6 +60,17 @@ def patch_components(data, session=None):
raise


def get_components_from_id_list(id_list):
session = requests_retry_session()
component_list = []
while id_list:
next_batch = id_list[:GET_BATCH_SIZE]
next_comps = get_components(session=session, ids=','.join(next_batch))
component_list.extend(next_comps)
id_list = id_list[GET_BATCH_SIZE:]
return component_list


def patch_desired_config(node_ids, desired_config, enabled=False, tags=None, clear_state=False):
session = requests_retry_session()
data = []
Expand Down

0 comments on commit 7f30004

Please sign in to comment.