db438e027cb6a598a879308e6bb0704c28596fd7
[policy/parent.git] / docs / clamp / controlloop / controlloop.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2
3 .. _clamp-builtin-label:
4
5 CLAMP Metadata Control Loop Automation Management using TOSCA
6 #############################################################
7
8
9 .. contents::
10     :depth: 4
11
12 The idea of using control loops to automatically (or autonomously) perform network management
13 has been the subject of much research in the Network Management research community, see this
14 paper for some background. However, it is only with the advent of ONAP that we have a platform
15 that supports control loops for network management. Before ONAP, Control Loops have been
16 implemented by hard-coding components together and hard coding logic into components. ONAP
17 has taken a step forward towards automatic implementation of Control Loops by allowing
18 parameterization of Control Loops that work on the premise that the Control Loops use a set
19 of analytic, policy, and control components connected together in set ways.
20
21 The goal of the work is to extend and enhance the current ONAP Control Loop support to provide
22 a complete open-source framework for Control Loops. This will enhance the current support to
23 provide TOSCA based Control Loop definition and development, commissioning and run-time management.
24 The participants that comprise a Control Loop and the metadata needed to link the participants
25 together to create a Control Loop are specified in a standardized way using the OASIS TOSCA
26 modelling language. The TOSCA description is then used to commission, instantiate, and manage
27 the Control Loops in the run time system.
28
29 .. image:: images/01-controlloop-overview.png
30
31 1 Terminology
32 =============
33
34 This section describes the terminology used in the system.
35
36 1.1 Control Loop Terminology
37 ----------------------------
38
39 **Control Loop Type:** A definition of a Control Loop in the TOSCA language. This definition describes
40 a certain type of a control loop. The life cycle of instances of a Control Loop Type are managed
41 by CLAMP.
42
43 **Control Loop Instance:** An instance of a Control Loop Type. The life cycle of a Control Loop
44 Instance is managed by CLAMP. A Control Loop Instance is a set of executing elements on which
45 Life Cycle Management (LCM) is executed collectively. For example, a set of microservices may be
46 spawned and executed together to deliver a service. This collection of services is a control loop.
47
48 **Control Loop Element Type:** A definition of a Control Loop Element in the TOSCA language. This
49 definition describes a certain type of Control Loop Element for a control loop in a Control
50 Loop Type.
51
52 **Control Loop Element Instance:** A single entity executing on a participant, with its Life Cycle
53 being managed as part of the overall control loop. For example, a single microservice that is
54 executing as one microservice in a service.
55
56 **CLAMP Control Loop Runtime:** The CLAMP server that holds Control Loop Type definitions and manages
57 the life cycle of Control Loop Instances and their Control Loop Elements in cooperation with
58 participants.
59
60
61 1.2 Participant Terminology
62 ---------------------------
63
64 **Participant Type:** Definition of a type of system or framework that can take part in control
65 loops and a definition of the capabilities of that participant type. A participant advertises
66 its type to the CLAMP Control Loop Runtime.
67
68 **Participant:** A system or framework that takes part in control loops by executing Control Loop
69 Elements in cooperation with the CLAMP Control Loop Runtime. A participant chooses to partake
70 in control loops, to manage Control Loop Elements for CLAMP, and to receive, send and act on
71 LCM messages for the CLAMP runtime.
72
73 1.3 Terminology for Properties
74 ------------------------------
75
76 **Common Properties:** Properties that apply to all Control Loop Instances of a certain Control
77 Loop Type and are specified when a Control Loop Type is commissioned.
78
79 **Instance Specific Properties:** Properties that must be specified for each Control Loop Instance
80 and are specified when a Control Loop Instance is Initialized.
81
82 1.4 Concepts and their relationships
83 ------------------------------------
84
85 The UML diagram below shows the concepts described in the terminology sections above and how
86 they are interrelated.
87
88 .. image:: images/02-controlloop-concepts.png
89
90 The Control Loop Definition concepts describe the types of things that are in the system. These
91 concepts are defined at design time and are passed to the runtime in a TOSCA document. The
92 concepts in the Control Loop Runtime are created by the runtime part of the system using the
93 definitions created at design time.
94
95
96 2 Capabilities
97 ==============
98
99 We consider the capabilities of Control Loops at Design Time and Run Time.
100
101 At Design Time, three capabilities are supported:
102
103 #. **Control Loop Element Definition Specification.** This capability allows users to define Control
104    Loop Element Types and the metadata that can be used on and configured on a Control Loop Element
105    Type. Users also define the Participant Type that will run the Control Loop Element when it is
106    taking part in in a control loop. The post condition of an execution of this capability is that
107    metadata for a Control Loop Element Type is defined in the Control Loop Design Time Catalogue.
108
109 #. **Control Loop Element Definition Onboarding.** This capability allows external users and systems
110    (such as SDC or DCAE-MOD) to define the metadata that can be used on and configured on a Control
111    Loop Element Type and to define the Participant Type that will run the Control Loop Element when
112    it is taking part in in a control loop. The post condition of an execution of this capability
113    is that metadata for a Control Loop Element Type is defined in the Control Loop Design Time
114    Catalogue.
115
116 #. **Control Loop Type Definition.** This capability allows users and other systems to create Control
117    Loop Type definitions by specifying a set of Control Loop Element Definitions from those that
118    are available in the Control Loop Design Time Catalogue. These Control Loop Elements will
119    work together to form Control Loops. In an execution of this capability, a user specifies the
120    metadata for the Control Loop and specifies the set of Control Loop Elements and their Participant
121    Types. The user also selects the correct metadata sets for each participant in the Control Loop
122    Type and defines the overall Control Loop Type metadata. The user also specifies the Common
123    Property Types that apply to all instances of a control loop type and the Instance Specific
124    Property Types that apply to individual instances of a Control Loop Type. The post condition for
125    an execution of this capability is a Control Loop definition in TOSCA stored in the Control Loop
126    Design Time Catalogue.
127
128 .. note::
129     Once a Control Loop Definition is commissioned to the Control Loop Runtime and has been
130     stored in the Run Time Inventory, it cannot be further edited unless it is decommissioned.
131
132
133 At Run Time, the following participant related capabilities are supported:
134
135 #. **System Pre-Configuration.** This capability allows participants to register and deregister
136    with CLAMP. Participants explicitly register with CLAMP when they start. Control Loop Priming
137    is performed on each participant once it registers. The post condition for an execution of this
138    capability is that a participant becomes available (registration) or is no longer available
139    (deregistration) for participation in a control loop.
140
141 #. **Control Loop Priming on Participants.** A participant is primed to support a Control Loop Type.
142    Priming a participant means that the definition of a control loop and the values of Common
143    Property Types that apply to all instances of a control loop type on a participant are sent
144    to a participant. The participant can then take whatever actions it need to do to support
145    the control loop type in question. Control Loop Priming takes place at participant
146    registration and at Control Loop Commissioning. The post condition for an execution of this
147    capability is that all participants in this control loop type are commissioned, that is they
148    are prepared to run instances of their Control Loop Element types.
149
150
151 At Run Time, the following Control Loop Life Cycle management capabilities are supported:
152
153 #. **Control Loop Commissioning:** This capability allows version controlled Control Loop Type
154    definitions to be taken from the Control Loop Design Time Catalogue and be placed in the
155    Commissioned Control Loop Inventory. It also allows the values of Common Property Types
156    that apply to all instances of a Control Loop Type to be set. Further, the Control Loop
157    Type is primed on all concerned participants. The post condition for an execution of this
158    capability is that the Control Loop Type definition is in the Commissioned Control Loop
159    Inventory and the Control Loop Type is primed on concerned participants.
160
161 #. **Control Loop Instance Life Cycle Management:** This capability allows a Control Loop
162    Instance to have its life cycle managed.
163
164    #. **Control Loop Instance Creation:** This capability allows a Control Loop Instance to be
165       created. The Control Loop Type definition is read from the Commissioned Control Loop
166       Inventory and values are assigned to the Instance Specific Property Types defined for
167       instances of the Control Loop Type in the same manner as the existing CLAMP client does.
168       A Control Loop Instance that has been created but has not yet been instantiated on
169       participants is in state UNINITIALIZED. In this state, the Instance Specific Property Type
170       values can be revised and updated as often as the user requires. The post condition for an
171       execution of this capability is that the Control Loop instance is created in the
172       Instantiated Control Loop Inventory but has not been instantiated on Participants.
173
174    #. **Control Loop Instance Update on Participants:** Once the user is happy with the property
175       values, the Control Loop Instance is updated on participants and the Control Loop Elements
176       for this Control Loop Instance are initialized or updated by participants using the control
177       loop metadata. The post condition for an execution of this capability is that the Control
178       Loop instance is updated on Participants.
179
180    #. **Control Loop State Change:** The user can now order the participants to change the state
181       of the Control Loop Instance. If the Control Loop is set to state RUNNING, each participant
182       begins accepting and processing control loop events and the Control Loop Instance is set
183       to state RUNNING in the Instantiated Control Loop inventory. The post condition for an
184       execution of this capability is that the Control Loop instance state is changed on
185       participants.
186
187    #. **Control Loop Instance Monitoring:** This capability allows Control Loop Instances to be
188       monitored. Users can check the status of Participants, Control Loop Instances, and Control
189       Loop Elements. Participants report their overall status and the status of Control Loop
190       Elements they are running periodically to CLAMP. Clamp aggregates these status reports
191       into an aggregated Control Loop Instance status record, which is available for monitoring.
192       The post condition for an execution of this capability is that Control Loop Instances are
193       being monitored.
194
195    #. **Control Loop Instance Supervision:** This capability allows Control Loop Instances to be
196       supervised. The CLAMP runtime expects participants to report on Control Loop Elements
197       periodically. The CLAMP runtime checks that periodic reports are received and that each
198       Control Loop Element is in the state it should be in. If reports are missed or if a
199       Control Loop Element is in an incorrect state, remedial action is taken and notifications
200       are issued. The post condition for an execution of this capability is that Control Loop
201       Instances are being supervised by the CLAMP runtime.
202
203    #. **Control Loop Instance Removal from Participants:** A user can order the removal of a Control
204       Loop Instance from participants. The post condition for an execution of this capability is
205       that the Control Loop instance is removed from Participants.
206
207    #. **Control Loop Instance Deletion:** A user can order the removal of a Control Loop Instance
208       from the CLAMP runtime. Control Loop Instances that are instantiated on participants cannot
209       be removed from the CLAMP runtime. The post condition for an execution of this capability
210       is that the Control Loop instance is removed from Instantiated Control Loop Inventory.
211
212 #. **Control Loop Decommissioning:** This capability allows version controlled Control Loop Type
213    definitions to be removed from the Commissioned Control Loop Inventory. A Control Loop
214    Definition that has instances in the Instantiated Control Loop Inventory cannot be removed.
215    The post condition for an execution of this capability is that the Control Loop Type
216    definition removed from the Commissioned Control Loop Inventory.
217
218 .. note::
219     The system dialogues for run time capabilities are described in detail on the
220     System Level Dialogues page.
221
222
223 2.1 Control Loop Instance States
224 --------------------------------
225
226 When a control loop definition has been commissioned, instances of the control loop can be
227 created, updated, and deleted. The system manages the lifecycle of control loops and control
228 loop elements following the state transition diagram below.
229
230 .. image:: images/03-controlloop-instance-states.png
231
232 3 Overall Target Architecture
233 =============================
234
235 The diagram below shows an overview of the architecture of TOSCA based Control Loop
236 Management in CLAMP.
237
238 .. image:: images/04-overview.png
239
240 Following the ONAP Reference Architecture, the architecture has a Design Time part and
241 a Runtime part.
242
243 The Design Time part of the architecture allows a user to specify metadata for participants.
244 It also allows users to compose control loops. The Design Time Catalogue contains the metadata
245 primitives and control loop definition primitives for composition of control loops. As shown
246 in the figure above, the Design Time component provides a system where Control Loops can be
247 designed and defined in metadata. This means that a Control Loop can have any arbitrary
248 structure and the Control Loop developers can use whatever analytic, policy, or control
249 participants they like to implement their Control Loop. At composition time, the user
250 parameterises the Control Loop and stores it in the design time catalogue. This catalogue
251 contains the primitive metadata for any participants that can be used to compose a Control
252 Loop. A Control Loop SDK is used to compose a Control Loop by aggregating the metadata for
253 the participants chosen to be used in a Control Loop and by constructing the references between
254 the participants. The architecture of the Control Loop Design Time part will be elaborated in
255 future releases.
256
257 Composed Control Loops are commissioned on the run time part of the system, where they are
258 stored in the Commissioned Control Loop inventory and are available for instantiation. The
259 Commissioning component provides a CRUD REST interface for Control Loop Types, and implements
260 CRUD of Control Loop Types. Commissioning also implements validation and persistence of incoming
261 Control Loop Types. It also guarantees the integrity of updates and deletions of Control Loop
262 Types, such as performing updates in accordance with semantic versioning rules and ensuring that
263 deletions are not allowed on Control Loop Types that have instances defined.
264
265 The Instantiation component manages the Life Cycle Management of Control Loop Instances and
266 their Control Loop Elements. It publishes a REST interface that is used to create Control Loop
267 Instances and set values for Common and Instance Specific properties. This REST interface is
268 public and is used by the CLAMP GUI. It may also be used by any other client via the public
269 REST interface. the REST interface also allows the state of Control Loop Instances to be changed.
270 A user can change the state of Control Loop Instances as described in the state transition
271 diagram shown in section 2 above. The Instantiation component issues update and state change
272 messages via DMaaP to participants so that they can update and manage the state of the Control
273 Loop Elements they are responsible for. The Instantiation component also implements persistence
274 of Control Loop Instances, control loop elements, and their state changes.
275
276 The Monitoring component reads updates sent by participants. Participants report on the
277 state of their Control Loop Elements periodically and in response to a message they have
278 received from the Instantiation component. The Monitoring component reads the contents of
279 the participant messages and persists their state updates and statistics records. It also
280 publishes a REST interface that publishes the current state of all Participants, Control
281 Loop Instances and their Control Loop Elements, as well as publishing Participant and
282 Control Loop statistics.
283
284 The Supervision component is responsible for checking that Control Loop Instances are correctly
285 instantiated and are in the correct state (UNINITIALIZED/READY/RUNNING). It also handles
286 timeouts and on state changes to Control Loop Instances, and retries and rolls back state
287 changes where state changes failed.
288
289 A Participant is an executing component that partakes in control loops. More explicitly, a
290 Participant is something that implements the Participant Instantiation and Participant
291 Monitoring messaging protocol over DMaaP for Life Cycle management of Control Loop Elements.
292 A Participant runs Control Loop Elements and manages and reports on their life cycle
293 following the instructions it gets from the CLAMP runtime in messages delivered over DMaaP.
294
295 In the figure above, five participants are shown. A Configuration Persistence Participant
296 manages Control Loop Elements that interact with the ONAP Configuration Persistence Service
297 to store common data. The DCAE Participant runs Control Loop Elements that manage DCAE
298 microservices. The Kubernetes Participant hosts the Control Loop Elements that are managing
299 the life cycle of microservices in control loops that are in a Kubernetes ecosystem. The
300 Policy Participant handles the Control Loop Elements that interact with the Policy Framework
301 to manage policies for control loops. A Controller Participant such as the CDS Participant
302 runs Control Loop Elements that load metadata and configure controllers so that they can
303 partake in control loops. Any third party Existing System Participant can be developed to
304 run Control Loop Elements that interact with any existing system (such as an operator's
305 analytic, machine learning, or artificial intelligence system) so that those systems can
306 partake in control loops.
307
308 4. Other Considerations
309 =======================
310
311 4.1 Management of Control Loop Instance Configurations
312 ------------------------------------------------------
313
314 In order to keep management of versions of the configuration of control loop instances
315 straightforward and easy to implement, the following version management scheme using
316 semantic versioning is implemented. Each configuration of a Control Loop Instance and
317 configuration of a Control Loop Element has a semantic version with 3 digits indicating
318 the major.minor.patch number of the version.
319
320 Note that a configuration means a full set of parameter values for a Control Loop Instance.
321
322 .. image:: images/05-upgrade-states.png
323
324 Change constraints:
325
326 A Control Loop or Control Loop Element in state **RUNNING** can be changed to a higher patch
327 level or rolled back to a lower patch level. This means that hot changes that do not
328 impact the structure of a Control Loop or its elements can be executed.
329
330 A Control Loop or Control Loop Element in state **PASSIVE** can be changed to a higher
331 minor/patch level or rolled back to a lower minor/patch level. This means that structural
332 changes to Control Loop Elements that do not impact the Control Loop as a whole can be
333 executed by taking the control loop to state **PASSIVE**.
334
335 A Control Loop or Control Loop Element in state **UNINITIALIZED** can be changed to a higher
336 major/minor/patch level or rolled back to a lower major/minor/patch level. This means
337 that where the structure of the entire control loop is changed, the control loop must
338 be uninitialized and reinitialized.
339
340 If a Control Loop Element has a minor version change, then its Control Loop Instance must
341 have at least a minor version change.
342
343 If a Control Loop Element has a major version change, then its Control Loop Instance must
344 have a major version change.
345
346 4.2 Scalability
347 ---------------
348
349 The system is designed to be inherently scalable. The CLAMP runtime is stateless, all state
350 is preserved in the Instantiated Control Loop inventory in the database. When the user
351 requests an operation such as an instantiation, activation, passivation, or an uninitialization
352 on a Control Loop Instance, the CLAMP runtime broadcasts the request to participants over
353 DMaaP and saves details of the request to the database. The CLAMP runtime does not directly
354 wait for responses to requests.
355
356 When a request is broadcast on DMaaP, the request is asynchronously picked up by participants
357 of the types required for the Control Loop Instance and those participants manage the life
358 cycle of its control loop elements. Periodically, each participant reports back on the status
359 of operations it has picked up for the Control Loop Elements it controls, together with
360 statistics on the Control Loop Elements over DMaaP. On reception of these participant messages,
361 the CLAMP runtime stores this information to its database.
362
363 The participant to use on a control loop can be selected from the registered participants
364 in either of two ways:
365
366 **Runtime-side Selection:** The CLAMP runtime selects a suitable participant from the list of
367 participants and sends the participant ID that should be used in the Participant Update message.
368 In this case, the CLAMP runtime decides on which participant will run the Control Loop Element
369 based on a suitable algorithm. Algorithms could be round robin based or load based.
370
371 **Participant-side Selection:** The CLAMP runtime sends a list of Participant IDs that may be used
372 in the Participant Update message. In this case, the candidate participants decide among
373 themselves which participant should host the Control Loop Element.
374
375 This approach makes it easy to scale Control Loop life cycle management. As Control Loop
376 Instance counts increase, more than one CLAMP runtime can be deployed and REST/supervision
377 operations on Control Loop Instances can run in parallel. The number of participants can
378 scale because an asynchronous broadcast mechanism is used for runtime-participant communication
379 and there is no direct connection or communication channel between participants and CLAMP
380 runtime servers. Participant state, Control Loop Instance state, and Control Loop Element
381 state is held in the database, so any CLAMP runtime server can handle operations for any
382 participant. Because many participants of a particular type can be deployed and participant
383 instances can load balance control loop element instances for different Control Loop Instances
384 of many types across themselves using a mechanism such as a Kubernetes cluster.
385
386
387 4.3 Sandboxing and API Gateway Support
388 --------------------------------------
389
390 At runtime, interaction between ONAP platform services and application microservices are
391 relatively unconstrained, so interactions between Control Loop Elements for a given Control
392 Loop Instance remain relatively unconstrained. A proposal to support access-controlled access
393 to and between ONAP services will improve this. This can be complemented by intercepting and
394 controlling services accesses between Control Loop Elements for Control Loop Instances for
395 some/all Control Loop types.
396
397 API gateways such as Kong have emerged as a useful technology for exposing and controlling
398 service endpoint access for applications and services. When a Control Loop Type is onboarded,
399 or when Control Loop Instances are created in the Participants, CLAMP can configure service
400 endpoints between Control Loop Elements to redirect through an API Gateway.
401
402 Authentication and access-control rules can then be dynamically configured at the API gateway
403 to support constrained access between Control Loop Elements and Control Loop Instances.
404
405 The diagram below shows the approach for configuring API Gateway access at Control Loop
406 Instance and Control Loop Element level.
407
408 .. image:: images/06-api-gateway-sandbox.png
409
410 At design time, the Control Loop type definition specifies the type of API gateway configuration
411 that should be supported at Control Loop and Control Loop Element levels.
412
413 At runtime, the CLAMP can configure the API gateway to enable (or deny) interactions between
414 Control Loop Instances and individually for each Control Loop Element. All service-level
415 interactions in/out of a Control Loop Element, except that to/from the API Gateway, can be
416 blocked by networking policies, thus sandboxing a Control Loop Element and an entire Control
417 Loop Instance if desired. Therefore, a Control Loop Element will only have access to the APIs
418 that are configured and enabled for the Control Loop Element/Instance in the API gateway.
419
420 For some Control Loop Element Types the Participant can assist with service endpoint
421 reconfiguration, service request/response redirection to/from the API Gateway, or
422 annotation of requests/responses.
423
424 Once the Control Loop instance is instantiated on participants, the participants configure
425 the API gateway with the Control Loop Instance level configuration and with the specific
426 configuration for their Control Loop Element.
427
428 Monitoring and logging of the use of the API gateway may also be provided. Information and
429 statistics on API gateway use can be read from the API gateway and passed back in monitoring
430 messages to the CLAMP runtime.
431
432 Additional isolation and execution-environment sandboxing can be supported depending on the
433 Control Loop Element Type. For example: ONAP policies for given Control Loop Instances/Types
434 can be executed in a dedicated PDP engine instances; DCAE or K8S-hosted services can executed
435 in isolated namespaces or in dedicated workers/clusters; etc..
436
437
438 5 APIs and Protocols
439 ====================
440
441 The APIs and Protocols used by CLAMP for Control Loops are described on the pages below:
442
443 #. System Level Dialogues
444 #. Defining Control Loops in TOSCA for CLAMP
445 #. REST APIs for CLAMP Control Loops
446 #. The CLAMP Control Loop Participant Protocol
447
448
449 6 Design and Implementation
450 ===========================
451
452 The design and implementation of TOSCA Control Loops in CLAMP is described for each executable entity on the pages below:
453
454 #. The CLAMP Runtime Server
455 #. CLAMP Participants
456 #. The CLAMP GUI
457 #. Building and running CLAMP
458 #. Testing CLAMP