|
2 | 2 | title: Internals |
3 | 3 | --- |
4 | 4 |
|
| 5 | +This section provides a deeper understanding of some of the concepts surrounding Concourse. |
| 6 | + |
| 7 | +An understanding of the basics of Concourse concepts, such as pipelines, jobs, etc, is recommended as parts of this |
| 8 | +section might assume a level of knowledge from them. This section is not necessary for using Concourse but are more for |
| 9 | +experienced users that want to dig deeper into how Concourse works. |
| 10 | + |
5 | 11 | ## Basic architecture |
6 | 12 |
|
| 13 | +Concourse is a fairly simple distributed system built up from the following components. You'll see them referenced here |
| 14 | +and there throughout the documentation, so you may want to skim this page just to get an idea of what they are. |
| 15 | + |
| 16 | + |
| 17 | + |
7 | 18 | ## ATC: web UI & build scheduler |
8 | 19 |
|
| 20 | +The ATC is the heart of Concourse. It runs the web UI and API and is responsible for all pipeline scheduling. It |
| 21 | +connects to PostgreSQL, which it uses to store pipeline data (including build logs). |
| 22 | + |
| 23 | +Multiple ATCs can be running as one cluster; as long as they're all pointing to the same database, they'll synchronize |
| 24 | +using basic locking mechanisms and roughly spread work across the cluster. |
| 25 | + |
| 26 | +The ATC by default listens on port `8080`, and is usually co-located with the [TSA](#tsa-worker-registration-forwarding) |
| 27 | +and sitting behind a load balancer. |
| 28 | + |
| 29 | +!!! note |
| 30 | + |
| 31 | + For [`fly intercept`](../builds.md#fly-intercept) to function, make sure your load balancer is configured to do TCP |
| 32 | + or SSL forwarding, not HTTP or HTTPS. |
| 33 | + |
| 34 | +There are multiple components within the ATC that each have their own set of responsibilities. The main components |
| 35 | +consist of the [checker](checker.md), [scheduler](scheduler.md), [build tracker](build-tracker.md), and |
| 36 | +the [garbage collector](garbage-collector.md). |
| 37 | + |
| 38 | +The [checker](checker.md)'s responsibility is to continuously checks for new versions of resources. |
| 39 | +The [scheduler](scheduler.md) is responsible for scheduling builds for a job and the [build tracker](build-tracker.md) |
| 40 | +is responsible for running any scheduled builds. The [garbage collector](garbage-collector.md) is the cleanup mechanism |
| 41 | +for removing any unused or outdated objects, such as containers and volumes. |
| 42 | + |
| 43 | +All the components in a Concourse deployment can be viewed in the _components_ table in the database as of v5.7.0. The |
| 44 | +intervals that the components run at can also be adjusted through editing that table, as well as pausing the component |
| 45 | +from running entirely. |
| 46 | + |
9 | 47 | ## TSA: worker registration & forwarding |
10 | 48 |
|
| 49 | +The TSA is a custom-built SSH server that is used solely for securely |
| 50 | +registering [workers](../install/running-worker.md) with the [ATC](#atc-web-ui-build-scheduler). |
| 51 | + |
| 52 | +The TSA by default listens on port `2222`, and is usually co-located with the [ATC](#atc-web-ui-build-scheduler) and |
| 53 | +sitting behind a load balancer. |
| 54 | + |
| 55 | +The TSA implements CLI over the SSH connection, supporting the following commands: |
| 56 | + |
| 57 | +* The `forward-worker` command is used to reverse-tunnel a worker's addresses through the TSA and register the forwarded |
| 58 | + connections with the ATC. This allows workers running in arbitrary networks to register securely, so long as they can |
| 59 | + reach the TSA. This is much safer than opening the worker up to the outside world. |
| 60 | +* The `land-worker` command is sent from the worker when landing, and initiates the state change to `LANDING` through |
| 61 | + the ATC. |
| 62 | +* The `retire-worker` command is sent from the worker when retiring, and initiates the state change to `RETIRING` |
| 63 | + through the ATC. |
| 64 | +* The `delete-worker` command is sent from the worker when draining is interrupted while a worker is retiring. It |
| 65 | + removes the worker from the ATC. |
| 66 | +* The `sweep-containers` command is sent periodically to facilitate garbage collection of containers which can be |
| 67 | + removed from the worker. It returns a list of handles for containers in the `DESTROYING` state, and it is the worker's |
| 68 | + job to subsequently destroy them. |
| 69 | +* The `report-containers` command is sent along with the list of all container handles on the worker. The ATC uses this |
| 70 | + to update the database, removing any `DESTROYING` containers which are no longer in the set of handles, and marking |
| 71 | + any `CREATED` containers that are not present as missing. |
| 72 | +* The `sweep-volumes` command is sent periodically to facilitate garbage collection of volumes which can be removed from |
| 73 | + the worker. It returns a list of handles for volumes in the `DESTROYING` state, and it is the worker's job to |
| 74 | + subsequently destroy them. |
| 75 | +* The `report-volumes` command is sent along with the list of all volume handles on the worker. The ATC uses this to |
| 76 | + update the database, removing any `DESTROYING` volumes which are no longer in the set of handles, and marking |
| 77 | + any `CREATED` volumes that are not present as missing. |
| 78 | + |
11 | 79 | ## Workers Architecture |
12 | 80 |
|
13 | | -### The worker lifecycle |
| 81 | +Workers are machines running [Garden](https://github.com/cloudfoundry-incubator/garden) |
| 82 | +and [Baggageclaim](https://github.com/concourse/concourse/tree/master/worker/baggageclaim) servers and registering |
| 83 | +themselves via the [TSA](#tsa-worker-registration-forwarding). |
| 84 | + |
| 85 | +!!! note |
| 86 | + |
| 87 | + Windows and Darwin workers also run Garden and Baggageclaim servers but do not run containers. They both use |
| 88 | + [houdini](https://github.com/vito/houdini) to fake making containers. Windows containers are not supported and |
| 89 | + Darwin does not have native container technology. |
| 90 | + |
| 91 | +Workers have no important state configured on their machines, as everything runs in a container and thus shouldn't care |
| 92 | +about what packages are installed on the host (well, except for those that allow it to be a worker in the first place). |
| 93 | +This is very different from workers in other non-containerized CI solutions, where the state of packages on the worker |
| 94 | +is crucial to whether your pipeline works or not. |
| 95 | + |
| 96 | +Each worker registers itself with the Concourse cluster via the [TSA](#tsa-worker-registration-forwarding). |
| 97 | + |
| 98 | +Workers by default listen on port `7777` for Garden and port `7788` for Baggageclaim. Connections to both servers are |
| 99 | +forwarded over the SSH connection made to the [TSA](#tsa-worker-registration-forwarding). |
| 100 | + |
| 101 | +### The worker lifecycle |
| 102 | + |
| 103 | +#### **RUNNING** |
| 104 | + |
| 105 | +: A worker in this state is registered with the cluster and ready to start running containers and storing volumes. |
| 106 | + |
| 107 | +#### **STALLED** |
| 108 | + |
| 109 | +: A worker in this state was previously registered with the cluster, but stopped advertising itself for some reason. |
| 110 | +Usually this is due to network connectivity issues, or the worker stopping unexpectedly. |
| 111 | + |
| 112 | +: If the worker remains in this state and cannot be recovered, it can be removed using |
| 113 | +the [`fly prune-worker`](../operation/administration.md#fly-prune-worker) command. |
| 114 | + |
| 115 | +#### **LANDING** |
| 116 | + |
| 117 | +: The `concourse land-worker` command will put a worker in the `LANDING` state to safely drain its assignments for |
| 118 | +temporary downtime. |
| 119 | + |
| 120 | +: The ATC will wait for builds on the worker for jobs which are uninterruptible to finish, and transition the worker |
| 121 | +into `LANDED` state. |
| 122 | + |
| 123 | +#### **LANDED** |
| 124 | + |
| 125 | +: A worker in this state has successfully waited for all uninterruptible jobs on it after having `concourse land-worker` |
| 126 | +called. It will no longer be used to schedule any new containers or create volumes until it registers as `RUNNING` |
| 127 | +again. |
| 128 | + |
| 129 | +#### **RETIRING** |
| 130 | + |
| 131 | +: The `concourse retire-worker` command will put a worker in the `RETIRING` state to remove it from the cluster |
| 132 | +permanently. |
| 133 | + |
| 134 | +: The ATC will wait for builds on the worker for jobs which are uninterruptible to finish, and remove the worker. |
0 commit comments