kubernetes: error syncing CronJobController
What happened?
I have some errors from kube-controller-manager logs. The errors repeat and repeat.
E1009 08:42:04.145383 1 cronjob_controllerv2.go:164] error syncing CronJobController cdr/hello, requeuing: Operation cannot be fulfilled on cronjobs.batch "hello": the object has been modified; please apply your changes to the latest version and try again
E1009 08:41:03.919023 1 cronjob_controllerv2.go:164] error syncing CronJobController cdr/hello, requeuing: Operation cannot be fulfilled on cronjobs.batch "hello": the object has been modified; please apply your changes to the latest version and try again
The Cronjob is pretty simple from Kubernetes docs:
apiVersion: batch/v1
kind: CronJob
metadata:
name: hello
spec:
schedule: "* * * * *"
jobTemplate:
spec:
template:
spec:
restartPolicy: Never
imagePullSecrets:
- name: dockerhubcred
containers:
- name: hello
image: busybox:1.28
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
resources:
limits:
memory: "200Mi"
cpu: "200m"
requests:
memory: "100Mi"
cpu: "100m"
Another cronjobs have the same error.
What did you expect to happen?
I don’t understand why this error is reproduced. Job have Succeeded status and run correctly.
How can we reproduce it (as minimally and precisely as possible)?
Use the above.
Anything else we need to know?
No response
Kubernetes version
$ kubectl version
Server Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.8", GitCommit:"0ce7342c984110dfc93657d64df5dc3b2c0d1fe9", GitTreeState:"clean", BuildDate:"2023-03-15T13:33:02Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
Cloud provider
No
OS version
From master (nodes is identical):
# On Linux:
$ cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="8.7"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="8.7"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Oracle Linux Server 8.7"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:8:7:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 8"
ORACLE_BUGZILLA_PRODUCT_VERSION=8.7
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=8.7
$ uname -a
Linux k8s-master1 4.18.0-425.13.1.el8_7.x86_64 #1 SMP Tue Feb 21 15:09:05 PST 2023 x86_64 x86_64 x86_64 GNU/Linux
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 30 (13 by maintainers)
This problem has always existed and belongs to the category of occasional problems. Usually occurs on sync periodic cronjobs。I replicated this issue using this template in the v1.28.2 environment:
I added some printing in the code https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/cronjob/cronjob_controllerv2.go#L211
And the error log shows that the same resourceVersion was updated by two sync:
Because the cronjob obtained by sync every time is taken from the cache:https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/cronjob/cronjob_controllerv2.go#L183 So this issue may be due to the cache not synchronizing in real-time from ETCD,resulting in the obtained cronjob data not being the last updated data
Can someone else provide some helpful information?
This https://github.com/kubernetes/kubernetes/issues/103607 issue got fixed at https://github.com/kubernetes/kubernetes/pull/104799 but we’re still experiencing it after the fix. We started having the issue with CronJob Controller v2 which hit stable in Kubernetes 1.21. The issue persists on Kubernetes 1.27/1.25 for our case.
@devopskolesnikov I am not getting any error message in logs. Its triggering me the message
Hello from the Kubernetes cluster