Artifact gathering in Prow job and `ci-operator` tests
Components
Artifact collection is based on components from the prow
repository. These coordinating components are collectively know as
pod-utilities and augment the pod_spec declared in a ProwJob
to add functionality such as timeouts, output censoring, execution
synchronization, and, of course, artifact gathering.
In OpenShift CI jobs, this process is done at two levels using the same
components: for the Prow job (independently of what it executes) and for
individual ci-operator steps inside a job. The latter become subdirectories
of the artifacts directory of the former.
entrypoint
entrypoint is a small program which acts as the parent process
of the command configured in the pod_spec of the ProwJob. It redirects the
child process output to a file so it can be collected, generates a signal when
that process finishes so that artifact gathering and upload can begin, among
other functions. It is configured via the ENTRYPOINT_OPTIONS environment
variable, as can be seen in the ProwJob object:
| |
artifact_diris the path where the artifacts directory is created so that the test can place files in it.process_logis the file to which the output of the child process is redirected.marker_fileis be created at the end of the execution to signal that the test has finished.
sidecar
sidecar is the component responsible for gathering and uploading
artifacts to Google Cloud Storage (GCS). It is added as a secondary container
to the one declared in the pod_spec and so will be executed in parallel with
it. The signal emitted by entrypoint when the test finishes (in most cases,
see the timeout documentation) will cause it to being its work. It
is controlled by a special environment variable SIDECAR_OPTIONS, which can be
seen in the ProwJob object:
| |
gcs_optionscontrol how and where in GCS files are placed. The final paths are determined by these options and the Prow job’sJOB_SPEC.Files from a periodic or post-submit job called
$namewith build ID$build_idcan be listed with:1$ gsutil ls gs://$bucket/logs/$name/$build_id/artifacts/Files from a pre-submit job for pull request
$pullin repository$org/$repocan be listed with:1$ gsutil ls gs://$bucket/pr-logs/pull/$org_$repo/$pull/$name/$build_id/artifacts/
entriescontains information about test processes to wait for and collect data from. These correspond to theentrypointoptions.censoring_optionscontrols the censoring of artifacts prior to the upload based on the content of secrets mounted into thePod.
Testing
When executing ci-operator locally, most of the time artifacts are not
necessary. If that is the case, simply not including a gcs_credentials_secret
(usually set to gce-sa-credentials-gcs-publisher) in the JOB_SPEC will allow
tests to be executed. The sidecar container will fail to upload artifacts,
but that is not considered an error by ci-operator. Alternatively, creating
an empty Secret object in the test namespace (either directly or via
ci-operator’s --secret-dir argument) will cause sidecar to fail
immediately and not even attempt to gather or upload artifacts.
For some test setups, artifact gathering is required, and ci-operator does not
currently provide a way to disable it. In order to executed tests locally, the
test namespace needs to contain valid GCS credentials. In this case, or if
artifacts actually need to be inspected, the Secret can be copied from one of
the build clusters:
The Secret name is determined by decoration_config.gcs_credentials_secret in
the JOB_SPEC. Note that this setup has the potential to interfere with actual
job results, since artifacts from local executions will be uploaded to the same
locations as they are. In case a JOB_SPEC with real values is used, these
artifacts can overwrite and/or pollute real job results. The
decoration_config.gcs_configuration.path_prefix field can be used to avoid
this. The artifacts can be listed with:
| |