metadata.resourceVersion: Invalid value

Fixed error: metadata.resourceVersion: Invalid value: \"\": must be specified for an update when annotating

Change-Id: I0e9ad64eae5a8ee42778c0fa50a3a3345ff25115
Closes-Bug: 1722142
This commit is contained in:
Jiyuan Tang 2017-09-27 15:41:39 +08:00
parent c4b897262b
commit 05a25af13f
1 changed files with 9 additions and 6 deletions

View File

@ -94,12 +94,10 @@ class K8sClient(object):
if self.token:
header.update({'Authorization': 'Bearer %s' % self.token})
while itertools.count(1):
data = jsonutils.dumps({
"metadata": {
"annotations": annotations,
"resourceVersion": resource_version,
}
}, sort_keys=True)
metadata = {"annotations": annotations}
if resource_version:
metadata['resourceVersion'] = resource_version
data = jsonutils.dumps({"metadata": metadata}, sort_keys=True)
response = requests.patch(url, data=data,
headers=header, cert=self.cert,
verify=self.verify_server)
@ -121,6 +119,11 @@ class K8sClient(object):
LOG.debug("Annotations for %(path)s already present: "
"%(names)s", {'path': path,
'names': retrieved_annotations})
LOG.error("Exception response, headers: %(headers)s, "
"content: %(content)s, text: %(text)s"
% {'headers': response.headers,
'content': response.content, 'text': response.text})
raise exc.K8sClientException(response.text)
def watch(self, path):