Prow
repository·main·Indexed 43 days ago
https://github.com/kubernetes-sigs/prowA Kubernetes-native automation engine designed to manage large-scale CI/CD and testing workflows, primarily used by the Kubernetes community to automate pull request management and testing processes.
What's inside Prow
- Prow is a Kubernetes-based automation service used for managing CI/CD, testing, and community workflows. It provides the infrastructure for handling pull requests, managing build statuses, and automating various aspects of the Kubernetes testing ecosystem. The project's source code and statically generated documentation are hosted in this repository.
What is generic-autobumper?
mainThe
generic-autobumpertool automates version upgrading for container images (such as Prow deployment manifests).Workflow:
- It operates on a local git repository containing deployment manifests (e.g., the
/config/prow/clusterfolder). - It identifies the most recent tags for specified prefixes in a registry (e.g.,
gcr.io). - It modifies the YAML files with these new tags.
- It performs a
git-commit, pushes the changes to the remote repository, and creates or updates a Pull Request (PR).
Cluster administrators can then upgrade the image versions by simply approving the generated PR.
Prow Job Integration Patterns:
- Periodic Jobs: Use a periodic job to run the autobumper workflow at regular intervals to generate version-bump PRs.
- Postsubmit Jobs: Use a postsubmit job to automatically deploy the changes once the PR is merged, making the new versions effective in the cluster.
- It operates on a local git repository containing deployment manifests (e.g., the
Overview of Prow Cluster Components
mainProw is implemented as a microservice architecture consisting of container images running as Kubernetes deployments. The components are categorized into Core, Merge Automation, and Optional services.
Core Components
crier: Reports ProwJob status changes to external systems like Gerrit, GitHub, Pub/Sub, or Slack.deck: A UI component that provides views for recent jobs, command/plugin help, merge automation status (Tide), and a dashboard for PR authors.hook: The central stateless server that listens for GitHub webhooks and dispatches them to plugins (e.g., for triggering jobs or handling slash commands).horologium: Triggers periodic jobs.prow-controller-manager: Manages the lifecycle and execution of jobs running in Kubernetes pods (replacesplank).sinker: Handles cleanup of old jobs and pods.
Merge Automation
tide: Manages the retesting and merging of Pull Requests based on configured merge criteria.
Optional Components
branchprotector: Configures GitHub branch protection policies.exporter: Exposes general ProwJob metrics.gerrit: An adapter for handling CI workflows on Gerrit.hmac: Updates HMAC tokens and secrets for specified organizations/repositories.tot: Vends sequential build numbers (useful for legacy automation; otherwise, Prow uses monotonically increasing non-sequential numbers).status-reconciler: Prevents in-flight GitHub PRs from getting stuck when blocking presubmit configurations change.sub: Listens to Cloud Pub/Sub notifications to trigger Prow jobs.
What is Prow?
mainProw is a Kubernetes-based CI/CD system designed for multi-org scale. It handles job execution for testing, batch processing, and artifact publishing.
Key capabilities include:
- Event-driven Job Execution: Uses GitHub events to trigger
presubmitjobs (on PR update) andpostsubmitjobs (post-PR merge). - GitHub Automation: Provides pluggable bot automation for policy enforcement and chat-ops via
/foostyle commands. - Merge Automation: Includes batch testing logic and merge queue management (via Tide).
- Infrastructure: Designed for high availability on Kubernetes, featuring JSON structured logs and Prometheus metrics.
- Administration: Supports automatic deployment of source control-based configuration and automatic GitHub organization/repository administration.
- Event-driven Job Execution: Uses GitHub events to trigger
What is genyaml?
mainOverview
genyamlis a documentation tool designed to marshal Go structs into YAML while preserving documentation. It extracts doc comments from.gosource files and attaches them as comment nodes to the corresponding fields in the resulting YAML output.Key Features
- Comment Extraction: Automatically maps Go doc comments to YAML keys.
- JSON Tag Support: Uses
jsontags for field naming to ensure maximum portability. - Multiline Support: Preserves multiline comments (converting tabs to spaces and compressing multiple spaces).
- Filtering: Supports ignoring specific comment lines using special prefixes.
Documentation tooling for Prow
mainThe Prow documentation website is built and managed using the following stack:
- Hugo: An open-source static site generator used to format and generate the website from Markdown or HTML content.
- Docsy: A Hugo theme used for styling and site structure.
- Netlify: Used for managing the deployment of the site.
Manage GitHub organizations and teams with Peribolos
mainPeribolos is a GitOps tool that allows you to declare GitHub organization settings, teams, and memberships in a YAML file. When applied, Peribolos updates the GitHub organization to match the declared configuration.
To use Peribolos, you extend your primary Prow
config.yamlby adding a top-levelorgskey. Peribolos only manages the fields explicitly defined in your configuration; any fields missing from the YAML will remain unchanged in GitHub.orgs: this-org: # org settings company: foo email: foo name: foo description: foo has_organization_projects: true has_repository_projects: true default_repository_permission: read members_can_create_repositories: false # org member settings members: - anne - bob admins: - carl # team settings teams: node: # team config description: people working on node backend privacy: closed previously: - backend # Renames 'backend' team to 'node' # team members members: - anne maintainers: - jane repos: # Permissions for the team on specific repos some-repo: admin other-repo: readUse the clonerefs utility to clone code
mainclonerefsis a Prow pod utility used to clone code under test at specified locations.Key Behaviors:
- Exit Codes: The utility typically exits with code
0regardless of whether individual clone operations succeed or fail. It only exits with a non-zero status if a fatal error occurs that prevents any clone operations from starting. - Logging: Clone statuses are recorded to a specified log file in JSON format.
- Integration: It is designed to be used with
initupload, which can decode theclonerefsJSON output and format it for human readability.
- Exit Codes: The utility typically exits with code
Gerrit integration components
mainGerrit integration in Prow consists of two main components:
- Gerrit Adapter: A controller that periodically polls Gerrit and triggers presubmit and postsubmit jobs based on your Prow configuration.
- Crier: The reporter component responsible for reporting results back to Gerrit.
Note: The Gerrit adapter does not currently support Gerrit hooks.
Key features of Tide
mainTide provides several automation and observability features for GitHub workflows:
- Batch Testing & Merging: Automatically runs batch tests and merges multiple PRs together when possible.
- Base Branch Integrity: Ensures PRs are tested against the most recent commit on the base branch before merging.
- Status Visibility: Maintains a GitHub status context indicating if a PR is in a pool or identifying missing requirements.
- Merge Control: Supports blocking merges to specific branches or entire repositories using labeled GitHub issues.
- Configurable Merge Modes: Supports
merge,squash, orrebasemethods. - Observability: Exposes Prometheus metrics and serves live data for Deck to populate Tide and PR dashboards.
- Optional Statuses: Supports repositories that use 'optional' status contexts which are not required for a merge.
What is ghCache and how does it work?
mainghCache is an HTTP cache specifically optimized for the GitHub API (
https://api.github.com). It implements two key non-standard behaviors to optimize for both data freshness and GitHub API rate limits:- Mandatory Revalidation: Every cache hit is revalidated with a conditional HTTP request to GitHub, even if the cache entry is still fresh (within its TTL). It ignores and overwrites the
Cache-Controlheader to force this behavior. This leverages GitHub's support for conditional requests, which do not consume API tokens if the resource has not changed. - Request Coalescing: If multiple concurrent requests are made for the same resource, ghCache coalesces them into a single upstream request to GitHub. This prevents redundant API calls and token consumption when many handlers (such as Prow's hook component) react to the same event simultaneously.
Additionally, ghCache provides Prometheus instrumentation to monitor cache activity, request duration, and API token usage/savings.
- Mandatory Revalidation: Every cache hit is revalidated with a conditional HTTP request to GitHub, even if the cache entry is still fresh (within its TTL). It ignores and overwrites the
What is Tide?
mainTide is a Prow component designed to manage pools of GitHub Pull Requests (PRs) that meet specific criteria. It automates the lifecycle of PRs through two main behaviors:
- "Tide comes in": Automatically retesting PRs that meet defined criteria.
- "Tide goes out": Automatically merging PRs once they have up-to-date, passing test results.
Tide scales by treating every unique
org/repo:branchcombination as a disjoint merge pool, allowing a single instance to manage multiple organizations and repositories efficiently.