bug (k8s): intermittent failures in k8s scanning #7684
Labels
kind/bug
Categorizes issue or PR as related to a bug.
target/kubernetes
Issues relating to kubernetes cluster scanning
Description
SOMETIMES a k8s scan fails with a panic.
It happens when Trivy executes PostAnalyze yet, but the temporary file is already removed.
I managed to enable logs and caught it.
the full log
Reason
Now Trivy k8s scan tries to handle kubernetes yaml files in parallel.
Because Trivy creates a misconfig scanner for each thread, sometime one misconfig scanner works faster and removes a temporary file, then another misconfig scanner can't find this temporary yaml and will arise a fatal error.
Update: there is a mistake for remove temporary files if an error appears.
this block removes a few files by pattern (
"%s-%s-%s-*.yaml", artifact.Namespace, artifact.Kind, artifact.Name
), instead of a specific file:trivy/pkg/k8s/scanner/io.go
Lines 35 to 38 in 8d5dbc9
Discussed in #7663
The text was updated successfully, but these errors were encountered: