Reference and map

Each table links to the page that explains the area it covers.

Where it lives

The whole repository, from main.go down. ABTaskFile, Rakefile, and packager/ hold the build tooling.

Command line

main.go calls cmd.Run, which builds a fisk application named choria-provisioner. The run command is the default, so choria-provisioner --config ... and choria-provisioner run --config ... are equivalent.

FlagCommandRequiredDefaultEffect
--debugGlobalNoOffForces the Choria log level to debug.
--configrunYesNoneNames the Provisioner YAML. Must be an existing file.
--choria-configrunNochoria.UserConfig()Names the Choria client configuration. Must be an existing file.
--pidrunNoUnsetWrites the PID, and removes the file on exit.

--version prints config.Version, which is 0.0.0 in a plain go build. The release build injects it through -ldflags, mapped in packager/buildspec.yaml to github.com/choria-io/provisioner/config.Version.

Source map

FileLinesHolds
main.go9The call to cmd.Run.
cmd/provisioner.go130Flags, both config loads, the Choria framework, /metrics, signal handling, and the PID file. Architecture.
config/config.go142The Config struct, Load, the defaults, and the validation.
config/pausable.go48Pause, Resume, Flip, and Paused. Pausing and leader election.
config/stats.go18The choria_provisioner_paused gauge.
hosts/hosts.go223Process, the package state, broadcast discovery, add, remove, and isCurrent. Discovery and the work queue.
hosts/event.go82The connector and the lifecycle startup subscription.
hosts/provisioner.go84The worker loop and the finisher.
hosts/election.go51The leader election setup and its two callbacks.
hosts/stats.go66Nine fleet-level counters and gauges.
host/host.go483The Host struct, Provision, JWT and CSR validation, server JWT issuance, and key encryption. The provisioning cycle and Security and enrollment.
host/rpc.go404rpcWrapper and every Choria RPC action. RPC, retries, and upgrades.
host/helper.go131ConfigResponse and the child process. The helper contract.
host/version.go210The vendored RPM version comparison.
host/stats.go42Five per-server metrics.
host/host_test.go238Ginkgo specs for generateServerJWT, validateCSR, and encryptPrivateKey.
tools.go18Build-tagged tools imports that pin the Ginkgo CLI, excluded from normal builds.

Key types

config.Config
config/config.go:25. The parsed YAML plus derived durations, the config file path, and the pause flag. Passed by pointer to every package.
host.Host
host/host.go:29. One server. Five exported fields form the helper's input. The remaining fields hold state that the RPC sequence fills in.
host.ConfigResponse
host/helper.go:23. The helper's reply. Twelve optional fields.
host.Version
host/version.go:21. An RPM epoch, version, and release triple with a Compare method.

Exported metrics

Every metric carries a site label taken from the site configuration key. Three init functions register them, one per package.

MetricTypeExtra labelsRegistered in
choria_provisioner_pausedGaugeNoneconfig/stats.go
choria_provisioner_discoveredCounterNonehosts/stats.go
choria_provisioner_event_discoveredCounterNonehosts/stats.go
choria_provisioner_discover_cyclesCounterNonehosts/stats.go
choria_provisioner_discovery_errorsCounterNonehosts/stats.go
choria_provisioner_provision_errorsCounterNonehosts/stats.go
choria_provisioner_provisionedCounterNonehosts/stats.go
choria_provisioner_busy_workersGaugeNonehosts/stats.go
choria_provisioner_work_queue_entriesGaugeNonehosts/stats.go
choria_provisioner_waiting_nodesGaugeNonehosts/stats.go
choria_provisioner_rpc_timeSummaryrpchost/stats.go
choria_provisioner_rpc_errorsCounterrpchost/stats.go
choria_provisioner_helper_timeSummaryNonehost/stats.go
choria_provisioner_helper_errorsCounterNonehost/stats.go
choria_provisioner_helper_shutdown_requestsCounterNonehost/stats.go

The rpc label is the agent#action string, for example choria_provision#configure or rpcutil#inventory. Monitoring describes what each metric measures.

Configuration keys

Configuration File gives the full operational description. The following table gives the struct field and the reader for each key.

YAML keyFieldRead by
workersWorkershosts.Process, to size the worker pool.
intervalInterval, IntervalDurationhosts.Process for the ticker, add for the dedup window, Provision for the staleness check.
helperHelperrunHelper, split with shellquote.
tokenTokenNewHost, which copies it to Host.token for every choria_provision action.
siteSiteEvery metric, as the site label.
lifecycle_componentLifecycleComponentlisten, as the startup event subject.
logfile, loglevelLogfile, Loglevelcmd.run, which copies them onto the Choria configuration.
choria_insecureInsecurecmd.run, which disables TLS and forces the file security provider.
monitor_portMonitorPortcmd.setupPrometheus.
broker_provisioning_passwordBrokerProvisionPasswordcmd.run, which sets the NATS user to provisioner.
cert_deny_listCertDenyListvalidateCSR, through matchAnyRegex.
jwt_verify_certJWTVerifyCertvalidateJWT, as a file path or a hex public key.
jwt_signing_keyJWTSigningKeygenerateServerJWT.
jwt_signing_tokenJWTSigningTokengenerateServerJWT, re-read for every server.
server_jwt_validityServerJWTValidity, ServerJWTValidityDurationgenerateServerJWT.
upgrades_repositoryUpgradesRepoupgrade, as the release_update repository.
upgrades_optionalUpgradesOptionalProvision, in the upgrade failure branch.
leader_electionLeaderElectionhosts.Process, to start startElection.
features.jwtFeatures.JWTProvision, to gate fetchJWT and validateJWT.
features.pkiFeatures.PKIProvision, to gate fetchCSR and validateCSR.
features.ed25519Features.ED25519Provision, to gate fetchEd25519PubKey and generateServerJWT.
features.upgradesFeatures.VersionUpgradesProvision, to gate handleHostUpgrade.

rego_policy is declared on Config as RegoPolicy and read nowhere. OPA policies reach a node through the helper’s opa_policies reply instead.

Choria RPC actions used

AgentActionPurpose
rpcutilinventoryFacts, agent list, version, and the upgradable flag.
choria_provisionjwtThe provisioning.jwt and the server’s ECDH public key.
choria_provisiongen25519An ed25519 public key and a signature over a nonce.
choria_provisiongencsrA CSR generated by the node.
choria_provisionrelease_updateAn in-place binary upgrade.
choria_provisionconfigureConfiguration, credentials, and policies in one call.
choria_provisionrestartRestart into the new configuration.
choria_provisionshutdownExit with code 0, which does not trigger a systemd restart.

Glossary

fleet node
A machine running Choria Server. Provisioner's unit of work.
provisioning collective
The sub-collective that an unconfigured server joins. Provisioner forces both collectives and main_collective to this value.
provisioning.jwt
A token placed on a node that enables provisioning mode, carries the broker address, and holds the shared token.
helper
The site-supplied program that turns a server's identity and inventory into a configuration.
Organization Issuer
The ed25519 key at the root of a certificate-authority-free Choria deployment. Provisioner signs server tokens that chain to it.
server JWT
The token that Provisioner issues for a node in an Organization Issuer deployment, replacing an x509 certificate.
lifecycle event
A JSON event that Choria components publish on choria.lifecycle.event.>. Provisioner subscribes to the startup ones.
leader election
A Choria Streams primitive that names one instance in a cluster as active.
paused
The flag that a standby instance sets. Every outbound action checks it.
splay
A random delay that a server applies before acting on a restart or shutdown, spreading the load across a fleet.
site
A name for one installation, used as a label on every metric so a dashboard can aggregate across installations.
Next

The Code Map overview returns to the start. Writing a helper gives the operator’s view of the helper contract.