Add 'annotations' to capsule API

Implements: blueprint add-annotations-to-capsule
Change-Id: Ibf3f801596c3a768b05fca9ccbef555ddba319af
This commit is contained in:
Hongbin Lu 2019-12-21 20:43:56 +00:00
parent 2bf646e9bd
commit 0492c35723
14 changed files with 55 additions and 8 deletions

View File

@ -28,7 +28,7 @@
test-config:
$TEMPEST_CONFIG:
container_service:
min_microversion: 1.37
min_microversion: 1.38
post-config:
$ZUN_CONF:
docker:

View File

@ -43,6 +43,7 @@ Capsule Template
- metadata: capsule-metadata-request
- metadata.labels: capsule-labels-request
- metadata.name: capsule-name-request
- metadata.annotations: capsule-annotations-request
- spec: capsule-spec-request
.. _create-capsule-spec:
@ -114,6 +115,7 @@ Capsule
- uuid: capsule-uuid
- name: capsule-name
- labels: capsule-labels
- annotations: capsule-annotations
- restart_policy: capsule-restart_policy
- created_at: created_at
- updated_at: updated_at
@ -206,6 +208,7 @@ Capsule
- uuid: capsule-uuid
- name: capsule-name
- labels: capsule-labels
- annotations: capsule-annotations
- restart_policy: capsule-restart_policy
- created_at: created_at
- updated_at: updated_at
@ -301,6 +304,7 @@ Capsule
- uuid: capsule-uuid
- name: capsule-name
- labels: capsule-labels
- annotations: capsule-annotations
- restart_policy: capsule-restart_policy
- created_at: created_at
- updated_at: updated_at

View File

@ -327,6 +327,22 @@ capsule-addresses:
IP address of the capsule. This includes both ipv4 and/or ipv6 addresses.
in: body
required: true
capsule-annotations:
description: |
The annotations of the capsule.
Annotations is an unstructured key value map stored with a resource
that may be set by external tools to store and retrieve arbitrary metadata.
in: body
required: true
type: object
capsule-annotations-request:
description: |
The annotations added to the capsule.
Annotations is an unstructured key value map stored with a resource
that may be set by external tools to store and retrieve arbitrary metadata.
in: body
required: false
type: object
capsule-args-request:
description: |
The arguments to the command.
@ -466,14 +482,15 @@ capsule-memory:
capsule-metadata-request:
description: |
Capsule metadata in key-value format.
Keys can be ``name`` or ``labels``.
Keys can be ``name``, ``labels`` and ``annotations``.
An example format would look as follows:
.. code-block:: javascript
"metadata": {
"labels": {"app": "web"},
"name": "demo"
"name": "demo",
"annotations": {"key1": "value1"}
}
in: body

View File

@ -70,7 +70,10 @@
"labels": {
"app": "web"
},
"name": "demo"
"name": "demo",
"annotations": {
"key1": "value1"
},
}
}
}

View File

@ -16,6 +16,9 @@
"labels": {
"app": "web"
},
"annotations": {
"key1": "value1"
},
"restart_policy": {
"MaximumRetryCount": "0",
"Name": "always"

View File

@ -18,6 +18,9 @@
"labels": {
"app": "web"
},
"annotations": {
"key1": "value1"
},
"restart_policy": {
"MaximumRetryCount": "0",
"Name": "always"

View File

@ -16,6 +16,9 @@
"labels": {
"app": "web"
},
"annotations": {
"key1": "value1"
},
"restart_policy": {
"MaximumRetryCount": "0",
"Name": "always"

View File

@ -235,6 +235,7 @@ class CapsuleController(base.Controller):
if metadata_info:
new_capsule.name = metadata_info.get('name', None)
new_capsule.labels = metadata_info.get('labels', None)
new_capsule.annotations = metadata_info.get('annotations', None)
# create the capsule in DB so that it generates a 'id'
new_capsule.save()

View File

@ -132,6 +132,10 @@ labels = {
'type': ['object', 'null']
}
annotations = {
'type': ['object', 'null']
}
hints = {
'type': ['object', 'null']
}
@ -373,6 +377,7 @@ capsule_metadata = {
"type": ["object"],
"properties": {
"labels": labels,
"annotations": annotations,
# use the same format as container name
"name": container_name,
}

View File

@ -31,6 +31,7 @@ _basic_keys = (
'restart_policy',
'name',
'labels',
'annotations',
'memory',
'cpu',
'init_containers',

View File

@ -70,10 +70,11 @@ REST_API_VERSION_HISTORY = """REST API Version History:
* 1.35 - Support exposing container ports in capsule
* 1.36 - Add 'tty' to container
* 1.37 - Add 'tty' and 'stdin' to capsule
* 1.38 - Add 'annotations' to capsule
"""
BASE_VER = '1.1'
CURRENT_MAX_VER = '1.37'
CURRENT_MAX_VER = '1.38'
class Version(object):

View File

@ -287,3 +287,9 @@ user documentation.
Add 'tty' and 'stdin' to capsule.
Containers in capsule can specify these two fields.
1.38
----
Add 'annotations' to capsule.
This field stores metadata of the capsule in key-value format.

View File

@ -28,7 +28,7 @@ from zun.tests.unit.db import base
PATH_PREFIX = '/v1'
CURRENT_VERSION = "container 1.36"
CURRENT_VERSION = "container 1.38"
class FunctionalTest(base.DbTestCase):

View File

@ -28,7 +28,7 @@ class TestRootController(api_base.FunctionalTest):
'default_version':
{'id': 'v1',
'links': [{'href': 'http://localhost/v1/', 'rel': 'self'}],
'max_version': '1.37',
'max_version': '1.38',
'min_version': '1.1',
'status': 'CURRENT'},
'description': 'Zun is an OpenStack project which '
@ -37,7 +37,7 @@ class TestRootController(api_base.FunctionalTest):
'versions': [{'id': 'v1',
'links': [{'href': 'http://localhost/v1/',
'rel': 'self'}],
'max_version': '1.37',
'max_version': '1.38',
'min_version': '1.1',
'status': 'CURRENT'}]}