Skip to content

Commit

Permalink
Merge pull request #137 from fiaas/fix-watcher-list-namespace
Browse files Browse the repository at this point in the history
Fix watcher initial list always using default namespace
  • Loading branch information
tg90nor authored Jun 3, 2024
2 parents 5c03343 + 97188c0 commit c75fc9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion k8s/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def watch(self, namespace=None):
while self._run_forever:
if last_seen_resource_version is None:
# list all resources and yield a synthetic ADDED watch event for each
model_list = self._model.list_with_meta()
model_list = self._model.list_with_meta(namespace=namespace)
LOG.info("Got %d %s instances from quorum read", len(model_list.items), self._model.__name__)
for obj in model_list.items:
event = SyntheticAddedWatchEvent(obj)
Expand Down
8 changes: 4 additions & 4 deletions tests/k8s/test_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_multiple_events(
watcher._run_forever = False
assert list(gen) == []

api_list_with_meta.assert_called_with()
api_list_with_meta.assert_called_with(namespace=None)
# verify watch_list was called with resourceVersion returned by list call
api_watch_list.assert_called_with(namespace=None, resource_version=list_resource_version, allow_bookmarks=True)

Expand All @@ -126,7 +126,7 @@ def stop_iteration(*args, **kwargs):

assert list(gen) == []

api_list_with_meta.assert_called_with()
api_list_with_meta.assert_called_with(namespace=None)
# verify watch_list was called with resourceVersion returned by list call
api_watch_list.assert_called_with(namespace=None, resource_version=list_resource_version, allow_bookmarks=True)

Expand Down Expand Up @@ -252,7 +252,7 @@ def stop_iteration(*args, **kwargs):

assert list(gen) == []

api_list_with_meta.assert_called_with()
api_list_with_meta.assert_called_with(namespace=namespace)
api_watch_list.assert_called_with(namespace=namespace, resource_version=None, allow_bookmarks=True)

def test_handle_410_list(self, api_watch_list, api_list_with_meta):
Expand Down Expand Up @@ -306,7 +306,7 @@ def test_handle_410_watch(self, api_watch_list, api_list_with_meta):
_assert_event(next(gen), 1, MODIFIED, 3)
# verify list and watch_list has now been called twice, and each call of watch_list used the resourceVersion
# returned by the preceding list call
assert api_list_with_meta.call_args_list == [mock.call(), mock.call()]
assert api_list_with_meta.call_args_list == [mock.call(namespace=None), mock.call(namespace=None)]
assert api_watch_list.call_args_list == [
mock.call(namespace=None, resource_version=first_list_resource_version, allow_bookmarks=True),
mock.call(namespace=None, resource_version=second_list_resource_version, allow_bookmarks=True),
Expand Down

0 comments on commit c75fc9d

Please sign in to comment.