-
Notifications
You must be signed in to change notification settings - Fork 182
resource version reset default when event object resource version inv… #199
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: DrAuYueng 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 |
Welcome @DrAuYueng! |
Codecov Report
@@ Coverage Diff @@
## master #199 +/- ##
==========================================
+ Coverage 92.23% 92.66% +0.42%
==========================================
Files 13 13
Lines 1481 1554 +73
==========================================
+ Hits 1366 1440 +74
+ Misses 115 114 -1
Continue to review full report at Codecov.
|
kubernetes version:v1.14.6 |
/cc |
if self.resource_version is None: | ||
# In some case like 'too old resource version', | ||
# the event type would be ERROR, resource version will be None | ||
self.resource_version = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watching with resourceVersion=0
doesn't guarantee the client to continue watching from the last seen state, and therefore may cause missing watch events. The right way to handle a 410 Gone
response is to perform a LIST request, and start the watch from the resourceVersion
returned by that new list operation (see https://kubernetes.io/docs/reference/using-api/api-concepts/#efficient-detection-of-changes for more details).
This is part of the problems kubernetes-client/python#868 was trying to address
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If catch event type of Error and continue like #133 ,will cause endless loop, current resourceVersion never change, always get Error of message:"too old resource version"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If catch event type of Error and continue like #133 ,will cause endless loop, current resourceVersion never change, always get Error of message:"too old resource version"
Make resourceVersion=0 make sure the watch stream still work even if the wrong init resource version set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will cause endless loop, current resourceVersion never change, always get Error of message:"too old resource version"
I don't think that's what we want and it should not happen
perform a LIST request, and start the watch from the resourceVersion returned by that new list operation
the resourceVersion returned by a LIST request will be the latest resourceVersion, it won't be stale
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closed this PR. In response to this:
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. |
Watch an API resource and stream the result back via a generator, when resource_version specified, may be cause "too old resource version" error, then result would be:
{ "type":"ERROR", "object":{ "kind":"Status", "apiVersion":"v1", "metadata":{ }, "status":"Failure", "message":"too old resource version: 38081900 (64845263)", "reason":"Gone", "code":410 } }
In this case, the func unmarshal_event can not parse the right resource version, actually is None,
the stream while loop continue, the next request will get ApiException: (500) error:
HTTP response headers: HTTPHeaderDict({'Content-Length': '186', 'Content-Type': 'application/json', 'Date': 'Fri, 19 Jun 2020 06:21:06 GMT'}) HTTP response body: b'{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"resourceVersion: Invalid value: \\"None\\": strconv.ParseUint: parsing \\"None\\": invalid syntax","code":500}\n'