Skip to content

Commit

Permalink
fix: NoFilterException is redundant, remove it
Browse files Browse the repository at this point in the history
In the former version, when collecting filterable 'glob_file'
specs, an unexpected "Traceback" info will be printed in
the debug log.

In fact, it's not necessary to add the NoFilterException,
in that case, the ContentException can be leveraged, we
just need to log it into the debug instead of raising it again.

Signed-off-by: Xiangce Liu <[email protected]>
  • Loading branch information
xiangce committed Aug 7, 2024
1 parent c4099a0 commit 6fedf62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
5 changes: 0 additions & 5 deletions insights/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ class ContentException(SkipComponent):
pass


class NoFilterException(ContentException):
""" Raised whenever no filters added to a `filterable` :class:`datasource`."""
pass


class InvalidContentType(InvalidArchive):
def __init__(self, content_type):
self.msg = 'Invalid content type: "%s"' % content_type
Expand Down
11 changes: 6 additions & 5 deletions insights/core/spec_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from insights.core.exceptions import (
BlacklistedSpec,
ContentException,
NoFilterException,
SkipComponent)
from insights.core.plugins import component, datasource, is_datasource
from insights.core.serde import deserializer, serializer
Expand Down Expand Up @@ -191,7 +190,7 @@ def validate(self):
if (self.ds and filters.ENABLED and
any(s.filterable for s in dr.get_registry_points(self.ds)) and
not filters.get_filters(self.ds)):
raise NoFilterException("Skipping %s due to no filters." % dr.get_name(self.ds))
raise ContentException("Skipping %s due to no filters." % dr.get_name(self.ds))
# 2.2 Customer Prohibits Collection
if not blacklist.allow_file("/" + self.relative_path):
log.warning("WARNING: Skipping file %s", "/" + self.relative_path)
Expand Down Expand Up @@ -367,7 +366,7 @@ def validate(self):
if (self.ds and filters.ENABLED and
any(s.filterable for s in dr.get_registry_points(self.ds)) and
not filters.get_filters(self.ds)):
raise NoFilterException("Skipping %s due to no filters." % dr.get_name(self.ds))
raise ContentException("Skipping %s due to no filters." % dr.get_name(self.ds))
# 2.2 Customer Prohibits Collection
if not blacklist.allow_command(self.cmd):
log.warning("WARNING: Skipping command %s", self.cmd)
Expand Down Expand Up @@ -702,6 +701,8 @@ def __call__(self, broker):
results.append(self.kind(
path[len(root):], root=root, save_as=self.save_as,
ds=self, ctx=ctx, cleaner=cleaner))
except ContentException as ce:
log.debug(ce)
except Exception:
log.debug(traceback.format_exc())
if results:
Expand Down Expand Up @@ -770,8 +771,8 @@ def __call__(self, broker):
return self.kind(
ctx.locate_path(p), root=root, save_as=self.save_as,
ds=self, ctx=ctx, cleaner=cleaner)
except NoFilterException as nfe:
raise nfe
except ContentException as ce:
log.debug(ce)
except Exception:
pass
raise ContentException("None of [%s] found." % ', '.join(self.paths))
Expand Down

0 comments on commit 6fedf62

Please sign in to comment.