Skip to content

Commit

Permalink
fix: disable rv based filtering
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
  • Loading branch information
vishal-chdhry committed Jul 7, 2024
1 parent a7dacb2 commit 3dd1083
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 58 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/conformance-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
branches:
- "main"

push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/migration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
branches:
- "main"

push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand Down
13 changes: 3 additions & 10 deletions pkg/api/cephr.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,9 @@ func (c *cephrStore) Watch(ctx context.Context, options *metainternalversion.Lis
events := make([]watch.Event, len(list.Items))
for i, pol := range list.Items {
report := pol.DeepCopy()
if report.Generation == 1 || report.Generation == 0 {
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
} else {
events[i] = watch.Event{
Type: watch.Modified,
Object: report,
}
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
}
return c.broadcaster.WatchWithPrefix(events)
Expand Down
13 changes: 3 additions & 10 deletions pkg/api/cpolr.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,9 @@ func (c *cpolrStore) Watch(ctx context.Context, options *metainternalversion.Lis
events := make([]watch.Event, len(list.Items))
for i, pol := range list.Items {
report := pol.DeepCopy()
if report.Generation == 1 || report.Generation == 0 {
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
} else {
events[i] = watch.Event{
Type: watch.Modified,
Object: report,
}
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
}
return c.broadcaster.WatchWithPrefix(events)
Expand Down
13 changes: 3 additions & 10 deletions pkg/api/ephr.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,9 @@ func (p *ephrStore) Watch(ctx context.Context, options *metainternalversion.List
events := make([]watch.Event, len(list.Items))
for i, pol := range list.Items {
report := pol.DeepCopy()
if report.Generation == 1 || report.Generation == 0 {
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
} else {
events[i] = watch.Event{
Type: watch.Modified,
Object: report,
}
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
}
return p.broadcaster.WatchWithPrefix(events)
Expand Down
34 changes: 16 additions & 18 deletions pkg/api/filter.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
package api

import (
"strconv"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
)

func allowObjectListWatch(object metav1.ObjectMeta, labelSelector labels.Selector, desiredRv uint64, rvmatch metav1.ResourceVersionMatch) (bool, uint64, error) {
rv, err := strconv.ParseUint(object.ResourceVersion, 10, 64)
if err != nil {
return false, 0, err
}
// rv, err := strconv.ParseUint(object.ResourceVersion, 10, 64)
// if err != nil {
// return false, 0, err
// }

switch rvmatch {
case metav1.ResourceVersionMatchExact:
if rv != desiredRv {
return false, 0, nil
}
default:
if rv < desiredRv {
return false, 0, nil
}
}
// switch rvmatch {
// case metav1.ResourceVersionMatchExact:
// if rv != desiredRv {
// return false, 0, nil
// }
// default:
// if rv < desiredRv {
// return false, 0, nil
// }
// }

if labelSelector == nil {
return true, rv, nil
return true, 1, nil
}

if labelSelector.Matches(labels.Set(object.Labels)) {
return true, rv, nil
return true, 1, nil
} else {
return false, 0, nil
}
Expand Down
13 changes: 3 additions & 10 deletions pkg/api/polr.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,9 @@ func (p *polrStore) Watch(ctx context.Context, options *metainternalversion.List
events := make([]watch.Event, len(list.Items))
for i, pol := range list.Items {
report := pol.DeepCopy()
if report.Generation == 1 || report.Generation == 0 {
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
} else {
events[i] = watch.Event{
Type: watch.Modified,
Object: report,
}
events[i] = watch.Event{
Type: watch.Added,
Object: report,
}
}
return p.broadcaster.WatchWithPrefix(events)
Expand Down

0 comments on commit 3dd1083

Please sign in to comment.