lwolf / kube-cleanup-operator

Kubernetes Operator to automatically delete completed Jobs and their Pods
MIT License
498 stars 109 forks source link

Pod xxxx was not created by a job, ignoring. #15

Closed SqiSch closed 6 years ago

SqiSch commented 6 years ago

He Sergey, i always get the message:

Pod xxxx was not created by a job, ignoring.

We running kubernetes 1.9.6 on google container engine.
Our job manifest f.e.:

apiVersion: batch/v1
kind: Job
metadata:
  labels:
    app: behat
    chart: behat-1.0
.....

a describe of a succeeded pod

Name:           behat-d6048dbd-815e-4116-8bf1-71b2ae45c22b-32-8qxpp
Namespace:      default
Labels:         app=behat
                controller-uid=52ae430b-3bd1-11e8-9134-42010a840081
                job-name=behat-d6048dbd-815e-4116-8bf1-71b2ae45c22b-32
.....
Status:         Succeeded
Controlled By:  Job/behat-d6048dbd-815e-4116-8bf1-71b2ae45c22b-32
......

    State:          Terminated
      Reason:       Completed

do you have any clues why the problem here occurs?

Best, Marcel

SqiSch commented 6 years ago

I Found the reason. the version returned by version.Minor is 9+. When doing a strconv.Atoi(version.Minor)the version is 0 and then uses the old version.

i tried to add a branch, but i´m not able to create branches. One possible fix is to regex the version number:

....
    oldVersion := false

    major, _ := strconv.Atoi(version.Major)
    re := regexp.MustCompile("[0-9]+")
    minor, _ := strconv.Atoi(re.FindAllString(version.Minor, -1)[0])

    if major < 2 && minor < 8 {
        oldVersion = true
    }
...

it´s working then with current gcp kubernetes clusters.

lwolf commented 6 years ago

That is very weird. If I'm not mistaken that breaks the SemVer convention. Thank you for reporting the issue and creating the PR