View on GitHub

Bacon @ Red Hat

CLI for ProjectNCL

Configuration

Configuring Bacon

An example configuration is present here

The default configuration used by bacon should be located in folder: ~/.config/pnc-bacon/ with name config.yaml. We can specify a different folder for the location of the config.yaml via the -p flag:

bacon pnc build cancel -p <alternate folder containing config.yaml> 1000

We can specify several profiles in the configuration file. This is useful when dealing with different PNC servers and/or configurations. We can use the --profile flag to choose the non-default one:

bacon pnc build cancel --profile coolProfile 1000

Authentication

To authenticate to PNC Authentication servers, add this to your config.yaml:

keycloak:
    url: "http://keycloak.com"
    realm: ""
    username: ""

    # if regular user
    clientId: ""

    # if service account
    # clientSecret: ""

We also support LDAP authentication as an alternative to keycloak if the PNC servers are configured to accept LDAP requests:

ldapUsernamePassword: username:password

Internal SCM repositories (GitHub and GitLab)

The git provider is chosen from the repository URL: GitLab when the host contains gitlab, GitHub otherwise.

githubToken: "github-token"   # GitHub / GitHub Enterprise, 'repo' scope
gitlabToken: "gitlab-token"   # GitLab, 'read_api' scope (or the GITLAB_TOKEN environment variable)

scmSource chooses where build sources and alignment diffs come from: auto (default: the git provider, then PNC when it fails), direct (the git provider only) or orch (PNC only, which reads the repository through Reqour; no git provider access or token needed, but a PNC login with a role that may read builds). See the alignment diff guide.

Without a token, public (and on GitLab, internal) repositories are read anonymously. Tokens are only sent to the repository’s own host (after the URL rewrites), never to a host it redirects to. This does not cover the git clone PiG makes for javadoc (JGit), which handles its redirects itself.

Sources and alignment diffs are read from the build’s internal repository URL, then from the repository’s current internal URL; the external (upstream) URL is not used, as it does not have the aligned commits and tags. The provider APIs are reached at https://<host> of the repository URL; use a URL rewrite for another port or scheme.

Network timeouts

Connections to SCM hosts, repository managers and bifrost time out after 30 seconds, and SCM hosts must start answering (status and headers) within 2 minutes; downloading the body itself is not limited. A host that cannot be reached is not retried with other revisions or credentials, and a token a host rejects is not tried again on it.

PNC client HTTP timeouts

The PNC REST client used by bacon defaults to a 30 second connect timeout and a 60 second read timeout. Some operations can take longer than the read default to respond — for example generating redacted provenance during bacon pnc build download-build-outputs <id> --redacted — and will otherwise fail with java.net.SocketTimeoutException: Read timed out.

Both timeouts can be overridden without changing config.yaml. Each accepts a value in milliseconds and can be set via either a Java system property or an environment variable:

Timeout System property Environment variable Default
Read pnc.client.readTimeoutMillis PNC_CLIENT_READ_TIMEOUT_MILLIS 60000
Connect pnc.client.connectTimeoutMillis PNC_CLIENT_CONNECT_TIMEOUT_MILLIS 30000

Precedence for each timeout is: system property first, then environment variable, then the built-in default. Values that are missing, blank, non-numeric, or not strictly positive are ignored (a warning is logged) and the default is used.

Set the read timeout to 5 minutes via an environment variable:

export PNC_CLIENT_READ_TIMEOUT_MILLIS=300000
bacon pnc build download-build-outputs <id> --redacted

Or via a system property (system properties reach bacon through JAVA_TOOL_OPTIONS):

JAVA_TOOL_OPTIONS="-Dpnc.client.readTimeoutMillis=300000" \
  bacon pnc build download-build-outputs <id> --redacted

Rewriting download URLs

Some URLs that PNC hands out may not be reachable from where bacon runs, while the same service is reachable at another address: the publicUrl of built artifacts, or the bifrost host PNC redirects the alignment log to. URL rewrites replace the start of such URLs, like git’s url.<base>.insteadOf:

urlRewrites:
  "https://bifrost.example.com": "https://bifrost.internal.example.com:8443"
  "https://indy.example.com/api/content": "https://mirror.example.com/indy"

or for a single run, with the global --url-rewrite <from>=<to> option (repeatable, added to the profile’s rules):

bacon pnc build download-build-outputs <id> \
  --url-rewrite https://bifrost.example.com=https://bifrost.internal.example.com:8443