Skip to content

Commit 66d09b8

Browse files
committed
add generics policy draft
as discussed in the last SIG Architecture meeting
1 parent 8465376 commit 66d09b8

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

sig-architecture/generics.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Background
2+
3+
In general, Kubernetes has not restricted using new Go features, we've quickly
4+
adopted new standard library types and methods and will continue to do so.
5+
6+
Generally the latest stable go release is in use on the main development branch.
7+
This includes all of the staging libraries (client-go etc.) that originate in the
8+
main [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes) repository.
9+
10+
In Kubernetes v1.24 we shipped Go 1.18 (which adds support for generics)
11+
rather late in the release cycle, so we temporarily prohibited using generics
12+
in case we ran into other issues and needed to roll back to unblock the release.
13+
Now that v1.24.0 is out, use of generics should be allowed.
14+
15+
# Generics Policy
16+
17+
Generics may be used in Kubernetes starting in v1.25, with the following restrictions
18+
applying only until v1.24 is [out of support][version-support]:
19+
20+
- Generics should **not** be used in Kubernetes libraries used across multiple Kubernetes
21+
versions, that is the non "staged" libraries like:
22+
- [k8s.io/utils](https://github.com/kubernetes/utils)
23+
- [sigs.k8s.io/yaml](https://github.com/kubernetes-sigs/yaml)
24+
- [k8s.io/klog](https://github.com/kubernetes/klog)
25+
- etc.
26+
27+
- Generics should be **avoided** when writing Kubernetes bug fixes that are likely to be backported, to streamline cherry-picking to older release branches.
28+
29+
These restrictions should be considered lifted when v1.24 is out of support.
30+
31+
## Recommendations for Reviewers
32+
33+
- Consider if proposed generics pull requests improve maintainability and readability.
34+
35+
- The current generics implementation is known to have some performance issues
36+
depending on usage: consider requesting benchmarks before / after the changes.
37+
38+
[version-support]: https://kubernetes.io/releases/patch-releases/#support-period

0 commit comments

Comments
 (0)