Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The scan status displays 'Scanning,' even though the job has reached the specified backoff limit #2326

Closed
Alon-Katz opened this issue Mar 3, 2024 · 1 comment · Fixed by #2568
Assignees
Labels
bug Bugs

Comments

@Alon-Katz
Copy link

Alon-Katz commented Mar 3, 2024

🐞 Bug report

Describe the bug

The scan job created by the scan CRD is in a failed state with the event: 'Job has reached the specified backoff limit.' However, the scan CRD continues to display a 'Scanning' status and does not update to 'Failed.'
The latest version included a bug fix intended to address the issue 'Fixed Scans being marked as Failed after the first job has failed,' which may be relevant.
Unfortunately, this fix seems to have exacerbated the problem, as now scans are incorrectly showing a 'Scanning' status when they have actually failed.
ref to the bug fix: #2205

Steps To Reproduce

Run a scan that is failing, look at the job events, view the scan status

Expected behavior

If the job has reached the maximum backoff limit, the scan status should be "Failed" and not "Scanning"

System (please complete the following information):

  • secureCodeBox Version/Release:
    v4.4.1
  • Kubernetes Version [command: kubectl version]:
    Client Version: v1.29.2
    Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
    Server Version: v1.28.5-eks-5e0fdde

Screenshots / Logs

Job output:

Name:             scan-2f1cf8e1-8bf5-4e7e-a0de-93fe6ac44005-rp8mw
Namespace:        scb-scanners
Selector:         batch.kubernetes.io/controller-uid=2ff42089-79a1-4620-a58d-e0175702153e
Labels:           securecodebox.io/job-type=scanner
Annotations:      <none>
Controlled By:    Scan/2f1cf8e1-8bf5-4e7e-a0de-93fe6ac44005
Parallelism:      1
Completions:      1
Completion Mode:  NonIndexed
Start Time:       Sun, 03 Mar 2024 10:33:15 +0200
Pods Statuses:    0 Active (0 Ready) / 0 Succeeded / 1 Failed
Pod Template:
  Labels:           app.kubernetes.io/managed-by=securecodebox
                    batch.kubernetes.io/controller-uid=2ff42089-79a1-4620-a58d-e0175702153e
                    batch.kubernetes.io/job-name=scan-2f1cf8e1-8bf5-4e7e-a0de-93fe6ac44005-rp8mw
                    controller-uid=2ff42089-79a1-4620-a58d-e0175702153e
                    job-name=scan-2f1cf8e1-8bf5-4e7e-a0de-93fe6ac44005-rp8mw
  Annotations:      auto-discovery.securecodebox.io/ignore: true
                    sidecar.istio.io/inject: false
  Service Account:  lurker
  Containers:
   gitleaks:
    Image:      docker.io/zricethezav/gitleaks:v8.18.2
    Port:       <none>
    Host Port:  <none>
    Command:
      gitleaks
      --verbose
      --report-format
      sarif
      --report-path
      /home/securecodebox/report.json
      --exit-code
      0
      detect
      detect
      --source
      /f14b0104-c583-45ae-bba6-d7eb8df767d0/48ec99a2-61f7-4a07-992b-cdb2bc7a0467/379931510/efea2f02da73197dd1f5faeb174fc6cddd36e459
      --log-opts
      efea2f02da73197dd1f5faeb174fc6cddd36e459
    Limits:
      cpu:     1
      memory:  2Gi
    Requests:
      cpu:     500m
      memory:  1Gi
    Environment:
      STAGE:  prod
    Mounts:
      /f14b0104-c583-45ae-bba6-d7eb8df767d0/48ec99a2-61f7-4a07-992b-cdb2bc7a0467/379931510/efea2f02da73197dd1f5faeb174fc6cddd36e459 from efs (ro,path="f14b0104-c583-45ae-bba6-d7eb8df767d0/48ec99a2-61f7-4a07-992b-cdb2bc7a0467/379931510/efea2f02da73197dd1f5faeb174fc6cddd36e459")
      /home/securecodebox/ from scan-results (rw)
   lurker:
    Image:      docker.io/securecodebox/lurker:4.4.1
    Port:       <none>
    Host Port:  <none>
    Args:
      --container
      gitleaks
      --file
      /home/securecodebox/report.json
      --url
      ...
    Limits:
      cpu:     100m
      memory:  100Mi
    Requests:
      cpu:     20m
      memory:  20Mi
    Environment:
      NAMESPACE:   (v1:metadata.namespace)
    Mounts:
      /home/securecodebox/ from scan-results (ro)
  Volumes:
   scan-results:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
   efs:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  scb-scanners-pvc
    ReadOnly:   true
Events:
  Type     Reason                Age   From            Message
  ----     ------                ----  ----            -------
  Normal   SuccessfulCreate      12m   job-controller  Created pod: scan-2f1cf8e1-8bf5-4e7e-a0de-93fe6ac44005-rp8mw-5rh4z
  Normal   SuccessfulDelete      10m   job-controller  Deleted pod: scan-2f1cf8e1-8bf5-4e7e-a0de-93fe6ac44005-rp8mw-5rh4z
  Warning  BackoffLimitExceeded  10m   job-controller  Job has reached the specified backoff limit

Scan output:

Name:         2f1cf8e1-8bf5-4e7e-a0de-93fe6ac44005
Namespace:    scb-scanners
Labels:       <none>
Annotations: <none>
API Version:  execution.securecodebox.io/v1
Kind:         Scan
Metadata:
  Creation Timestamp:  2024-03-03T08:33:15Z
  Finalizers:
    s3.storage.securecodebox.io
  Generation:        2
  Resource Version:  77260138
  UID:               dcee8417-87ae-4cc7-8bc7-add3ef829d93
Spec:
  Parameters:
    detect
    --source
    /f14b0104-c583-45ae-bba6-d7eb8df767d0/48ec99a2-61f7-4a07-992b-cdb2bc7a0467/379931510/efea2f02da73197dd1f5faeb174fc6cddd36e459
    --log-opts
    efea2f02da73197dd1f5faeb174fc6cddd36e459
  Resource Mode:  namespaceLocal
  Resources:
  Scan Type:  gitleaks
  Volume Mounts:
    Mount Path:  /f14b0104-c583-45ae-bba6-d7eb8df767d0/48ec99a2-61f7-4a07-992b-cdb2bc7a0467/379931510/efea2f02da73197dd1f5faeb174fc6cddd36e459
    Name:        efs
    Read Only:   true
    Sub Path:    f14b0104-c583-45ae-bba6-d7eb8df767d0/48ec99a2-61f7-4a07-992b-cdb2bc7a0467/379931510/efea2f02da73197dd1f5faeb174fc6cddd36e459
  Volumes:
    Name:  efs
    Persistent Volume Claim:
      Claim Name:  scb-scanners-pvc
      Read Only:   true
Status:
  Finding Download Link:  ....
  Raw Result Type:           gitleaks-json
  State:                     Scanning
Events:                      <none>
Screenshot 2024-03-03 at 13 51 41 Screenshot 2024-03-03 at 13 51 57
@Alon-Katz Alon-Katz added the bug Bugs label Mar 3, 2024
@Alon-Katz Alon-Katz changed the title Scan shows state "Scanning" while Job has reached the specified backoff limit The scan status displays 'Scanning,' even though the job has reached the specified backoff limit. Mar 3, 2024
@Alon-Katz Alon-Katz changed the title The scan status displays 'Scanning,' even though the job has reached the specified backoff limit. The scan status displays 'Scanning,' even though the job has reached the specified backoff limit Mar 3, 2024
@J12934
Copy link
Member

J12934 commented Mar 4, 2024

Oh mh interessting, we'll have a look.
Thank you for the detailed report 🙌

Ilyesbdlala added a commit that referenced this issue Jul 9, 2024
…d due to exceeding the backoff limit

we had the assumption that job.Status.Failed calculates the number of times the job failed. it is actually the number of pods that failed due to this job. In this case it will always be a max of 1. Supplemented it with job.Status.Conditions[].Reason

Signed-off-by: Ilyes Ben Dlala <[email protected]>
Weltraumschaf pushed a commit that referenced this issue Jul 31, 2024
…d due to exceeding the backoff limit

we had the assumption that job.Status.Failed calculates the number of times the job failed. it is actually the number of pods that failed due to this job. In this case it will always be a max of 1. Supplemented it with job.Status.Conditions[].Reason

Signed-off-by: Ilyes Ben Dlala <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants