Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
if --search-provides finds no children we should then fallback to --s…
Browse files Browse the repository at this point in the history
…earch-latest
  • Loading branch information
JimFuller-RedHat committed Feb 2, 2024
1 parent 264d645 commit d6b2a8b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 42 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed
* if default --search_provides finds no children then revert to --search-all

## [0.5.4] - 2024-01-23
### Fixed
* fixed searches with middleware CLI enabled (GRIF-221)
Expand Down
85 changes: 44 additions & 41 deletions griffon/services/core_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,106 +342,109 @@ def execute(self, status=None) -> List[Dict[str, Any]]:
params["active_streams"] = "True"
if self.exclude_unreleased:
params["released_components"] = "True"
if not self.include_container_roots:
if not (self.include_container_roots):
params["type"] = "RPM"
params["arch"] = "src"

component_name = self.component_name
if not self.strict_name_search and not self.regex_name_search:
component_name = re.escape(component_name)

if self.search_latest:
search_latest_params = copy.deepcopy(params)
if self.search_provides:
search_provides_params = copy.deepcopy(params)
if not (self.strict_name_search):
search_latest_params["re_name"] = component_name
search_provides_params["re_provides_name"] = component_name
else:
search_latest_params["name"] = component_name
search_provides_params["provides_name"] = component_name
if self.ns:
search_latest_params["namespace"] = self.ns
search_latest_params["root_components"] = "True"
search_latest_params["latest_components_by_streams"] = "True"
status.update("searching latest root component(s).")
latest_components_cnt = self.corgi_session.components.count(**search_latest_params)
status.update(f"found {latest_components_cnt} latest component(s).")
search_provides_params["namespace"] = self.ns
search_provides_params["latest_components_by_streams"] = "True"
status.update("searching latest provided child component(s).")
latest_components_cnt = self.corgi_session.components.count(**search_provides_params)
status.update(f"found {latest_components_cnt} latest provides component(s).")
latest_components = self.corgi_session.components.retrieve_list_iterator_async(
**search_latest_params, max_results=10000
**search_provides_params, max_results=10000
)

status.update(
f"found {latest_components_cnt} latest provides child component(s)- retrieving children, sources & upstreams." # noqa
)
status.update(f"found {latest_components_cnt} latest root component(s).") # noqa
with multiprocessing.Pool() as pool:
for processed_component in pool.map(
partial(process_component, self.corgi_session, search_latest_params),
partial(process_component, self.corgi_session, search_provides_params),
latest_components,
):
results.append(processed_component)
# if we have found no children then search_latest for roots
if not (results):
self.search_latest = True

if not self.no_community:
status.update("searching latest community root component(s).")
status.update("searching latest community provided child component(s).")
community_component_cnt = self.community_session.components.count(
**search_latest_params
**search_provides_params
)
status.update(
f"found {community_component_cnt} latest community root component(s)." # noqa
f"found {community_component_cnt} latest community provided child component(s)." # noqa
)
latest_community_components = (
self.community_session.components.retrieve_list_iterator_async(
**search_latest_params, max_results=10000
**search_provides_params, max_results=10000
)
)
status.update(
f"found {community_component_cnt} latest community root component(s)- retrieving children, sources & upstreams." # noqa
f"found {community_component_cnt} latest community provided child component(s)- retrieving children, sources & upstreams." # noqa
)
with multiprocessing.Pool() as pool:
for processed_component in pool.map(
partial(process_component, self.community_session, search_latest_params),
partial(process_component, self.community_session, search_provides_params),
latest_community_components,
):
results.append(processed_component)

if self.search_provides:
search_provides_params = copy.deepcopy(params)
if self.search_latest:
search_latest_params = copy.deepcopy(params)
if not (self.strict_name_search):
search_provides_params["re_provides_name"] = component_name
search_latest_params["re_name"] = component_name
else:
search_provides_params["provides_name"] = component_name
search_latest_params["name"] = component_name
if self.ns:
search_provides_params["namespace"] = self.ns
search_provides_params["latest_components_by_streams"] = "True"
status.update("searching latest provided child component(s).")
latest_components_cnt = self.corgi_session.components.count(**search_provides_params)
status.update(f"found {latest_components_cnt} latest provides component(s).")
search_latest_params["namespace"] = self.ns
search_latest_params["root_components"] = "True"
search_latest_params["latest_components_by_streams"] = "True"
status.update("searching latest root component(s).")
latest_components_cnt = self.corgi_session.components.count(**search_latest_params)
status.update(f"found {latest_components_cnt} latest component(s).")
latest_components = self.corgi_session.components.retrieve_list_iterator_async(
**search_provides_params, max_results=10000
)

status.update(
f"found {latest_components_cnt} latest provides child component(s)- retrieving children, sources & upstreams." # noqa
**search_latest_params, max_results=10000
)
status.update(f"found {latest_components_cnt} latest root component(s).") # noqa
with multiprocessing.Pool() as pool:
for processed_component in pool.map(
partial(process_component, self.corgi_session, search_provides_params),
partial(process_component, self.corgi_session, search_latest_params),
latest_components,
):
results.append(processed_component)

if not self.no_community:
status.update("searching latest community provided child component(s).")
status.update("searching latest community root component(s).")
community_component_cnt = self.community_session.components.count(
**search_provides_params
**search_latest_params
)
status.update(
f"found {community_component_cnt} latest community provided child component(s)." # noqa
f"found {community_component_cnt} latest community root component(s)." # noqa
)
latest_community_components = (
self.community_session.components.retrieve_list_iterator_async(
**search_provides_params, max_results=10000
**search_latest_params, max_results=10000
)
)
status.update(
f"found {community_component_cnt} latest community provided child component(s)- retrieving children, sources & upstreams." # noqa
f"found {community_component_cnt} latest community root component(s)- retrieving children, sources & upstreams." # noqa
)
with multiprocessing.Pool() as pool:
for processed_component in pool.map(
partial(process_component, self.community_session, search_provides_params),
partial(process_component, self.community_session, search_latest_params),
latest_community_components,
):
results.append(processed_component)
Expand Down
6 changes: 5 additions & 1 deletion scripts/smoke-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,8 @@ griffon service products-contain-component v2v-conversion-host-ansible -vvv --i
griffon service products-contain-component 'compat-sap-c++-12'
griffon service products-contain-component -r 'compat-sap-c\+\+-12'
#griffon service products-contain-component -s 'compat-sap-c++-12'
griffon service products-contain-component runc
griffon service products-contain-component runc
griffon service products-contain-component github.com/go-redis/redis/v8/internal/hscan --include-container-roots --include-inactive-product-streams --no-filter-rh-naming --include-product-streams-excluded-components
griffon service products-contain-component pdf-generator -vvv --include-container-roots
griffon service products-contain-component -s wireshark -v
griffon service products-contain-component "hypershift-cloudwatch-loggging" --include-container-roots

0 comments on commit d6b2a8b

Please sign in to comment.