Skip to content

Latest commit

 

History

History
172 lines (126 loc) · 9.64 KB

CONTRIBUTING.md

File metadata and controls

172 lines (126 loc) · 9.64 KB

Contributing to KAI Scheduler

Thank you for your interest in contributing to KAI Scheduler! This document provides guidelines and instructions to help you get started with contributing to our project.

Make sure to read our Contributor License Agreement and Code of Conduct.

Getting Started

New Contributors

We're excited to help you make your first contribution! Whether you're looking to file issues, develop features, fix bugs, or improve documentation, we're here to support you through the process.

Browse issues labeled [good first issue] or [help wanted] on GitHub for an easy introduction.

Developers

The main building blocks of KAI Scheduler are documented in the docs/developer folder. Here are the key components:

We recommend reviewing these documents to understand the system architecture before making significant contributions.

How to Contribute

Reporting Issues

Open an issue with a clear description, steps to reproduce, and relevant environment details. See ISSUES.md for what to include in bug reports and feature requests.

Improving Documentation

Help us keep the docs clear and useful by fixing typos, updating outdated information, or adding examples.

Contributing Changes

  • Open an Issue – For features, behavior or API changes and non-trivial fixes, find or open an issue first so maintainers can confirm the direction. Trivial fixes and documentation changes do not need one.
  • Fork and Clone – Begin by forking the repository and cloning it to your local machine.
  • Create a Branch – Use a descriptive branch name, such as feature/add-cool-feature or bugfix/fix-issue123.
  • Make Changes – Keep your commits small, focused, and well-documented. For detailed build and test instructions, refer to Building from Source.
  • Log Changes – For behavior-affecting changes (features, fixes, API changes), add a changelog entry by running make changelog (powered by changie). This creates a small fragment file under .changes/unreleased/ instead of editing CHANGELOG.md directly, so entries never conflict between PRs or backports. CHANGELOG.md is the source of truth for released versions (following keepachangelog.com); your fragment stays in .changes/unreleased/ until a maintainer cuts the next release, which folds the pending fragments into CHANGELOG.md and clears them. Skip logging internal changes like refactoring or tests. CI checks for a fragment; add the skip-changelog label to your PR to skip if your change doesn't require a changelog entry.
  • Submit a PR – Open a pull request and link the issue (Fixes #N) under "Related Issues" in the PR description.
  • Approval Policy – PRs from external contributors require approval from 2 trusted reviewers (organization members or collaborators) before merging.
  • Coverage - Please look at the coverage change details and create unit tests, integration tests or end-to-end tests to cover new functionality or changes.

Changing API Types and Shared Utilities

API types, generated clients, and the constants, utilities/resources and utilities/podgroup packages live in the github.com/kai-scheduler/api module. Change them there first:

  1. Make the change in kai-scheduler/api.
  2. Test it here with a local replace github.com/kai-scheduler/api => ../api in go.mod. Do not commit the replace.
  3. Release a new api version, then bump it here with go get github.com/kai-scheduler/api@vX.Y.Z.

The in-tree copies under pkg/apis and pkg/common/{constants,podgroup} have been removed. See the api repo's Contributing section.

Build, Test and Validate

make test and make build run in Docker and are slow; prefer targeted commands while iterating. See Building from Source for the full flow.

make validate                                  # regenerates everything and checks git diff; run before finishing any non-trivial change
go test ./pkg/scheduler/actions/allocate       # most packages use plain go test
go test -run TestHandleAllocation ./pkg/scheduler/actions/allocate
go tool ginkgo -v --focus "pattern" ./pkg/binder/controllers/integration_tests   # Ginkgo suites
make envtest                                   # then run go test with KUBEBUILDER_ASSETS (see build/makefile/testenv.mk)
./hack/run-e2e-kind.sh                         # e2e on kind; add --preserve-cluster to keep it
go tool ginkgo -r --randomize-all --label-filter '!autoscale && !scale && !upgrade && !gitops' ./test/e2e/suites   # CI e2e filter
  • Test files live next to the code and end in _test.go.
  • Not every package is Ginkgo. Check for a suite_test.go before using ginkgo.

Code Style

Only what linters and gofmt do not enforce:

  • Imports in three groups: stdlib, external, internal.
  • ctx context.Context is the first parameter.
  • Comments explain why, not what. Keep them short, with no pronouns (I, we). Do not add obvious comments.
  • New files need the Apache-2.0 + NVIDIA header (make gen-license).
  • Add RBAC through kubebuilder markers, e.g. // +kubebuilder:rbac:groups=core,resources=pods,verbs=get, then run make manifests.
  • Never hand-edit generated files (zz_generated*, CRDs, RBAC templates, *_mock.go); change the source and run make manifests generate-mocks. New mocks go in the generate-mocks list in the Makefile.
  • Logging follows the practices below. V(5+) scheduler logs must be guarded with .Do(...).

Logging Practices

Use log.InfraLogger for scheduler actions and phases. V(2-3) logs are operational; V(5+) logs are diagnostic and may run in scheduler hot paths.

Guard V(5+) scheduler logs with VerboseLogger.Do so disabled verbosity does not construct arguments or perform formatting:

log.InfraLogger.V(6).Do(func() {
	log.InfraLogger.Infof("Task <%s/%s> allocatable on node <%s>",
		task.Namespace, task.Name, node.Name)
})

Create values used only by a V(5+) message inside the callback, including fmt.Sprintf, joins, detailed-error rendering, and stringification. Leave operational V(1-4) logs and controller-runtime contextual logs unchanged.

PR Title Guidelines

PR titles must follow the Conventional Commits title specification. The format is:

<type>[optional scope]: <description>

Types

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that don't affect code meaning (formatting, whitespace)
  • refactor: Code changes that neither fix a bug nor add a feature
  • perf: Performance improvements
  • test: Adding or updating tests
  • build: Changes to build system or dependencies
  • ci: Changes to CI/CD configuration
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit

Scopes (Optional)

The allowed scopes are listed in .github/workflows/validate-pr-title.yaml.

Breaking Changes

Breaking changes MUST be indicated by adding ! after the type/scope: feat(api)!: remove deprecated field

Examples

feat(scheduler): add GPU topology-aware scheduling
fix(binder): resolve race condition in pod binding
docs: update installation guide
refactor(api): simplify PodGroup status structure
feat(api)!: remove deprecated field from CRD

Tips

  • Use the imperative mood: "add feature" not "added feature"
  • Don't end with a period

Pull Request Checklist

Before introducing major changes, we strongly recommend opening a PR that outlines your proposed design. Each pull request should meet the following requirements:

  • All tests pass – Run the full test suite locally with: make build validate test
  • Test coverage – Add or update tests for any affected code.
  • Documentation – Update relevant documentation to reflect your changes.
  • Changes logged - If your changes warrant logging - like behavior changes (including bugfixes) or new features - run make changelog to add a changelog fragment (do not edit CHANGELOG.md directly). Use the skip-changelog label to opt out if not needed.
  • PR description – Fill out the pull request template completely

Getting Help

Need support or have a question? We're here to help:

Developer Certificate of Origin (DCO)

All commits must be signed off to certify you authored the change and agree to the DCO. Add -s to your commit command:

git commit -s -m "feat: my change"

This appends a Signed-off-by: Your Name <your@email.com> line to the commit message.

Fixing unsigned commits:

# Amend the last commit
git commit --amend -s

# Sign all commits on your branch at once
git rebase --signoff origin/main

License

By contributing, you agree that your contributions will be licensed under the Apache License 2.0.

Thank you for your interest and happy coding!