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

bug(k8s): scan for k8s v1.31.1 not working #7736

Closed
afdesk opened this issue Oct 15, 2024 Discussed in #7705 · 3 comments · Fixed by #7810
Closed

bug(k8s): scan for k8s v1.31.1 not working #7736

afdesk opened this issue Oct 15, 2024 Discussed in #7705 · 3 comments · Fixed by #7810
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.
Milestone

Comments

@afdesk
Copy link
Contributor

afdesk commented Oct 15, 2024

Description

Trivy kubernetes scan gets stuck in Kubernetes v1.31.* (tested for v1.31.1).

Reason

it seems it appears here kubernetes/kubernetes#126067

the docs - Difference between "Complete" and "SuccessCriteriaMet":

The similar job conditions, Complete and SuccessCriteriaMet, are different in the following ways:

* Complete means that all pods completed and either all of them were successful or the Job already had SuccessCriteriaMet=true.
* SuccessCriteriaMet means that the job meets at least one of successPolicies.

So, the job could have both conditions, Complete and SuccessCriteriaMet.

Solution

To resolve this issue @fl0pp5 suggested next solution:

https://github.com/aquasecurity/trivy-kubernetes/blob/b070991579cacd7634052dee2e250350d6e493e8/pkg/jobs/runnable_job.go#L68
On v1.31.1 condition.Type == batchv1.JobSuccessCriteriaMet but we await batchv1.JobComplete

@@ -65,7 +65,7 @@ func (r *runnableJob) Run(ctx context.Context) error {
                                return
                        }
                        switch condition := newJob.Status.Conditions[0]; condition.Type {
-                       case batchv1.JobComplete:
+                       case batchv1.JobComplete, batchv1.JobSuccessCriteriaMet:
                                complete <- nil
                        case batchv1.JobFailed:

Discussed in #7705

@afdesk afdesk added the kind/bug Categorizes issue or PR as related to a bug. label Oct 15, 2024
@afdesk afdesk self-assigned this Oct 17, 2024
@siennathesane
Copy link

I can confirm this also happens in 1.31.1 on k3s but no 1.30.5.

@simar7 simar7 added this to the v0.58.0 milestone Oct 29, 2024
@simar7
Copy link
Member

simar7 commented Oct 29, 2024

@afdesk I've moved it to the next (v0.58.0) milestone for now as I'm not sure how much work is needed to finish it, what do you think?

@afdesk
Copy link
Contributor Author

afdesk commented Oct 29, 2024

@afdesk I've moved it to the next (v0.58.0) milestone for now as I'm not sure how much work is needed to finish it, what do you think?

The PR was merged yesterday aquasecurity/trivy-kubernetes#403
I'm testing and will create a PR here in a few hours.
Let me please do it. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

3 participants