mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
fix: fetch only adopted ephemeral report (#10148)
Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
This commit is contained in:
parent
c9d821ee72
commit
e66a550560
1 changed files with 11 additions and 7 deletions
|
@ -202,7 +202,7 @@ func (c *controller) createVapMap() (sets.Set[string], error) {
|
|||
return results, nil
|
||||
}
|
||||
|
||||
func (c *controller) findEphemeralReports(ctx context.Context, namespace, name string) ([]kyvernov1alpha2.ReportInterface, error) {
|
||||
func (c *controller) findOwnedEphemeralReports(ctx context.Context, namespace, name string) ([]kyvernov1alpha2.ReportInterface, error) {
|
||||
selector, err := reportutils.SelectorResourceUidEquals(types.UID(name))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -219,9 +219,11 @@ func (c *controller) findEphemeralReports(ctx context.Context, namespace, name s
|
|||
return nil, err
|
||||
}
|
||||
for _, report := range reports.Items {
|
||||
if len(report.OwnerReferences) != 0 {
|
||||
report := report
|
||||
results = append(results, &report)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
reports, err := c.client.ReportsV1().EphemeralReports(namespace).List(ctx, metav1.ListOptions{
|
||||
LabelSelector: selector.String(),
|
||||
|
@ -233,10 +235,12 @@ func (c *controller) findEphemeralReports(ctx context.Context, namespace, name s
|
|||
return nil, err
|
||||
}
|
||||
for _, report := range reports.Items {
|
||||
if len(report.OwnerReferences) != 0 {
|
||||
report := report
|
||||
results = append(results, &report)
|
||||
}
|
||||
}
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
||||
|
@ -383,11 +387,11 @@ func (c *controller) backReconcile(ctx context.Context, logger logr.Logger, _, n
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if report == nil {
|
||||
if report != nil {
|
||||
reports = append(reports, report)
|
||||
}
|
||||
// get ephemeral reports
|
||||
ephemeralReports, err := c.findEphemeralReports(ctx, namespace, name)
|
||||
ephemeralReports, err := c.findOwnedEphemeralReports(ctx, namespace, name)
|
||||
if err != nil {
|
||||
if !apierrors.IsNotFound(err) {
|
||||
return err
|
||||
|
|
Loading…
Reference in a new issue