Browse code

Improve documentation of `Version` usage for Swarm API

This fix is an attempt to improve the documentation of
`Version` usage for Swarm API in Swagger docs.

As is shown in the docs updates, `Version` field in Swarm
API is a way to ensure safe concurrency and determinism
so that multiple updates to the same swarm related objects
(Node, Service, etc) will not unintentially overwrite each other.

This fix fixes 29448.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

Yong Tang authored on 2017/02/13 07:44:05
Showing 1 changed files
... ...
@@ -1577,6 +1577,21 @@ definitions:
1577 1577
           Settable: null
1578 1578
           Value: []
1579 1579
 
1580
+  ObjectVersion:
1581
+    description: |
1582
+      The version number of the object such as node, service, etc. This is needed to avoid conflicting writes.
1583
+      The client must send the version number along with the modified specification when updating these objects.
1584
+      This approach ensures safe concurrency and determinism in that the change on the object
1585
+      may not be applied if the version number has changed from the last read. In other words,
1586
+      if two update requests specify the same base version, only one of the requests can succeed.
1587
+      As a result, two separate update requests that happen at the same time will not
1588
+      unintentially overwrite each other.
1589
+    type: "object"
1590
+    properties:
1591
+      Index:
1592
+        type: "integer"
1593
+        format: "int64"
1594
+
1580 1595
   NodeSpec:
1581 1596
     type: "object"
1582 1597
     properties:
... ...
@@ -1613,11 +1628,7 @@ definitions:
1613 1613
       ID:
1614 1614
         type: "string"
1615 1615
       Version:
1616
-        type: "object"
1617
-        properties:
1618
-          Index:
1619
-            type: "integer"
1620
-            format: "int64"
1616
+        $ref: "#/definitions/ObjectVersion"
1621 1617
       CreatedAt:
1622 1618
         type: "string"
1623 1619
         format: "dateTime"
... ...
@@ -1840,11 +1851,7 @@ definitions:
1840 1840
         description: "The ID of the swarm."
1841 1841
         type: "string"
1842 1842
       Version:
1843
-        type: "object"
1844
-        properties:
1845
-          Index:
1846
-            type: "integer"
1847
-            format: "int64"
1843
+        $ref: "#/definitions/ObjectVersion"
1848 1844
       CreatedAt:
1849 1845
         type: "string"
1850 1846
         format: "dateTime"
... ...
@@ -2030,11 +2037,7 @@ definitions:
2030 2030
         description: "The ID of the task."
2031 2031
         type: "string"
2032 2032
       Version:
2033
-        type: "object"
2034
-        properties:
2035
-          Index:
2036
-            type: "integer"
2037
-            format: "int64"
2033
+        $ref: "#/definitions/ObjectVersion"
2038 2034
       CreatedAt:
2039 2035
         type: "string"
2040 2036
         format: "dateTime"
... ...
@@ -2242,11 +2245,7 @@ definitions:
2242 2242
       ID:
2243 2243
         type: "string"
2244 2244
       Version:
2245
-        type: "object"
2246
-        properties:
2247
-          Index:
2248
-            type: "integer"
2249
-            format: "int64"
2245
+        $ref: "#/definitions/ObjectVersion"
2250 2246
       CreatedAt:
2251 2247
         type: "string"
2252 2248
         format: "dateTime"
... ...
@@ -2454,11 +2453,7 @@ definitions:
2454 2454
       ID:
2455 2455
         type: "string"
2456 2456
       Version:
2457
-        type: "object"
2458
-        properties:
2459
-          Index:
2460
-            type: "integer"
2461
-            format: "int64"
2457
+        $ref: "#/definitions/ObjectVersion"
2462 2458
       CreatedAt:
2463 2459
         type: "string"
2464 2460
         format: "dateTime"