• Stars
    star
    245
  • Rank 165,304 (Top 4 %)
  • Language
    Groovy
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Orchestration engine

Orca

Build Status

Orca Logo

Orca is the orchestration engine for Spinnaker. It is responsible for taking an execution definition and managing the stages and tasks, coordinating the other Spinnaker services.

Orca Executions (either Pipelines or Orchestrations) are composed of Stages which in turn are composed of Tasks. The tasks of a stage share a common context which can be queried across the entire execution allowing multiple stages to coordinate. For example a bake stage publishes details of the image it creates which is then used by a deploy stage.

Orca is a stateless, horizontally scalable service. Spinnaker's execution state is persisted to a backend store and work is distributed evenly through a work queue. So long as your backend persistence layer has capacity, you can freely add or remove Orca servers to match workload demands.

Internals Overview

Domain

The primary domain model is an Execution, of which there are two types: PIPELINE and ORCHESTRATION. The PIPELINE type is for pipelines while ORCHESTRATIONs is unscheduled, ad-hoc API-submitted actions and what you see in the UI under the "Tasks" tab in an Application.

At this point in Spinnakerโ€™s life, these two types are nearly programmatically identical, the key difference being that a Pipeline has a predefined persistent configuration, whereas an Orchestration is arbitarily configured at request-time and serial in execution.

For one Execution, there are one or many Stages organized as a DAG (Directed Acyclic Graph). An Execution supports concurrent branching logic of Stages. These Stages define higher-order, user-friendly actions and concepts, such as "Resize Server Group" or "Deploy" and can be chained together to form complex delivery workflows. Within a Stage, there are one or more Tasks (not to be confused with the Tasks tab in the UI: Internally these are Orchestrations). A Task can be considered an atomic unit of work, focused on a single action. If you are familiar with the Spinnaker UI, you'll note that for every Stage, there are multiple line items that correlate to a Stage's runtime: These are often Tasks. Tasks are always executed sequentially and serially.

It's important to note that a Stage is recursively composable. One stage can have zero to many Synthetic Stages, that is, stages that can occur either BEFORE or AFTER its parent stage. This is most easily illustrated in a Canary stage, which deploys multiple Server Groups (a baseline and canary). While to the end-user this appears to be a single stage, it's actually a composition of multiple Deploy stages with some extra logic on top. Lastly, an Execution's stage graph does not need to be known ahead of time. An Execution can lay its tracks down ahead of itself as it is running, which is how some of the more advanced functionality is implemented, like automatic rollbacks or canary behaviors.

Runtime

Orca uses a distributed queue library, Keiko, to manage its work. Keiko uses atomic messages to progress work through its lifecycle and allows Orca to first be resilient to node failure, as well as spread load evenly across the deployment making Orca easier to scale and operate.

Keiko itself is an abstraction around a delay queue, meaning it can deliver Messages immediately or at specific times in the future, as well as reschedule messages that have already been added to the queue for a new delivery time. This delay queue functionality is pivotal to Orca's performance and operational characteristics when dealing with long running operations.

A Message is a fine-grained unit of work. As an example, a StartStage message will verify that all upstream branches are complete and then perform any logic associated with preparing for the stage's execution. It won't actually perform the stage's core actions. A RunTask is really the only message that actually performs stage work that a user would be familiar with.

Some message types are re-deliverable and can be duplicated, whereas others are not. For example, in a pipeline that has two concurrent stage branches that do not join at the end, there will be two CompleteExecution messages sent. This is fine, because the CompleteExecutionHandler has logic to verify that indeed all stages are in a completed state before marking the entire execution as complete, whether it ultimately be a failure or success.

For every message type, there is a single correlated Handler that contains all of the logic for processing this Message type. A Message's contents are small and the bare minimum of information to process the request: For instance, an Execution is referenced by ID rather than containing its entire state. Orca builds atop these foundational Handlers in the form of StageDefinitionBuilder and other classes to build the DAG and implement actual Spinnaker orchestration logic.

The queue can be categorized into two parts: The QueueProcessor, and its Handlers. Orca uses a single thread to run QueueProcessor, which polls the oldest messages "ready" off the queue. A ready message is one whose delivery time is now or in the past: It is normal to have many more messages in the queue than those that are actually ready.

A separate worker thread pool is used for Handlers. Orca depends on threads in that pool in order to scale sufficiently. You can tune threads either by adjusting the pool size or by increasing the number of Orca instances. By ignoring downstream bottlenecks Orca can scale horizontally to meet Spinnaker work demand.

If the queue starts to back up, Executions and their Tasks will begin to take longer to start or complete. Sometimes the queue will back up because of downstream service pressure (for example, Clouddriver), but may also be due to Orca not having enough threads or persistence capacity.

One further note about the QueueProcessor and its thread pool. The QueueProcessor polls the queue on a regular interval (default 10ms) and tries to fill its thread pool if there's work ready to process. If the thread pool has a core size of 20, and 5 are already busy, it will attempt to take 15 messages off the queue immediately rather than one. This is because in most cases a message takes less than 1ms to complete and we don't want Orca to idle unnecessarily.

Storage & Work Queue

The following storage backends are supported for storing Execution state:

  • Redis (default)
  • MySQL (recommended)

The following backends are supported for the work queue:

  • Redis

Running Orca

Orca requires Redis (and optionally MySQL) to be up and running.

Start Orca via ./gradlew bootRun, or by following the instructions using the Spinnaker installation scripts.

Debugging

To start the JVM in debug mode, set the Java system property DEBUG=true:

./gradlew -DDEBUG=true

The JVM will then listen for a debugger to be attached on port 8183. The JVM will not wait for the debugger to be attached before starting Orca; the relevant JVM arguments can be seen and modified as needed in build.gradle.

More Repositories

1

spinnaker

Spinnaker is an open source, multi-cloud continuous delivery platform for releasing software changes with high velocity and confidence.
Shell
9,298
star
2

kayenta

Automated Canary Service
Java
1,287
star
3

clouddriver

read and write operations across cloud providers
Groovy
432
star
4

swabbie

Spinnaker's clean up service
Kotlin
370
star
5

halyard

A tool for configuring, installing, and updating Spinnaker
Java
308
star
6

deck

Management UI for Spinnaker
TypeScript
303
star
7

igor

Integration with Jenkins and Git for Spinnaker
Groovy
145
star
8

spin

Spinnaker CLI
Go
128
star
9

gate

Spinnaker API Gateway
Groovy
127
star
10

keel

Spinnaker's declarative service
Kotlin
109
star
11

rosco

A bakery for deployable images
Groovy
88
star
12

spinnaker.github.io

spinnaker documentation site
HTML
79
star
13

dcd-spec

Declarative Pipeline specification for Spinnaker
78
star
14

echo

Spinnaker Eventing Service
Java
74
star
15

kleat

A lightweight tool for managing Spinnaker configuration
Go
69
star
16

fiat

Spinnaker auth service
Java
68
star
17

front50

Spinnaker Metadata Repository Service
Java
63
star
18

pipeline-templates

A public collection of Spinnaker declarative pipeline templates
54
star
19

governance

Community documentation for Spinnaker
Kotlin
46
star
20

roer

A thin Spinnaker CLI
Go
45
star
21

kork

Kork provides some basic service building blocks for Spinnaker.
Java
41
star
22

spinnaker-monitoring

Support for monitoring deployed Spinnaker microservices.
Python
39
star
23

workshops

CSS
25
star
24

sponnet

Jsonnet library specifically for Spinnaker
Jsonnet
24
star
25

spinnaker.io

spinnaker.io website content
HTML
20
star
26

spinnaker-gradle-project

Gradle project for spinnaker project conventions
Kotlin
20
star
27

keiko

Queuing library originally built for Orca
Kotlin
18
star
28

deck-kayenta

Spinnaker UI module for Kayenta
TypeScript
17
star
29

kustomization-base

Base kustomize config for deploying Spinnaker to kubernetes
17
star
30

spinnaker-dependencies

Common dependencies for Spinnaker
Shell
14
star
31

deck-customized

Spinnaker Deck with customizations
HTML
14
star
32

rush

Script Execution service
Groovy
12
star
33

moniker

naming for cloud resources
Groovy
11
star
34

spinnaker-config

Template repo for users to overlay the base kustomization with their config
11
star
35

try.spinnaker.io

Spinnaker Playground ๐ŸŒŠ๐Ÿ„
Shell
9
star
36

styleguide

Style guide for Spinnaker UI
HTML
8
star
37

buildtool

Utilities and tools for setting up and execution Spinnaker integration tests
Python
6
star
38

scheduled-actions

As the name suggests ("scheduled actions")
Java
6
star
39

spinnakerbot

A GitHub bot for managing Spinnaker's repos.
Python
6
star
40

stats

Go
5
star
41

rotation-scheduler

A GitHub Action for generation a rotation schedule.
Go
5
star
42

bumpdeps

A GitHub Action to automatically bump Spinnaker dependencies
Kotlin
4
star
43

ops-tools

Unofficial community scripts and tools
4
star
44

dcdspike

quick spike of declarative CD templating
Java
4
star
45

managed.delivery

The microsite for managed.delivery
3
star
46

spinrel

A tool for working with Spinnaker releases.
Kotlin
3
star
47

clouddriver-cloudfoundry

Snapshot of cloud foundry code in clouddriver
Groovy
2
star
48

md-lib-go

Shared library code for Managed Delivery Go clients
Go
2
star
49

plugins

Spinnaker plugins repository
2
star
50

spinnaker-kustomize

Spinnaker installation via kustomize
Makefile
1
star
51

.github

Community Health files repo
1
star
52

spinnaker-dev.github.io

spinnaker.dev site
HTML
1
star
53

pipeline-builder

A Java library to build Spinnaker pipelines
Java
1
star