17417: Add arm64 packages for our Golang components.
[arvados.git] / doc / user / topics / collection-versioning.html.textile.liquid
1 ---
2 layout: default
3 navsection: userguide
4 title: Using collection versioning
5 ...
6
7 {% comment %}
8 Copyright (C) The Arvados Authors. All rights reserved.
9
10 SPDX-License-Identifier: CC-BY-SA-3.0
11 {% endcomment %}
12
13 When collection versioning is enabled, updating certain collection attributes (@name@, @description@, @properties@, @manifest_text@) will save a copy of the collection state, previous to the update. This copy (a new collection record) will have its own @uuid@, and a @current_version_uuid@ attribute pointing to the current version's @uuid@.
14
15 Every collection has a @version@ attribute that indicates its version number, starting from 1 on new collections and incrementing by 1 with every versionable update. All collections point to their most current version via the @current_version_uuid@ attribute, being @uuid@ and @current_version_uuid@ equal on those collection records that are the current version of themselves. Note that the "current version" collection record doesn't change its @uuid@, "past versions" are saved as new records every time it's needed, pointing to the current collection record.
16
17 A version will be saved when one of the following conditions is true:
18
19 One is by "configuring (system-wide) the collection's idle time":{{site.baseurl}}/admin/collection-versioning.html. This idle time is checked against the @modified_at@ attribute so that the version is saved when one or more of the previously enumerated attributes get updated and the @modified_at@ is at least at the configured idle time in the past. This way, a frequently updated collection won't create lots of version records that may not be useful.
20
21 The other way to trigger a version save, is by setting @preserve_version@ to @true@ on the current version collection record: this ensures that the current state will be preserved as a version the next time it gets updated.
22
23 h3. Collection's past versions behavior & limitations
24
25 Past version collection records are read-only, if you need to make changes to one of them, the suggested approach is to copy it into a new collection before updating.
26
27 Some attributes are automatically synced when they change on the current version: @owner_uuid@, @delete_at@, @trash_at@, @is_trashed@, @replication_desired@ and @storage_classes_desired@. This way, old versions follow the current one on several configurations. In the special case that a current version's @uuid@ gets updated, their past versions get also updated to point to the newer UUID. When a collection is deleted, any past versions are deleted along with it.
28
29 Permissions on past versions are the same as their current version, the system does not allow attaching permission links to old versions. If you need to give special access to someone to a particular old version, the correct procedure is by copying it as a new collection.
30
31 h3. Example: Accessing past versions of a collection
32
33 To request a particular collection with all its versions you should request a list filtering the current version's UUID and passing the @include_old_versions@ query parameter. For example, using the @arv@ command line client:
34
35 <pre>
36 $ arv collection index --filters '[["current_version_uuid", "=", "o967z-4zz18-ynmlhyjbg1arnr2"]]' --include-old-versions
37 {
38  "items":[
39   {
40    "uuid":"o967z-4zz18-i3ucessyo6xxadt",
41    "created_at":"2018-10-05T14:43:38.916885000Z",
42    "modified_at":"2018-10-05T14:44:31.098019000Z",
43    "version":1,
44    "current_version_uuid":"o967z-4zz18-ynmlhyjbg1arnr2"
45   },
46   {
47    "uuid":"o967z-4zz18-ynmlhyjbg1arnr2",
48    "created_at":"2018-10-05T14:43:38.916885000Z",
49    "modified_at":"2018-10-05T14:44:31.078643000Z",
50    "version":2,
51    "current_version_uuid":"o967z-4zz18-ynmlhyjbg1arnr2"
52   }
53  ],
54  "items_available":2
55 }
56 </pre>
57
58 To access a specific collection version using filters:
59
60 <pre>
61 $ arv collection index --filters '[["current_version_uuid", "=", "o967z-4zz18-ynmlhyjbg1arnr2"], ["version", "=", 1]]' --include-old-versions
62 {
63  "items":[
64   {
65    "uuid":"o967z-4zz18-i3ucessyo6xxadt",
66    "created_at":"2018-10-05T14:43:38.916885000Z",
67    "modified_at":"2018-10-05T14:44:31.098019000Z",
68    "version":1,
69    "current_version_uuid":"o967z-4zz18-ynmlhyjbg1arnr2"
70   }
71  ],
72  "items_available":1
73 }
74 </pre>
75
76 You can also access it directly via a GET request using its UUID:
77
78 <pre>
79 $ arv collection get --uuid o967z-4zz18-i3ucessyo6xxadt
80 {
81  "uuid":"o967z-4zz18-i3ucessyo6xxadt",
82  "created_at":"2018-10-05T14:43:38.916885000Z",
83  "modified_at":"2018-10-05T14:44:31.098019000Z",
84  "version":1,
85  "current_version_uuid":"o967z-4zz18-ynmlhyjbg1arnr2"
86 }
87 </pre>
88
89 h3. Example: Ensuring a version is preserved
90
91 As stated before, regardless of the collection's auto-save idle time cluster configuration, the user has the ability to request that a particular collection state should be preserved.
92
93 When working on a collection, if there's a need to preserve the current state as a new version, the @preserve_version@ attribute should be set to @true@. This will trigger a new version creation on the next update, keeping this "version 2" state as a snapshot.
94
95 <pre>
96 $ arv collection update --uuid o967z-4zz18-ynmlhyjbg1arnr2 -c '{"preserve_version":true}'
97 {
98  "uuid":"o967z-4zz18-ynmlhyjbg1arnr2",
99  "created_at":"2018-10-05T14:43:38.916885000Z",
100  "modified_at":"2018-10-05T15:12:57.986454000Z",
101  "version":2,
102  "current_version_uuid":"o967z-4zz18-ynmlhyjbg1arnr2",
103  "preserve_version":true
104 }
105 </pre>
106
107 Once the @preserve_version@ attribute is set to @true@, it cannot be changed to @false@ and it will only be reset when a versionable update on the collection triggers a version save.