fiaas / k8s

Python client library for the Kubernetes API
https://fiaas.github.io/
Apache License 2.0
39 stars 24 forks source link

Updated Watcher to use Bookmark events and restart watch from last observed event #94

Closed MichelCarroll closed 2 years ago

MichelCarroll commented 4 years ago

This PR is in response to #70 and #71.

I modified the k8s.watcher module to:

Please let me know what you think.

gregjones commented 4 years ago

I think it looks good, thanks for the contribution. I did a bit of testing locally, and then some reading of the API docs, and it seems it's expected that clients handle a "410 Gone" status from the API when sending the resourceVersion constraint in a query, as the server doesn't guarantee to know about old events:

{"type":"ERROR","object":{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"too old resource version: 1312242788 (1474332294)","reason":"Gone","code":410}}

Catching that error and setting the last_seen_version back to None should work for this. I think it would be more friendly if the library took care of this, rather than leaving it up to clients

mortenlj commented 4 years ago

/sem-approve

mortenlj commented 4 years ago

☝️ Trying to get semaphore to build the PR...

MichelCarroll commented 4 years ago

@gregjones Good point. I'll add handling for the "too old resource version" case.

@mortenlj Indeed, I'll look at Semaphore and make the adjustments you suggested.

I found your "hacktoberfest" tagged issues. I figured this was a good opportunity to learn more about the k8s API, as well as levelling up my Python skills.

mortenlj commented 3 years ago

@MichelCarroll : Any movement on this?