python icon indicating copy to clipboard operation
python copied to clipboard

Watch Stream does not show recent DELETED or MODIFIED events when restarted, only shows ADDED

Open wilandm opened this issue 3 years ago • 8 comments

What happened (please include outputs or screenshots):

The watch stream method does not show past DELETED or MODIFIED events when the watch is restarted.

If watch.Watch.stream() is running during the event it shows, but if you restart it, out of the older event only ADDED shows. So we are seeing past events, but only of type ADDED.

What you expected to happen:

I expect the DELETED and MODIFIED events to show for events that occurred before the watch was started. This is the same behaviour as kubectl get events -w.

How to reproduce it (as minimally and precisely as possible):

from kubernetes import client, config, watch

config.load_kube_config()

custom_objects_api = client.CustomObjectsApi()

w = watch.Watch()

NAMESPACE = "ncdc-015197-sit"


API_VERSION = "v1beta1"
PLURAL = "bigquerydatasets"
GROUP = "bigquery.cnrm.cloud.google.com"


for event in w.stream(
    custom_objects_api.list_namespaced_custom_object,
    GROUP,
    API_VERSION,
    NAMESPACE,
    PLURAL,
):

    print(
        f"name: {event['object']['metadata']['name']} , type: {event['type']}")

    if event["type"] == "DELETED":
        print("DETECTED deleted")

Ran a short python script above titled test-events.py

Screen Shot 2022-09-23 at 11 00 40 AM

Screen Shot 2022-09-23 at 11 00 52 AM

Screen Shot 2022-09-23 at 11 01 01 AM

I ran the script at 10:05 first opening the watch, then applying my custom resource, followed by deleting it. The ADDED, MODIFIED and DELETED events all show while the stream() is running.

reran the script at 10:06, only get the ADDED events from the past, not DELETED or MODIFIED. Contrast that to the behavior of kubectl get events -w, where I get all past events before streaming updates for new events.

reran the script at 10:15 and 10:16 to confirm the same behaviour again as above.

Anything else we need to know?:

Environment:

  • Kubernetes version (kubectl version): server version is 1.23, git_version: v1.23.9-gke.2100
  • OS (e.g., MacOS 10.13.6): MacOS Monterey v12.5.1
  • Python version (python --version): 3.10.6
  • Python client version (pip list | grep kubernetes): 23.3.0

wilandm avatar Sep 26 '22 14:09 wilandm

/assign @roycaihw

yliaog avatar Sep 26 '22 16:09 yliaog

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Dec 25 '22 17:12 k8s-triage-robot

/remove-lifecycle stale

wilandm avatar Jan 04 '23 15:01 wilandm

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Apr 04 '23 16:04 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar May 04 '23 17:05 k8s-triage-robot

/remove-lifecycle rotten

anthops avatar May 23 '23 00:05 anthops

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jan 21 '24 01:01 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Feb 20 '24 01:02 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Mar 21 '24 02:03 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Mar 21 '24 02:03 k8s-ci-robot