Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Update watch resource_version on BOOKMARK events. #1796

Closed

Conversation

snjypl
Copy link

@snjypl snjypl commented May 8, 2022

The BOOKMARK feature was not getting used properly.

it is expected that on the BOOKMARK event, the watch should update it's resource_version to the one in the BOOKMARK event.

Currently the BOOKMARK event was considered same as ERROR, because of which the watch resource_version was not updated.

we are now decoding BOOKMARK event as a object/dict, and also updating the watch.resource_version

/kind bug

Fixes #1729
Related:
#23578
#21087

NONE

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels May 8, 2022
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 8, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: snjypl / name: sanjayp (f379bba)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label May 8, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @snjypl!

It looks like this is your first PR to kubernetes-client/python 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/python has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: snjypl
To complete the pull request process, please assign yliaog after the PR has been reviewed.
You can assign the PR to them by writing /assign @yliaog in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested review from fabianvf and yliaog May 8, 2022 20:07
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels May 8, 2022
@snjypl snjypl force-pushed the bugfix/1729-bookmarkevents branch from 9bf511b to f379bba Compare May 8, 2022 20:13
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels May 8, 2022
@snjypl
Copy link
Author

snjypl commented May 8, 2022

since the resoureVersion is the only thing that matters in an BOOKMARK event.
i don't think, it is required or expected to convert the bookmark event to the return_type since bookmark event will not have all the required fields.

when we treat it as a ERROR, we skip updating the watcher.resource_version to the one in bookmark event, which defeats the purpose of having the BOOKMARK feature.

and as far as de-serializing the bookmark event is concerned, the client should be fine with a dict object. the client is expected to check the event['TYPE'] and deal with the bookmark event as a dict

@snjypl snjypl changed the title FIX: Update watch resource_version on BOOKAMRK events. FIX: Update watch resource_version on BOOKMARK events. May 8, 2022
@ecerulm
Copy link

ecerulm commented May 9, 2022

The current behaviour when allow_watch_bookmarks=True and resource_version=<alreadyexpiredresourceversion is to raise an ApiException (410) , will this PR change that behaviour?

@snjypl
Copy link
Author

snjypl commented May 9, 2022

The current behaviour when allow_watch_bookmarks=True and resource_version=<alreadyexpiredresourceversion is to raise an ApiException (410) , will this PR change that behaviour?

no, it won't. it is the expected behavior.

@roycaihw
Copy link
Member

roycaihw commented May 9, 2022

/assign @ecerulm

@ecerulm
Copy link

ecerulm commented May 9, 2022

/assign @ecerulm

@roycaihw , what do you want me to do here?

@roycaihw
Copy link
Member

roycaihw commented May 9, 2022

It looks like you've been commenting on this PR already. Would you mind doing a first round of review? @ecerulm

@ecerulm
Copy link

ecerulm commented May 10, 2022

@roycaihw I'm not familiar with the setup of this project and how contributions are made, this PR is based on master which seems 23.0.1 , but the latest release is 23.3.0 (tag v23.3.0) , are PR supposed to be based on the master, on the tag v23.3.0 or on the tag 23.6.0?

@ecerulm
Copy link

ecerulm commented May 10, 2022

If I understand right , before with `allow_watch_bookmarks=True' you could have a loop like this

for event in  watcher.stream(v1.list_namespaced_pod, namespace, allow_watch_bookmarks=True):
  print(event['object'].metadata.resource_version

after the introduction of this PR the following will raise an AttributeError: 'dict' object has not attribute 'metadata' when it reaches a bookmark event, event['object'].metadata is of type V1ObjectMeta in the other events but it's of type dict for bookmark event.

That can potentially break the code of people already using allow_watch_bookmarks=True today when they upgrade to a version containing this PR code.

I'm not sure about the rules about backwards compatibility that this projects follows, it may be ok. I think somebody else should review this, @roycaihw , I'm not that familiar with the code base.

1 similar comment
@ecerulm
Copy link

ecerulm commented May 10, 2022

If I understand right , before with `allow_watch_bookmarks=True' you could have a loop like this

for event in  watcher.stream(v1.list_namespaced_pod, namespace, allow_watch_bookmarks=True):
  print(event['object'].metadata.resource_version

after the introduction of this PR the following will raise an AttributeError: 'dict' object has not attribute 'metadata' when it reaches a bookmark event, event['object'].metadata is of type V1ObjectMeta in the other events but it's of type dict for bookmark event.

That can potentially break the code of people already using allow_watch_bookmarks=True today when they upgrade to a version containing this PR code.

I'm not sure about the rules about backwards compatibility that this projects follows, it may be ok. I think somebody else should review this, @roycaihw , I'm not that familiar with the code base.

@snjypl
Copy link
Author

snjypl commented May 10, 2022

@ecerulm

If I understand right , before with `allow_watch_bookmarks=True' you could have a loop like this

for event in  watcher.stream(v1.list_namespaced_pod, namespace, allow_watch_bookmarks=True):
  print(event['object'].metadata.resource_version

No, even with the latest release you will get the same error. even now bookmark event is returned as dict.

this PR does not change that. so it is not backward incompatible.

@snjypl
Copy link
Author

snjypl commented May 10, 2022

if the user has opted for the bookmark feature by passing allow_watch_bookmarks then this would be the recommenced way of handling the events:

Note: this is the existing behavior. this PR does not change it.

 for event in  watcher.stream(v1.list_namespaced_pod, namespace, allow_watch_bookmarks=True):
           if event['TYPE'] == 'ERROR':
                 # handle error 
           if event['TYPE']  == 'BOOKMARK':
                 # handle bookmark 
           
           print(event['object'].metadata.resource_version

@ecerulm ecerulm removed their assignment May 10, 2022
@snjypl
Copy link
Author

snjypl commented May 13, 2022

@roycaihw @fabianvf @yliaog

is there anything i could do to help with the review? do i need to add any notes?

it will be really great to have this feature.

@snjypl
Copy link
Author

snjypl commented May 27, 2022

@roycaihw ping ! :D

@k8s-triage-robot
Copy link

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-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 25, 2022
@snjypl
Copy link
Author

snjypl commented Aug 25, 2022

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 25, 2022
@k8s-triage-robot
Copy link

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-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 23, 2022
@snjypl
Copy link
Author

snjypl commented Nov 25, 2022

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 25, 2022
@k8s-triage-robot
Copy link

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

This bot triages 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 PR is closed

You can:

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

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

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 23, 2023
@k8s-triage-robot
Copy link

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

This bot triages 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 PR is closed

You can:

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

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

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Mar 25, 2023
@k8s-triage-robot
Copy link

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

This bot triages 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 PR is closed

You can:

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

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

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closed this PR.

In response to this:

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

This bot triages 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 PR is closed

You can:

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

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

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for bookmark events
5 participants