Contributing to ORCA¶
Thank you for your interest in contributing to ORCA! We welcome contributions from the community.
Getting Started¶
Prerequisites¶
- Go 1.21 or higher
- Docker (for containerized testing)
- kubectl (for Kubernetes testing)
- AWS account (for integration testing)
- golangci-lint (for linting)
Development Setup¶
-
Clone the repository
-
Install dependencies
-
Install development tools
-
Build the project
-
Run tests
Development Workflow¶
Making Changes¶
-
Create a feature branch
-
Make your changes
- Write idiomatic Go code
- Follow the project structure conventions
- Add tests for new functionality
-
Update documentation as needed
-
Format and lint
-
Run tests
-
Commit your changes
Commit Message Convention¶
We follow Conventional Commits:
feat:- New featurefix:- Bug fixdocs:- Documentation changestest:- Adding or updating testsrefactor:- Code refactoringperf:- Performance improvementschore:- Maintenance tasks
Examples:
feat: add explicit instance selection support
fix: handle pod deletion edge cases
docs: update instance selection guide
test: add unit tests for AWS client
Pull Request Process¶
- Update documentation - Ensure README.md and relevant docs are updated
- Add changelog entry - Add your changes to CHANGELOG.md under [Unreleased]
- Ensure tests pass - All tests must pass (
make test) - Ensure linting passes - Code must pass linting (
make lint) - Create pull request - Provide clear description of changes
- Request review - Tag maintainers for review
Code Style Guidelines¶
Go Code Style¶
- Follow Effective Go
- Use
gofmtfor formatting (runmake fmt) - Keep functions focused and small
- Write self-documenting code with clear variable names
- Add comments for exported functions and complex logic
Error Handling¶
// Good: Wrap errors with context
if err != nil {
return fmt.Errorf("failed to create instance: %w", err)
}
// Bad: Generic error
if err != nil {
return err
}
Logging¶
// Use structured logging
log.Info("creating pod",
"namespace", pod.Namespace,
"name", pod.Name,
"instanceType", instanceType)
Testing Guidelines¶
Unit Tests¶
- Write tests for all new functionality
- Aim for >80% code coverage
- Use table-driven tests where appropriate
- Mock external dependencies (AWS SDK, Kubernetes API)
Example:
func TestSelectInstanceType(t *testing.T) {
tests := []struct {
name string
pod *corev1.Pod
expected string
}{
{
name: "explicit instance type",
pod: &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"orca.research/instance-type": "p5.48xlarge",
},
},
},
expected: "p5.48xlarge",
},
// More test cases...
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := selectInstanceType(tt.pod)
if result != tt.expected {
t.Errorf("expected %s, got %s", tt.expected, result)
}
})
}
}
Integration Tests¶
- Test against real AWS services when possible
- Use AWS localstack for local testing
- Clean up resources after tests
Documentation¶
Code Documentation¶
- Document all exported functions, types, and constants
- Use godoc format
// CreatePod creates a new pod by launching an EC2 instance.
// It returns an error if the instance cannot be created.
func (p *Provider) CreatePod(ctx context.Context, pod *corev1.Pod) error {
// Implementation
}
User Documentation¶
- Update README.md for user-facing changes
- Add examples in
examples/directory - Update relevant docs in
docs/directory
Architecture Guidelines¶
Project Structure¶
cmd/orca/ # Main application entry point
pkg/ # Public libraries
provider/ # Virtual Kubelet provider implementation
config/ # Configuration management
instances/ # Instance selection logic
internal/ # Private application code
aws/ # AWS SDK integration
container/ # Container runtime integration
metrics/ # Metrics and monitoring
Design Principles¶
- Explicit over Implicit - Users should specify what they want
- Research-First - Optimize for research computing workflows
- Production-Grade - Write code as if it will run at scale
- Testability - Design for testability from the start
- Observability - Include metrics, logging, tracing
Getting Help¶
- GitHub Issues - Bug reports and feature requests
- GitHub Discussions - Questions and general discussion
- Research Partners - Reach out to NRP, SDSU contacts
Code of Conduct¶
- Be respectful and inclusive
- Focus on constructive feedback
- Welcome newcomers
- Assume good intentions
License¶
By contributing to ORCA, you agree that your contributions will be licensed under the Apache License 2.0.