Skip to content
This repository has been archived by the owner on Mar 13, 2022. It is now read-only.

Watch properly decode resourceVersion from custom object response #64

Merged
merged 1 commit into from
Apr 27, 2018

Conversation

roycaihw
Copy link
Member

fixes kubernetes-client/python#503

Watch deserializes a CR json response into a dictionary instead of an object of a class, because we don't have model defined for CR, and hasattr() doesn't work for dict. As a result watch failed to update resource_version from last response. This PR tries getting resource version if the response is deserialized into a dictionary.

@roycaihw roycaihw force-pushed the crd-watch branch 4 times, most recently from 69d7445 to e824e81 Compare April 26, 2018 23:40
@roycaihw
Copy link
Member Author

cc @mbohlool @yliaog

watch/watch.py Outdated
# For custom objects that we don't have model defined, json
# deserialization results in dictionary
elif isinstance(js['object'], dict) and 'metadata' in js['object']:
self.resource_version = js['object']['metadata'][
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to check whether 'resourceVersion' is present in js['object']['metadata']

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@codecov-io
Copy link

Codecov Report

Merging #64 into master will increase coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #64      +/-   ##
==========================================
+ Coverage   93.36%   93.43%   +0.07%     
==========================================
  Files          11       11              
  Lines         949      960      +11     
==========================================
+ Hits          886      897      +11     
  Misses         63       63
Impacted Files Coverage Δ
watch/watch_test.py 98.13% <100%> (+0.17%) ⬆️
watch/watch.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 789de6a...38cc265. Read the comment docs.

@yliaog yliaog merged commit 5784a38 into kubernetes-client:master Apr 27, 2018
@roycaihw roycaihw deleted the crd-watch branch April 27, 2018 21:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Watch CRD receives the same event
3 participants