From d6b2a8b9904334da19ba3e5eef4bc316a9c1f26d Mon Sep 17 00:00:00 2001 From: jfuller Date: Fri, 2 Feb 2024 11:35:07 +0100 Subject: [PATCH] if --search-provides finds no children we should then fallback to --search-latest --- CHANGELOG.md | 3 ++ griffon/services/core_queries.py | 85 +++++++++++++++++--------------- scripts/smoke-tests.sh | 6 ++- 3 files changed, 52 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 842010f..6c4a415 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/griffon/services/core_queries.py b/griffon/services/core_queries.py index 98dc4fc..0381782 100644 --- a/griffon/services/core_queries.py +++ b/griffon/services/core_queries.py @@ -342,7 +342,7 @@ 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" @@ -350,98 +350,101 @@ def execute(self, status=None) -> List[Dict[str, Any]]: 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) diff --git a/scripts/smoke-tests.sh b/scripts/smoke-tests.sh index d92fa28..ad85de6 100755 --- a/scripts/smoke-tests.sh +++ b/scripts/smoke-tests.sh @@ -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 \ No newline at end of file +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