Go 1.27 vet rejects %d with a pointer argument (golang/go#62595).
k/k's go.mod declares go 1.27.0, so seven call sites that pass a
*int32, *uint64 or *int to %d now fail. update.go uses ptr.Deref
because CollisionCount can be nil; the other six sites check nil first.
Kubernetes 1.37 finished the introduction of context-aware client-go APIs.
Components like kube-controller-manager which are meant to support contextual
logging should use those new APIs.
This is not enforced yet because existing code must be updated first. Once
that is done, enforcement of everything touched here can be enabled tree-wide.
NodeShouldRunDaemonPod built a pod from the DaemonSet template and parsed
its required node affinity on every call, and the controller's sync paths
call it once per node in the cluster. Both inputs depend only on the
DaemonSet: the checks consume the daemon pod's tolerations and the parsed
required node affinity, so compute exactly those, once per sync, in
manage, updateDaemonSetStatus, rollingUpdate and updatedDesiredNodeCounts
- no pod object is constructed at all. The affinity is parsed straight
from the pod template via nodeaffinity.NewRequiredNodeAffinity; the
tolerations are the template's plus the daemon-pod defaults
(daemonPodTolerations).
predicates' fitsNodeName check is dropped: it was vacuously true (NewPod
pinned Spec.NodeName to the examined node, so the comparison always
passed); the template NodeName precondition is still checked directly in
nodeShouldRunDaemonPod. NodeShouldRunDaemonPod keeps its signature and
behavior.
benchstat vs the benchmark commit (BenchmarkUpdateDaemonSetStatus,
-benchtime 1s -count 10): geomean sec/op -97.5%, B/op -99.6%,
allocs/op -99.6%.
This is part of the ongoing effort to adopt contextual logging
and utilities throughout the codebase.
Contributes to #126379
Signed-off-by: Aditi Gupta <aditigpta@google.com>
The "// import <path>" comment has been superseded by Go modules.
We don't have to remove them, but doing so has some advantages:
- They are used inconsistently, which is confusing.
- We can then also remove the (currently broken) hack/update-vanity-imports.sh.
- Last but not least, it would be a first step towards avoiding the k8s.io domain.
This commit was generated with
sed -i -e 's;^package \(.*\) // import.*;package \1;' $(git grep -l '^package.*// import' | grep -v 'vendor/')
Everything was included, except for
package labels // import k8s.io/kubernetes/pkg/util/labels
because that package is marked as "read-only".
- Increase the global level for broadcaster's logging to 3 so that users can ignore event messages by lowering the logging level. It reduces information noise.
- Making sure the context is properly injected into the broadcaster, this will allow the -v flag value to be used also in that broadcaster, rather than the above global value.
- test: use cancellation from ktesting
- golangci-hints: checked error return value
* Skip terminal Pods with a deletion timestamp from the Daemonset sync
Change-Id: I64a347a87c02ee2bd48be10e6fff380c8c81f742
* Review comments and fix integration test
Change-Id: I3eb5ec62bce8b4b150726a1e9b2b517c4e993713
* Include deleted terminal pods in history
Change-Id: I8b921157e6be1c809dd59f8035ec259ea4d96301
This touches cases where FromInt() is used on numeric constants, or
values which are already int32s, or int variables which are defined
close by and can be changed to int32s with little impact.
Signed-off-by: Stephen Kitt <skitt@redhat.com>
Most of the individual controllers were already converted earlier. Some log
calls were missed or added and then not updated during a rebase. Some of those
get updated here to fill those gaps.
Adding of the name to the logger used by each controller gets
consolidated in this commit. By using the name under which the
controller is registered we ensure that the names in the log
are consistent.
This ensures that the daemonset controller updates daemonset statuses in
a best-effort manner even if syncDaemonSet fails.
In order to add an integration test, this also replaces
`cmd/kube-apiserver/app/testing.StartTestServer` with
`test/integration/framework.StartTestServer` and adds
`setupWithServerSetup` to configure the admission control of the
apiserver.