Prow

repository·main·Indexed 43 days ago

https://github.com/kubernetes-sigs/prow

A 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.

Tokens
99.7K
Snippets
230
Records
426
Agent score
51%

What's inside Prow

  1. Overview of Prow

    main
    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.
  2. What is generic-autobumper?

    main

    The generic-autobumper tool automates version upgrading for container images (such as Prow deployment manifests).

    Workflow:

    1. It operates on a local git repository containing deployment manifests (e.g., the /config/prow/cluster folder).
    2. It identifies the most recent tags for specified prefixes in a registry (e.g., gcr.io).
    3. It modifies the YAML files with these new tags.
    4. 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.
  3. Overview of Prow Cluster Components

    main

    Prow 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 (replaces plank).
    • 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.
  4. What is Prow?

    main

    Prow 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 presubmit jobs (on PR update) and postsubmit jobs (post-PR merge).
    • GitHub Automation: Provides pluggable bot automation for policy enforcement and chat-ops via /foo style 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.
  5. What is genyaml?

    main

    Overview

    genyaml is a documentation tool designed to marshal Go structs into YAML while preserving documentation. It extracts doc comments from .go source 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 json tags 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.
  6. Manage GitHub organizations and teams with Peribolos

    main

    Peribolos 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.yaml by adding a top-level orgs key. 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: read
  7. Use the clonerefs utility to clone code

    main

    clonerefs is a Prow pod utility used to clone code under test at specified locations.

    Key Behaviors:

    • Exit Codes: The utility typically exits with code 0 regardless 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 the clonerefs JSON output and format it for human readability.
  8. Key features of Tide

    main

    Tide 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, or rebase methods.
    • 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.
  9. What is ghCache and how does it work?

    main

    ghCache 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:

    1. 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-Control header to force this behavior. This leverages GitHub's support for conditional requests, which do not consume API tokens if the resource has not changed.
    2. 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.

  10. What is Tide?

    main

    Tide 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:

    1. "Tide comes in": Automatically retesting PRs that meet defined criteria.
    2. "Tide goes out": Automatically merging PRs once they have up-to-date, passing test results.

    Tide scales by treating every unique org/repo:branch combination as a disjoint merge pool, allowing a single instance to manage multiple organizations and repositories efficiently.