feat(docs): Hugo
[csit.git] / docs / content / introduction / automating_vpp_api_flag_day.md
1 ---
2 bookHidden: true
3 title: "VPP API Flag Day Algorithms"
4 ---
5
6 # VPP API Flag Day Algorithm
7
8 ## Abstract
9
10 This document describes the current solution to the problem of
11 automating the detection of VPP API changes which are not backwards
12 compatible with existing CSIT tests, by defining the "Flag Day"
13 process of deploying a new set of CSIT tests which are compatible
14 with the new version of the VPP API without causing a halt to the
15 normal VPP/CSIT operational CI process. This is initially
16 limited to changes in \*.api files contained in the vpp repo.
17 Eventually the detection algorithm could be extended to include
18 other integration points such as "directory" structure of stats
19 segment or PAPI python library dependencies.
20
21 ## Motivation
22
23 Aside of per-release activities (release report), CSIT also provides testing
24 that requires somewhat tight coupling to the latest (merged but not released)
25 VPP code. Currently, HEAD of one project is run against somewhat older codebase
26 of the other project. Definition of what is the older codebase to use
27 is maintained by CSIT project. For older CSIT codebase, there are so-called
28 "oper" branches. For older VPP codebase, CSIT master HEAD contains identifiers
29 for "stable" VPP builds. Such older codebases are also used for verify jobs,
30 where HEAD of the other project is replaced by the commit under review.
31
32 One particular type of jobs useful for VPP development is trending jobs.
33 They test latests VPP build with latest oper branch of CSIT,
34 and analytics is applied to detect regressions in preformance.
35 For this to work properly, VPP project needs a warning against breaking
36 the assumptions the current oper branch makes about VPP behavior.
37 In the past, the most frequent type of such breakage was API change.
38
39 Earlier attempts to create a process to minimize breakage have focused
40 on creating a new verify job for VPP (called api-crc job) that
41 votes -1 on a change that affects CRC values for API messages CSIT uses.
42 The list of messages and CRC values (multiple "collections" are allowed)
43 is maintained in CSIT repository (in oper branch).
44 The process was less explicit on how should CSIT project maintain such list.
45 As CSIT was not willing to support two incpompatible API messages
46 by the same codebase (commit), there were unavoidable windows
47 where either trenging jobs, or CSIT verify jobs were failing.
48
49 Practice showed that human (or infra) errors can create two kinds of breakages.
50 Either the unavoidable short window gets long, affecting a trending job run
51 or two, or the api-crc job starts giving -1 to innocent changes
52 because oper branch went out of sync with VPP HEAD codebase.
53 This second type of failure prevents any merges to VPP for a long time
54 (12 hours is the typical time, give time zone differences).
55
56 The current version of this document introduces two new requirements.
57 Firstly, the api-crc job should not give false -1, under any
58 (reasonable) circumstances. That means, if a VPP change
59 (nor any of its unmerged ancestor commits) does not affect any CRC values
60 for messages used by CSIT, -1 should only mean "rebase is needed",
61 and rebasing to HEAD should result in +1 from the api-crc job.
62 Secondly, no more than one VPP change is allowed to be processed
63 (at the same time).
64
65 ## Naming
66
67 It is easier to define the process after chosing shorter names
68 for notions that need long definition.
69
70 Note: Everytime a single job is mentioned,
71 in practice it can be a set of jobs covering parts of functionality.
72 A "run" of the set of jobs passes only if each job within the set
73 has been run (again) and passed.
74
75 ## Jobs
76
77 + A *vpp verify* job: Any job run automatically, and voting on open VPP changes.
78   Some verify jobs compile and package VPP for target operating system
79   and processor architecture, the packages are NOT archived (currently).
80   They should be cached somewhere in future to speed up in downstream jobs,
81   but currently each such downstream job can clone and build.
82
83 + The *api-crc* job: Quick verify job for VPP changes, that accesses
84   CSIT repository (checkout latest oper branch HEAD) to figure out
85   whether merging the change is safe from CSIT point of view.
86   Here, -1 means CSIT is not ready. +1 means CSIT looks to be ready
87   for the new CRC values, but there still may be failures on real tests.
88
89 + A *trending* job: Any job that is started by timer and performs testing.
90   It checkouts CSIT latest oper branch HEAD, downloads the most recent
91   completely uploaded VPP package, and unconditionally runs the tests.
92   CRC checks are optional, ideally only written to console log
93   without otherwise affecting the test cases.
94
95 + A *vpp-csit* job: A slower verify job for VPP changes, that accesses CSIT
96   repository and runs tests from the correct CSIT commit (chosen as in trending)
97   against the VPP (built from the VPP patch under review).
98   Vote -1 means there were test failures. +1 means no test failures, meaning
99   there either was no API change, or it was backward compatible.
100
101 + A *csit-vpp* job: Verify job for open CSIT changes. Downloads the
102   (completely uploaded) VPP package marked as "stable", and runs a selection
103   of tests (from the CSIT patch under review).
104   Vote +1 means all tests have passed, so it is safe to merge
105   the patch under review.
106
107 + A *patch-on-patch* job: Manually triggered non-voting job
108   for open CSIT changes. Compiles and packages from VPP source
109   (usually of an unmerged change). Then runs the same tests as csit-vpp job.
110   This job is used to prove the CSIT patch under review is supporting
111   the specified VPP code.
112   In practice, this can be a vpp-csit job started with CSIT_REF set.
113
114 + A *manual verification* is done by a CSIT committer, locally executing steps
115   equivalent to the patch-on-patch job. This can to save time and resources.
116
117 ## CRC Collections
118
119 Any commit in/for the CSIT repository contains a file (supported_crcs.yaml),
120 which contains either one or two collections. A collection is a mapping
121 that maps API message name to its CRC value.
122
123 A collection name specifies which VPP build is this collection for.
124 An API message name is present in a collection if and only if
125 it is used by a test implementation (can be in different CSIT commit)
126 targeted at the VPP build (pointed out by the collection name).
127
128 + The *stable collection*: Usually required, listed first, has comments and name
129   pointing to the VPP build this CSIT commit marks as stable.
130   The stable collection is only missing in deactivating changes (see below)
131   when not mergeable yet.
132
133 + The *active collection*: Optional, listed second, has comments and name
134   pointing to the VPP Gerrit (including patch set number)
135   the currently active API process is processing.
136   The patch set number part can be behind the actual Gerrit state.
137   This is safe, because api-crc job on the active API change will fail
138   if the older patch is no longer API-equivalent to the newer patch.
139
140 ## Changes
141
142 + An *API change*: The name for any Gerrit Change for VPP repository
143   that does not pass api-crc job right away, and needs this whole process.
144   This usually means .api files are edited, but a patch that affects
145   the way CRC values are computed is also an API change.
146
147   Full name could be VPP API Change, but as no CSIT change is named "API change"
148   (and this document does not talk about other FD.io or external projects),
149   "API change" is shorter.
150
151 + A *blocked change*: The name for open Gerrit Change for VPP repository
152   that got -1 from some of voting verify jobs.
153
154 + A *VPP-blocked change": A blocked change which got -1 from some "pure VPP"
155   verify job, meaning no CSIT code has been involved in the vote.
156   Example: "make test" fails.
157
158   VPP contributor is expected to fix the change, or VPP developers
159   are expected to found a cause in an earlier VPP change, and fix it.
160   No interaction with CSIT developers is necessary.
161
162 + A *CSIT-blocked change*: A blocked change which is not VPP-blocked,
163   but does not pass some vpp-csit job.
164   To fix a CSIT-blocked change, an interaction with a CSIT committer
165   is usually necessary. Even if a VPP developer is experienced enough
166   to identify the cause of the failure, a merge to CSIT is usually needed
167   for a full fix.
168
169   This process does not specify what to do with CSIT-blocked changes
170   that are not also API changes.
171
172 + A *candidate API change*: An API change that meets all requirements
173   to become active (see below). Currently, the requirements are:
174
175   + No -1 nor -2 from from any human reviewer.
176
177   + All verify jobs (except vpp-csit ones) pass.
178
179   + +1 from a VPP committer.
180
181   The reason is to avoid situations where an API change becomes active,
182   but the VPP committers are unwilling to merge it for some reason.
183
184 + The *active API change*: The candidate API change currently being processed
185   by the API Flag Day Algorithm.
186   While many API changes can be candidates at the same time,
187   only one is allowed be active at a time.
188
189 + The *activating change*: The name for a Gerrit Change for CSIT repository
190   that does not change the test code, but adds the active CRC collection.
191   Merge of the opening change (to latest CSIT oper branch) defines
192   which API change has become active.
193
194 + The *deactivating change*: The name for Gerrit Change for CSIT repository
195   that only supports tests and CRC values for VPP with the active API change.
196   That implies the previously stable CRC collection is deleted,
197   and any edits to the test implementation are done here.
198
199 + The *mergeable deactivating change*: The deactivating change with additional
200   requirements. Details on the requirements are listed in the next section.
201   Merging this change finishes the process for the active API change.
202
203 It is possible for a single CSIT change to act both as a mergeable
204 deactivating change for one API change, and as an activating change
205 for another API change. As English lacks a good adjective for such a thing,
206 this document does not name this change.
207 When this documents says a change is activating or deactivating,
208 it allows the possibility for the change to fullfill also other purposes
209 (e.g. acting as deactivating / activating change for another API change).
210
211 ## Algorithm Steps
212
213 The following steps describe the application of the API "Flag Day" algorithm:
214
215 #. A VPP patch for an API change is submitted to
216    gerrit for review.
217 #. The api-crc job detects the API CRC values have changed
218    for some messages used by CSIT.
219 #. The api-crc job runs in parallel with any other vpp-csit verify job,
220    so those other jobs can hint at the impact on CSIT.
221    Currently, any such vpp-csit job is non-voting,
222    as the current process does not guarantee such jobs passes
223    when the API change is merged.
224 #. If the api-crc job fails, an email with the appropriate reason
225    is sent to the VPP patch submitter and vpp-api-dev@lists.fd.io
226    including the VPP patch information and .api files that are edited.
227 #. The VPP patch developer works with a VPP committer
228    to ensure the patch meets requirements to become a candidate (see above).
229 #. The VPP patch developer and CSIT team create a CSIT JIRA ticket
230    to identify the work required to support the new VPP API version.
231 #. CSIT developer creates a patch of the deactivating change
232    (upload to Gerrit not required yet).
233 #. CSIT developer runs patch-on-patch job (or manual verification).
234    Both developers iterate until the verification passes.
235    Note that in this phase csit-vpp job is expected to vote -1,
236    as the deactivating change is not mergeable yet.
237 #. CSIT developer creates the activating change, uploads to Gerrit,
238    waits for vote (usual review cycle applies).
239 #. When CSIT committer is satisfied, the activating change is merged
240    to CSIT master branch and cherry-picked to the latest oper branch.
241    This enters a "critical section" of the process.
242    Merges of other activating changes are not allowed from now on.
243    The targeted API change becomes the active API change.
244    This does not break any jobs.
245 #. VPP developer (or CSIT committer) issues a recheck on the VPP patch.
246 #. On failure, VPP and CSIT committers analyze what went wrong.
247    Typically, the active CRC collection is matching only an older patch set,
248    but a newer patch set needs different CRC values.
249    Either due to improvements on the VPP change in question,
250    or due to a rebase over previously merged (unrelated) API change.
251    VPP perhaps needs to rebase, and CSIT definitely needs
252    to merge edits to the active collection. Then issue a recheck again,
253    and iterate until success.
254 #. On success, VPP Committer merges the active API change patch.
255    (This is also a delayed verification of the current active CRC collection.)
256 #. VPP committer sends an e-mail to vpp-api-dev stating the support for
257    the previous CRC values will soon be removed, implying other changes
258    (whether API or not) should be rebased soon.
259 #. VPP merge jobs create and upload new VPP packages.
260    This breaks trending jobs, but both VPP and CSIT verify jobs still work.
261 #. CSIT developer makes the deactivating change mergeable:
262    The stable VPP build indicator is bumped to the build
263    that contains the active API change. The active CRC collection
264    (added by the activating change) is renamed to the new stable collection.
265    (The previous stable collection has already been deleted.)
266    At this time, the deactivating change should be uploaded to Gerrit and
267    csit verify jobs should be triggered.
268 #. CSIT committer reviews the code, perhaps triggering any additional jobs
269    needed to verify the tests using the edited APIs are still working.
270 #. When satisfied, CSIT committer merges the mergeable deactivating change
271    (to both master and oper).
272    The merge fixes trending jobs. VPP and CSIT verify jobs continue to work.
273    The merge also breaks some verify jobs for old changes in VPP,
274    as announced when the active API change was merged.
275    The merge is the point where the process leaves the "critical section",
276    thus allowing merges of activating changes for other API changes.
277 #. CSIT committer sends an e-mail to vpp-api-dev stating the support for
278    the previous CRC values has been removed, and rebase is needed
279    for all affected VPP changes.
280 #. Recheck of existing VPP patches in gerrit may cause the "VPP
281    API Incompatible Change Test" to send an email to the patch
282    submitter to rebase the patch to pick up the compatible VPP API
283    version files.
284
285 ### Real life examples
286
287 Simple API change: https://gerrit.fd.io/r/c/vpp/+/23829
288
289 Activating change: https://gerrit.fd.io/r/c/csit/+/23956
290
291 Mergeable deactivating change: https://gerrit.fd.io/r/c/csit/+/24280
292
293 Less straightforward mergeable deactivating change:
294 https://gerrit.fd.io/r/c/csit/+/22526
295 It shows:
296
297 + Crc edits: supported_crcs.yaml
298 + Version bump: VPP_STABLE_VER_UBUNTU_BIONIC
299 + And even a way to work around failing tests:
300   eth2p-ethicmpv4-ip4base-eth-1tap-dev.robot
301
302 Simple change that is both deactivating and activating:
303 https://gerrit.fd.io/r/c/csit/+/23969