Package: python-heptapod-runner
Python utilities and subsytems for Heptapod RunnerHeptapod Runneris the fork ofGitLab Runnermeant to
work forHeptapodandGitLabinstances.The facilities provided in this package are part of the Heptapod Runner
extended distribution, aiming to provide additional options. They also
share the samesource code repositorywith Heptapod Runner.They are not to be confused with the main Heptapod Runner program, which
is a standalone programm written in Go (like GitLab Runner) that does not have
any dependency onpython-heptapod-runner.Python was selected for fast prototyping and because it is lingua franca in
the Mercurial community, but It is possible that some of facilities end up
being rewritten in another language.heptapod-paas-runner-registerThis interactive program can be used to bootstrap the configuration forheptapod-paas-runner.Warning:in all cases, the configuration has to be manually completed
afterwards.It takes care notably of the registration against
the GitLab or Heptapod instance, hence playing a similar role as thegitlab-runner registercommand.It will just append a new[[runners]section if the configuration file
already exists.Caveats for configuration file creationThe parent directory of the configuration file path has to exist,
be writable by the system user doing the registrationThe resulting configuration file has to be readable by
the system user forheptapod-paas-runner.The parent directory of the state file path has to be writable by the
system user forheptapod-paas-runner.heptapod-paas-runnerThe purpose of this program is to provide on-demand provisioning while
following the expected workflows of PAAS systems:Docker hosts are provisioned only after jobs have been acquired from the
coordinatoractual job launch involves pushing a Dockerfile to a Git repository that
controls the Docker host.Process and state managementSimple invocationheptapod-paas-runnertakes a single positional argument: the path to
its configuration file (see the section aboutheptapod-paas-runner-registerabove)Several options are available and can be displayed with:heptapod-paas-runner --helpGraceful restart and state managementHeptapod PAAS Runner tracks the jobs it has launched
in order to deprovision the resources once they are finished.To that end, it implements a graceful shutdown whenSIGTERMis
received (this is the default stop signal used by many process managers,
including systemd).Upon signal reception, it willstop acquiring new jobsfinish operations that can't be interrupted (launchings, decommissionings)write all needed information about currently tracked jobs in a fileexitThis shutdown sequence is not instantaneous. A waiting time of 2 minutes
should be enough before resorting to more drastic means (this includes margin).We will probably improve the interruption of the launch sequence, but we
can't go as far as to interrupt a currently running request, as it could
provision untrackable resources.Graceful reloadCurrently not supported, a configuration change can be done without losing
information with the grateful restart.In theory, a proper reload would be less dangerous.Sample systemd unit file[Unit]
Description=Heptapod PAAS Runner
After=network.target

[Install]
WantedBy=multi-user.target

[Service]
User=heptapod-runner
WorkingDirectory=/srv/heptapod-runner
ExecStart=/srv/heptapod-runner/venv/bin/heptapod-paas-runner /etc/heptapod-runner/pass-runner.toml
# We don't need a specific ExecStop, as systemd has a cascading system
# of defaults for the stop signal, with the
# SIGTERM being the ultimate default.

TimeoutStopSec=120
Restart=always
RestartSec=125The configuration fileheptapod-paas-runneruses the same configuration file as the normal
Heptapod (or GitLab) Runner.Eachrunnerssection has anexecutorentry that must be one of the PAAS
executors, and consists otherwise of a mix ofspecific PAAS Runner configuration, depending on the executor.standard GitLab Runner configuration, forwarded to the final executor,
unless forced by the PAAS Runner.The PAAS executors are currently:clever-docker(see below)local-docker, for testing and development purposes onlyNote:heptapod-paas-runnerdoes not have a registration facility yet.
In practice, you can use anyheptapod-runnerorgitlab-runnerexecutable
to create a configuration file with an appropriate coordinator token,
and then modify it forheptapod-paas-runner. This does not have to be done
on the actual target system.Global configurationThe global configuration is not forwarded to the PAAS resources. It is instead
used to tweakheptapod-paas-runneritself.concurrent(default 50): same meaning as in standard GitLab Runner.
This is the maximum number of jobs across all defined runners.check_interval(default 3):
similar meaning as in standard GitLab Runner. This is
the time in seconds between full coordinator polls, given that:if a coordinator grants a job, it is repolled immediately unless limits
on jobs are reached (number of jobs, weighted quota, and concurrent
provisioning)if limits on jobs are reached, the waiting time is given byjob_progress_poll_interval(see below)job_progress_interval(default 30): time in seconds to wait between
coordinator requests to check if launched jobs are finished.quota_computation(required): allows to set the weighted quota by taking
a runner section, one of its associated flavor and a number of job as
reference. Example:[quota_computation]
  reference_runner = "my-runner"
  reference_flavor = "M"
  reference_jobs_count = 4

[[runners]]
  name = "my-runner"
  url = "https://heptapod.example"
  ...This sets the quota to be the weight of 4 jobs with flavor M of themy-runnerrunner defined afterwards.state_file: path of the file used to keep tracking running jobs after
a graceful restart.paas_max_concurrent_provisioning (default 10): maximum number of
concurrent jobs currently queued at the PAAS infrastructure that haven't
been acknowledged as really running by their coordinators yet.paas_finished_jobs_keep_resources(defaultfalse): iftrue, no
decommissioning will occur.pass_decommision_launched_failures(defaulttrue): iffalse, in the
case where resource was supposedly created in the PAAS infrastructure but
did not actually start, no attempt to remove it will be done, so that it
can be inspected to understand the issue.Global footprint: the weight systemSomeheptapod-paas-runnerexecutors have the capability to use
different resources ("flavors") according to job details.
The job details are usually available only once the job is acquired,
which can currently not be reverted.A concurrency control system accounting only for the number of jobs would
hence need to cripple its capability to run small jobs because of the
possibility to run large jobs. This is what happened before the introduction
of the weight system.The weights used by the various configuredrunnersare simply summed up.
Beware that the weights of different executors are usually very much not
comparable, hence it is a very bad idea to mix several executortypesin a singleheptapod-paas-runnerservice.
For instance, at the time of this writing,
theclever-dockerexecutor has weights ranging roughly from 2 to 75,
whereas an executor not implementing weights would have all values equal to 1.It is perfectly admissible, and even recommended, to smooth out those limits
to put severalrunnersin a single service, as long as they all have the
sameexecutor. The typical use-case for this would be to perform CI for
several Heptapod (or pure upstream GitLab) instances.Common properties of the Docker executorsAll standard features (images, services) are supporteedImage management and Dependency ProxyWe don't currently have the means to reuse PAAS resources, hence all jobs
start with fresh downloads of all necessary Docker images.Partly because of this, the Heptapod PAAS Runner uses the Dependency Proxy
automatically, diverging in that from the standard GitLab Runner Docker
executor.Practical consequences for job authors:donotdisable the Dependency Proxy for your Groupif a service has no alias defined in the job, it will be accessible with
only one ofthe two syntaxes normally supported by GitLab Runner:if the service image is defined aspostgres:13, the service container
can be accessed as usual aspostgresif the image is defined astutum/wordpress, the service
container can be accessed astutum-wordpress, butnottutum__wordpressTheclever-dockerexecutorThis runs the job inClever Cloud.Clever Cloud is also the company hosting thepublic Heptapod instance for
Free and Open Source Software, where Heptapod
is self-hosted and thecommercial Heptapod instance.There are two modes of operation: single organization and multi-tenant.Common configurationRequired:executor:clever-dockercc_extra_envsubsection. Can be used to pass extra environment to
the sub-runner spawned on the provisioned resource. CurrentlyCC_ENABLE_HEPTAPOD_RUNNER = "true"is necessaryOptional:cc_api_url(defaults tohttps://api.clever-cloud.com/v2):
Clever Cloud base API URLcc_zone(defaults topar): any zone can be in theory used. In practice,
the zone better be close to the GitLab / Heptapod instance (the coordinator).cc_default_flavor(defaults toM): the flavor (size) of instances that
will be launched on Clever Cloud if not specified by the job.[job_trace_watch](strongly recommended): this section enables watching
the user-level job log (internally called "the job trace") to limit the
number of concurrent jobs being in provisioning and not fully started yet,
and to provide quicker user feedback in case of problems.
Items are:token: sadly, has to be an Administrator token withread-apiscope.
A future version of Heptapod should be able to avoid that, but probably not
upstream GitLabtimout_seconds(default 300): the time after which the job launch
is considered to have failed.poll_step(default 10): the time in seconds between checks of the
job tracecc_deployment_repo_timeout(default 20): maximum time in seconds to wait
for the Clever Cloud's deployment Git repository to be readycc_deployment_repo_wait_step(default 2): time between requests
to assess if the Clever Cloud's deployment Git repository is readyRunning for a single Clever Cloud OrganizationPut these in the Runner configurationcc_multi_tenant: unspecified orfalse.cc_orga_id: specify the id of your Clever Cloud Organization, as seen,
e.g, in its Overview page in the Clever Cloud console.cc_token: token for the Clever Cloud API, with enough rights to create,
deploy and delete applications and instancesIt doesn't matter whether the Runner is tied to specific Projects, a Group or
a whole GitLab / Heptapod instance: all resources will be attached
(and billed) to the specified Organization.This is a good fit for a self-hosted Heptapod instance.Full example:state_file="/srv/heptapod-runner/paas-runner-state.json"[quota_computation]reference_runner="clever-cloud"reference_flavor="3XL"reference_jobs_count=8[[runners]]name="clever-cloud"url="https://heptapod.example.com"token="D3adNQYu8OCjkYDbwDaG"executor="clever-docker"cc_orga_id="orga_07cf2ef0-c9ad-4f04-b492-94c164f95c76"cc_token="bb52e490-d47e-47a4-b190-73e23eb17111"[runners.cc_extra_env]CC_ENABLE_HEPTAPOD_RUNNER="true"[runners.custom_build_dir][runners.cache][runners.cache.s3]# A future version of Heptapod PAAS Runner may fill this in automatically.# Meanwhile it is possible to use any S3 configuration. Using Clever's# Cellar for your CI caches in the same zone is the best for# network proximity and bandwidth.# (replace with your credentials and bucket of choice)ServerAddress="cellar-c2.services.clever-cloud.com"AccessKey="dEA7gjmYM98gobVi6Y1x"SecretKey="v0tdpjgpsDRqaSvIndvHAXFmjbpEd958gbZuO7yv"BucketName="heptapod-ci"[runners.cache.gcs][runners.docker]helper_image="registry.heptapod.net/heptapod/heptapod-runner/helper:x86_64-latest"tls_verify=falseimage="debian:bullseye"privileged=falsedisable_entrypoint_overwrite=falseoom_kill_disable=falsedisable_cache=falsevolumes=["/cache"]shm_size=0(all tokens and uuids in this example are random values freshly obtained
for this documentation)The multi-tenant modeIn this mode, the runner determines the Clever Cloud Organization and the
associated API token from attributes of the top-level Heptapod Group to which
the Project belongs.It assumes that something populates those attributes.This mode of operation is intended for instances such asheptapod.host.Required Runner configuration:cc_multi_tenant:truecc_gitlab_namespace_attributes_token: a GitLab / Heptapod private token
with enough rights to query Group custom attributes.Optional Runner configuration:cc_orga_id_attribute(defaults tocc_orga_id). Name of the custom
attribute on top-level Groups to use for the Organization ID.cc_orga_token_attribute (defaults tocc_orga_token`). Name of the custom
attribute on top-level Groups to use for the Clever API token of the
Organization.Full example:state_file="/srv/heptapod-runner/paas-runner-state.json"[quota_computation]reference_runner="clever-cloud"reference_flavor="3XL"reference_jobs_count=8[[runners]]name="clever-cloud"url="https://heptapod.example.com"token="D3adNQYu8OCjkYDbwDaG"executor="clever-docker"cc_multi_tenant=truecc_gitlab_namespace_attributes_token="D7aY5I5SygxA5oyZ11vB"[runners.cc_extra_env]CC_ENABLE_HEPTAPOD_RUNNER="true"[runners.custom_build_dir][runners.cache][runners.cache.s3]# Do not fill in this: it would use the same bucket for all tenants.# A future version of Heptapod PAAS Runner will fill this automatically,# using the Cellar add-on of each tenant for proper separation.[runners.cache.gcs][runners.docker]helper_image="registry.heptapod.net/heptapod/heptapod-runner/helper:x86_64-latest"tls_verify=falseimage="debian:bullseye"privileged=falsedisable_entrypoint_overwrite=falseoom_kill_disable=falsedisable_cache=falsevolumes=["/cache"]shm_size=0(all tokens in this example are random values freshly obtained for this
documentation)Flavors and their weightsEnd users can control the flavors (sizes) of the Clever Cloud instances
running their jobs. This is done with theCI_CLEVER_CLOUD_FLAVORjob
variable, with admissible values currently ranging fromXSto3XL.Theclever-dockerexecutors implement the weight system described above
to limit the maximum footprint of the whole runner service in the Clever
while taking differences between the flavors into account.If one wishes to allow as much as exactlyNjobs with flavorF, the
simplest is to use thequota_computationsection (see above).
Alternatively, one may set theconcurrentglobal configuration parameter toN*F.weight.
The weight system will then automatically adjust what it means for the typical
payload, consisting of bigger and or smaller instances thanF.The weight computation is expected to change in the future, as it is merely
an approximation of actual infrastructure constraints, hence it is better
to usequota_computationrather thanconcurrent.Currently, the weight of a flavor is computed asM^1.25whereMis the RAM footprint of the flavor, expressed in GiB. The non linearity of
this formula will allow in practice to spawn more smaller flavors with an
equivalent total memory footprint.