|
53 | 53 | - [Scalability](#scalability)
|
54 | 54 | - [Troubleshooting](#troubleshooting)
|
55 | 55 | - [Implementation History](#implementation-history)
|
| 56 | +- [Status and next steps](#status-and-next-steps) |
56 | 57 | - [Drawbacks](#drawbacks)
|
57 | 58 | - [Alternatives](#alternatives)
|
58 | 59 | - [Per-component logger](#per-component-logger)
|
@@ -520,9 +521,8 @@ logger.Info("Processing", "pod", klog.KObj(pod))
|
520 | 521 | logger.Info("Done", "pod", klog.KObj(pod))
|
521 | 522 | ```
|
522 | 523 |
|
523 |
| -Starting with beta, the feature gate will be enabled and code can be written |
524 |
| -without such duplication to avoid the need for further changes when reaching |
525 |
| -GA: |
| 524 | +Starting with GA, the feature will always be enabled and code can be written |
| 525 | +without such duplication: |
526 | 526 |
|
527 | 527 | ```
|
528 | 528 | logger := logger.WithValues("pod", klog.KObj(pod))
|
@@ -1075,14 +1075,130 @@ None besides bugs that could cause a program to panic (null logger).
|
1075 | 1075 |
|
1076 | 1076 | ###### What steps should be taken if SLOs are not being met to determine the problem?
|
1077 | 1077 |
|
1078 |
| -Revert commits that changed log calls. |
| 1078 | +A cluster operator can disable the feature via the feature gate. |
| 1079 | + |
| 1080 | +Kubernetes developers can revert individual commits that changed log calls once |
| 1081 | +it has been determined that they introduce too much overhead. |
1079 | 1082 |
|
1080 | 1083 | ## Implementation History
|
1081 | 1084 |
|
1082 | 1085 | * Kubernetes 1.24: initial alpha
|
1083 | 1086 | * Kubernetes 1.27: parts of kube-controller-manager converted
|
1084 | 1087 | * Kubernetes 1.28: kube-controller-manager converted completely, relationship
|
1085 | 1088 | with log/slog in Go 1.21 clarified
|
| 1089 | +* Kubernetes 1.29: kube-scheduler converted completely |
| 1090 | + |
| 1091 | +## Status and next steps |
| 1092 | + |
| 1093 | +As of Kubernetes 1.29.1, kube-controller-manager and kube-scheduler have been |
| 1094 | +converted. The logcheck tool can be used to count remaining log calls that need |
| 1095 | +to be converted: |
| 1096 | + |
| 1097 | +``` |
| 1098 | +go install sigs.k8s.io/logtools/logcheck@latest |
| 1099 | +
|
| 1100 | +echo "Component | Non-Structured Logging | Non-Contextual Logging " && echo "------ | ------- | -------" && for i in $(find pkg/* cmd/* staging/src/k8s.io/* -maxdepth 0 -type d | sort); do echo "$i | $(cd $i; ${GOPATH}/bin/logcheck -check-structured -check-deprecations=false 2>&1 ./... | wc -l ) | $(cd $i; ${GOPATH}/bin/logcheck -check-structured -check-deprecations=false -check-contextual ./... 2>&1 | wc -l )"; done |
| 1101 | +``` |
| 1102 | + |
| 1103 | +Note that this also counts calls where it was decided to not convert them. The |
| 1104 | +actual check with golangci-lint ignores those because of a `//nolint:logcheck` |
| 1105 | +suppression comment. |
| 1106 | + |
| 1107 | +Component | Non-Structured Logging | Non-Contextual Logging |
| 1108 | +------ | ------- | ------- |
| 1109 | +cmd/clicheck | 0 | 0 |
| 1110 | +cmd/cloud-controller-manager | 6 | 8 |
| 1111 | +cmd/dependencycheck | 0 | 0 |
| 1112 | +cmd/dependencyverifier | 0 | 0 |
| 1113 | +cmd/fieldnamedocscheck | 1 | 1 |
| 1114 | +cmd/gendocs | 0 | 0 |
| 1115 | +cmd/genkubedocs | 0 | 0 |
| 1116 | +cmd/genman | 0 | 0 |
| 1117 | +cmd/genswaggertypedocs | 2 | 2 |
| 1118 | +cmd/genutils | 0 | 0 |
| 1119 | +cmd/genyaml | 0 | 0 |
| 1120 | +cmd/gotemplate | 0 | 0 |
| 1121 | +cmd/importverifier | 0 | 0 |
| 1122 | +cmd/kubeadm | 264 | 463 |
| 1123 | +cmd/kube-apiserver | 6 | 7 |
| 1124 | +cmd/kube-controller-manager | 0 | 0 |
| 1125 | +cmd/kubectl | 0 | 0 |
| 1126 | +cmd/kubectl-convert | 0 | 0 |
| 1127 | +cmd/kubelet | 0 | 52 |
| 1128 | +cmd/kubemark | 1 | 1 |
| 1129 | +cmd/kube-proxy | 0 | 42 |
| 1130 | +cmd/kube-scheduler | 0 | 0 |
| 1131 | +cmd/preferredimports | 0 | 0 |
| 1132 | +cmd/prune-junit-xml | 0 | 0 |
| 1133 | +cmd/yamlfmt | 0 | 0 |
| 1134 | +pkg/api | 0 | 0 |
| 1135 | +pkg/apis | 0 | 0 |
| 1136 | +pkg/auth | 1 | 1 |
| 1137 | +pkg/capabilities | 0 | 0 |
| 1138 | +pkg/client | 0 | 0 |
| 1139 | +pkg/cloudprovider | 0 | 0 |
| 1140 | +pkg/cluster | 0 | 0 |
| 1141 | +pkg/controller | 0 | 3 |
| 1142 | +pkg/controlplane | 53 | 69 |
| 1143 | +pkg/credentialprovider | 48 | 77 |
| 1144 | +pkg/features | 0 | 0 |
| 1145 | +pkg/fieldpath | 0 | 0 |
| 1146 | +pkg/generated | 0 | 0 |
| 1147 | +pkg/kubeapiserver | 4 | 4 |
| 1148 | +pkg/kubectl | 1 | 2 |
| 1149 | +pkg/kubelet | 2 | 1983 |
| 1150 | +pkg/kubemark | 7 | 7 |
| 1151 | +pkg/printers | 0 | 0 |
| 1152 | +pkg/probe | 7 | 24 |
| 1153 | +pkg/proxy | 0 | 360 |
| 1154 | +pkg/quota | 0 | 0 |
| 1155 | +pkg/registry | 46 | 99 |
| 1156 | +pkg/routes | 2 | 2 |
| 1157 | +pkg/scheduler | 0 | 0 |
| 1158 | +pkg/security | 0 | 0 |
| 1159 | +pkg/securitycontext | 0 | 0 |
| 1160 | +pkg/serviceaccount | 25 | 44 |
| 1161 | +pkg/util | 20 | 57 |
| 1162 | +pkg/volume | 704 | 1110 |
| 1163 | +pkg/windows | 1 | 1 |
| 1164 | +staging/src/k8s.io/api | 0 | 0 |
| 1165 | +staging/src/k8s.io/apiextensions-apiserver | 58 | 89 |
| 1166 | +staging/src/k8s.io/apimachinery | 80 | 125 |
| 1167 | +staging/src/k8s.io/apiserver | 285 | 655 |
| 1168 | +staging/src/k8s.io/client-go | 163 | 283 |
| 1169 | +staging/src/k8s.io/cli-runtime | 1 | 2 |
| 1170 | +staging/src/k8s.io/cloud-provider | 122 | 162 |
| 1171 | +staging/src/k8s.io/cluster-bootstrap | 2 | 4 |
| 1172 | +staging/src/k8s.io/code-generator | 108 | 155 |
| 1173 | +staging/src/k8s.io/component-base | 33 | 64 |
| 1174 | +staging/src/k8s.io/component-helpers | 2 | 4 |
| 1175 | +staging/src/k8s.io/controller-manager | 10 | 10 |
| 1176 | +staging/src/k8s.io/cri-api | 0 | 0 |
| 1177 | +staging/src/k8s.io/csi-translation-lib | 3 | 4 |
| 1178 | +staging/src/k8s.io/dynamic-resource-allocation | 0 | 0 |
| 1179 | +staging/src/k8s.io/endpointslice | 0 | 0 |
| 1180 | +staging/src/k8s.io/kms | 0 | 0 |
| 1181 | +staging/src/k8s.io/kube-aggregator | 45 | 62 |
| 1182 | +staging/src/k8s.io/kube-controller-manager | 0 | 0 |
| 1183 | +staging/src/k8s.io/kubectl | 96 | 160 |
| 1184 | +staging/src/k8s.io/kubelet | 0 | 32 |
| 1185 | +staging/src/k8s.io/kube-proxy | 0 | 0 |
| 1186 | +staging/src/k8s.io/kube-scheduler | 0 | 0 |
| 1187 | +staging/src/k8s.io/legacy-cloud-providers | 1281 | 2015 |
| 1188 | +staging/src/k8s.io/metrics | 0 | 0 |
| 1189 | +staging/src/k8s.io/mount-utils | 55 | 95 |
| 1190 | +staging/src/k8s.io/pod-security-admission | 0 | 1 |
| 1191 | +staging/src/k8s.io/sample-apiserver | 0 | 0 |
| 1192 | +staging/src/k8s.io/sample-cli-plugin | 0 | 0 |
| 1193 | +staging/src/k8s.io/sample-controller | 0 | 0 |
| 1194 | + |
| 1195 | +For Kubernetes 1.30, the focus is on client-go. APIs need to be extended |
| 1196 | +carefully without breaking existing code so that a context can be provided for |
| 1197 | +log calls. In some cases, this also makes a context available to code which |
| 1198 | +currently uses `context.TODO` as a stop-gap measure. Currently there are over |
| 1199 | +300 of those in `staging/src/k8s.io/client-go`. Whenever new APIs get |
| 1200 | +introduced, components which were already converted to contextual logging get |
| 1201 | +updated to use those. |
1086 | 1202 |
|
1087 | 1203 | ## Drawbacks
|
1088 | 1204 |
|
|
0 commit comments