Skip to content

Commit 89e9132

Browse files
Add more design and testing guidelines
1 parent 6d24885 commit 89e9132

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

sig-scheduling/CONTRIBUTING.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ also follow the requirements of `Bug Report`, it will help us a lot when analyzi
3737
* If there's any debate on the rationalities, you can bring it to the [SIG meeting](https://github.com/kubernetes/community/tree/master/sig-scheduling#meetings).
3838
* If there are multiple implementation options, consider creating a doc with Pros and Cons, and gather some feedback.
3939
You can do this by sharing the doc with the SIG's [mailing list](https://groups.google.com/forum/#!forum/kubernetes-sig-scheduling).
40-
* If necessary, open an issue in kubernetes/enhancements and write a [KEP](https://github.com/kubernetes/enhancements/tree/master/keps/sig-scheduling) for it.
40+
* Any feature that requires an API change or significant refactoring
41+
should be preceded by a [Kubernetes Enhancement Proposal (KEP)](https://github.com/kubernetes/enhancements/tree/master/keps/sig-scheduling).
4142

4243
* If you find any out-of-date documentation, please help the community correct that by either sending a PR to
4344
update the docs or open an issue if you are not sure about how to fix it.
@@ -77,16 +78,39 @@ to the issue/PR, which helps to preserve the context.
7778
The following guidelines apply primarily to kube-scheduler, but some subprojects
7879
might also adhere to them.
7980

81+
When designing a feature, think about components that depend on kube-scheduler
82+
code, such as [cluster-autoscaler](https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler)
83+
or [scheduler-plugins](https://github.com/kubernetes-sigs/scheduler-plugins).
84+
Also consider interactions with other core components such as [kubelet](https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/).
85+
86+
When coding:
8087
- Follow [effective go](https://go.dev/doc/effective_go) guidelines.
88+
- Use [contextual logging](https://git.k8s.io/community/contributors/devel/sig-instrumentation/migration-to-structured-logging.md#contextual-logging-in-kubernetes).
89+
Some packages might still be using [structured logging](https://git.k8s.io/community/contributors/devel/sig-instrumentation/logging.md).
90+
- When writing APIs, follow [k8s API conventions](https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md)
8191
- Naming:
8292
- Length: As a rule-of-thumb, the length of a variable name should be
8393
proportional to the size of the scope where it is used and inversely
8494
proportional to the number of times that it is used.
85-
- In tests:
95+
96+
Testing:
97+
- Unit tests: every change should have high coverage by unit tests.
98+
- Integration tests: should cover interactions between the different components
99+
of kube-scheduler (event handlers, queue, cache, scheduling cycles) and
100+
kube-apiserver.
101+
- E2E tests: should cover interactions with other components, such as kubelet,
102+
kube-controller-manager, etc.
103+
- [Perf tests](https://github.com/kubernetes/kubernetes/tree/master/test/integration/scheduler_perf):
104+
should be considered for critical and/or CPU intensive operations.
105+
- General guidelines:
86106
- Follow a [DAMP principle](https://stackoverflow.com/a/11837973).
87107
- Use `cmp.Diff` instead of `reflect.Equal`, to provide useful comparisons.
108+
- Compare errors using `errors.Is` (`cmpopts.EquateErrors` when using
109+
`cmp.Diff`) instead of comparing the error strings.
110+
- Leverage existing utility functions from `pkg/scheduler/testing`.
88111
- Avoid creating or using assertion libraries.
89112
Use standard `t.Error` or `t.Fatal`, as necessary.
113+
- `gomega` and `ginkgo` should only be used in E2E tests.
90114

91115
Note that some existing code might be in violation of these guidelines, as it
92116
might have been written before these guidelines were established. Feel free to

0 commit comments

Comments
 (0)