consul-api-gateway
consul-api-gateway copied to clipboard
Parsing Resource Version Is Not Allowed
Overview of the Issue
The Kubernetes API explicitly disallows parsing the metadata.resourceVersion
field on an object as an integer. This project, however, does so as of this commit: https://github.com/hashicorp/consul-api-gateway/pull/26/commits/cb0486e386552b24f74a457df00680785d75a2b7
During a review of code that would be affected by non-numerical resourceVersions, I came upon this code. I'm hoping to better understand what this codebase is using the parsing logic for and if there are other means to that end without using non-supported API behavior. I can see that uses of the parsing seem to all be in precondition functions passed to Upsert*
methods on a store. This looks analogous to the resource version precondition provided by the Kubernetes API server, but the only implementation of the store I found was an in-memory one here - so I'm not entirely sure how the Kubernetes client and server get involved here.
Hi @stevekuznetsov , thanks for reporting!
Personally, I wasn't aware of that note RE: metadata.resourceVersion
. We're just parsing as an integer today to guard against incorrectly updating to an older version; however, it looks like the watcher probably handles that for us. If that's the case, we can just do an equality check as mentioned by the docs that you linked.
Gotcha - if you could help me understand the in-memory storage you have and when/if/how it gets synced to a running k8s API server, I could help fix it!
@andrewstucki provided some additional context over on my PR https://github.com/hashicorp/consul-api-gateway/pull/467#discussion_r1036280221