Skip to content

job executions started manually for a cronjob are marked as unexpected #120181

@anandanthony

Description

@anandanthony

What happened?

We have a custom resource with a name - Foo
We have a CronJob named - Foo

Now, we have a job whose owner refernce is set to the custom resource name - Foo. We have noticed that the job when stopped (suspended) basically causes an event/warning - "UnexpectedJob" for the given job execution.

syncCronJob is trying to reconcile the job because it thinks that it is owned by the CronJob. Probably because of "getJobsToBeReconciled", at this line.

What did you expect to happen?

The syncCronJob should not try to reconcile the job because it is not owned by the CronJob.

Proposed Solution: syncCronJob should not reconcile the job, since it is owned by the CronJob. The getJobsToBeReconciled method should match the name and the kind of the job. The kind in the case of a cronjob would be CronJob.

How can we reproduce it (as minimally and precisely as possible)?

  • Run a job execution using the same CRD used to create a cronjob.
  • Once the job execution starts, stop (suspend) it.
  • We would start getting events of type Warning with reason - UnexpectedJob.
  • Stop a job execution that was triggered due to the cronjob itself and we would not see warnings for this stopped job execution.

Anything else we need to know?

No response

Kubernetes version

$ kubectl version
# WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.2", GitCommit:"5835544ca568b757a8ecae5c153f317e5736700e", GitTreeState:"clean", BuildDate:"2022-09-21T14:33:49Z", GoVersion:"go1.19.1", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.6", GitCommit:"08d3594304660f86cfbd17bbb862041b4b75fe6c", GitTreeState:"clean", BuildDate:"2023-02-08T17:22:59Z", GoVersion:"go1.18.6", Compiler:"gc", Platform:"linux/amd64"}

Cloud provider

N\A

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, ...) and versions (if applicable)

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.priority/backlogHigher priority than priority/awaiting-more-evidence.sig/appsCategorizes an issue or PR as relevant to SIG Apps.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions